Displaying 20 results from an estimated 10000 matches similar to: "Error in x[good, ] * w : non-conformable arrays"
2009 Jul 07
3
Error due to non-conformable arrays
Hello,
Consider this function for generalized ridge regression:
gre <- function (X,y,D){
n <- dim(X)[1]
p <- dim(X)[2]
intercept <- rep(1, n)
X <- cbind(intercept, X)
X2D <- crossprod(X,X)+ D
Xy <- crossprod(X,y)
bth <- qr.solve(X2D, Xy)
}
# suppose X is an (nxp) design matrix and y is an (nx1) response vector
p <- dim(x)[2]
D<- diag(rep(1.5,p))
bt
2004 Sep 09
2
Skipping panels in Lattice
Dear all,
I wish to generate a lattice boxplot which skips an empty cell in a design.
I have trawled r-help, scruitinized xyplot(lattice) help page, and merrily
reproduced examples of using skip from a couple of previous r-help queries
and the example given in Pinheiro & Bates. But I must be missing something...
Here's an example (running R 1.9.1 on Win2k):
# generate some data
df1
2013 Feb 26
2
merging or joining 2 dataframes: merge, rbind.fill, etc.?
#I want to "merge" or "join" 2 dataframes (df1 & df2) into a 3rd
(mydf). I want the 3rd dataframe to contain 1 row for each row in df1
& df2, and all the columns in both df1 & df2. The solution should
"work" even if the 2 dataframes are identical, and even if the 2
dataframes do not have the same column names. The rbind.fill function
seems to work. For
2010 Sep 27
1
conditional assignment of colors in xyplot()
# Dear R Community,
# I have this data frame:
df1 <- data.frame(
F1 = factor( c( rep("D1",12),rep("D2",12),rep("D3",12) ) ),
F2 = factor( rep( rep( paste("O",1:6,sep=""), rep(2,6) ), 3) ),
F3 = factor( rep( c("V1","V2"), 18 ) ),
S1 =
2007 Jan 30
0
lme : Error in y[revOrder] - Fitted : non-conformable arrays
Greetings R-helpers,
I am attempting to fit an lme() while specifying a correlation
structure, but I'm getting into trouble long before I get to that point.
I am receiving the error:
Error in y[revOrder] - Fitted : non-conformable arrays
It doesn't seem to matter how simple or complex the model I specify is,
it always gives this same error message. This makes me suspect
something is
2003 Sep 03
2
lme in R and Splus
Good Day,
Included below is some code to generate data and to fit a mixed effects
model to this fake data. The code works as expected when I call the
function "lme" in Splus but not in R.
The error message from calling lme in R is:
"Error in getGroups.data.frame(dataMix, groups) :
Invalid formula for groups"
I installed the nlme package for R around 20 August
2012 Oct 11
1
as.data.frame.matrix() returns an invalid object
Hi,
Two ways to create what should normally be the same data frame:
> df1 <- data.frame(a=character(0), b=character(0))> df1
[1] a b
<0 rows> (or 0-length row.names)
> df2 <- as.data.frame(matrix(character(0), ncol=2,
dimnames=list(NULL, letters[1:2])))
> df2
[1] a b
<0 rows> (or 0-length row.names)
unique() works as expected except that I
2011 Mar 03
1
Non-conformable arrays
Hi Everyone,
I'm running some simulations where eventually I need to table the results. The problem is, that while most simulations I have at least one predicted outcome for each of the six possible categories, sometimes the algorithm assigns all the outcomes and one category is left out. Thus when I try to add the misclassification matrices I get an error. Is there a simple way I can make
2004 Dec 14
5
sort() leaves row names unaffected
Hello,
I wonder if I ran into a bug. If I do
summary(df1$X1) -> df1.y
df1.y
a b c d e
[1,] 50.74627 8.955224 17.91045 19.40299 2.985075
sort(df1.y)
a b c d e
[1,] 2.985075 8.955224 17.91045 19.40299 50.74627
my numbers are sorted but do not anymore correspond to the rownames.
For me it is counterintuitive that solely the numbers are sorted and not the
names. Is
2011 Aug 18
2
Best way/practice to create a new data frame from two given ones with last column computed from the two data frames?
Dear expeRts,
What is the best approach to create a third data frame from two given ones, when
the new/third data frame has last column computed from the last columns of the two given
data frames?
## Okay, sounds complicated, so here is an example. Assume we have the two data frames:
df1 <- data.frame(Year=rep(2001:2010, each=2), Group=c("Group 1","Group 2"), Value=1:20)
2006 Sep 14
1
R-devel: rownames of a data.frame
Hello!
Data.frames have new rownames funcionality, however in use of colnames<-
in R-devel "changes" this. Here is the example:
> df1 <- data.frame(letters[1:5])
> attributes(df1)
$names
[1] "letters.1.5."
$row.names
[1] 1 2 3 4 5
$class
[1] "data.frame"
> colnames(df1) <- "bla"
> attributes(df1)
$names
[1] "bla"
2009 Sep 16
1
re-code missing value
Dear all,
I have partial data set with four colums. First column is "site" with three
factors (i.e., A, B, and C). From second to fourth columns (v1 ~ v3) are my
observations. In the observations of the data set, "." indicates missing
value. I replaced "." with NA. To replace "." with NA, I used two steps.
First, I replaced "." with NA, and
2009 Feb 10
1
aggregate taking way too long to count.
Folks,
I'm checking the structure of a dataframe for duplicate parameters at a
site station (i.e depth should be measured once, not twice), using
aggregate to count each parameter within a site station. The fake data
below has only 26000 rows, and takes roughly 14 seconds. My real data has
750000 rows and I had to stop execution after about an hour. The by()
function is faster, but I
2017 Jul 13
2
about plotting a special case
Thanks, Jim. The code works, but I don't understand why you use q1090 <-
quantile(DF1$B, probs=c()), rather than DF1$A? Also, how to add a legend
for both points DF1 and DF2?
On Wed, Jul 12, 2017 at 8:25 PM, Jim Lemon <drjimlemon at gmail.com> wrote:
> Hi lily,
> Here is the first plot:
>
> plot(DF1$A,DF1$B,pch=19,col="red")
> meanA<-mean(DF1$A)
>
2012 Jul 11
4
Help with loop
Hi,
I have two dataframes:
The first, df1, contains some missing data:
cola colb colc cold cole
1 NA 5 9 NA 17
2 NA 6 NA 14 NA
3 3 NA 11 15 19
4 4 8 12 NA 20
The second, df2, contains the following:
cola colb colc cold cole
1 1.4 0.8 0.02 1.6 0.6
I'm wanting all missing data in df1$cola to be replaced by the value of
df2$cola.
2011 Nov 30
1
Replace columns in a data.frame randomly splitted
Dear community,
I'm working with the data.frame attached (
http://r.789695.n4.nabble.com/file/n4122926/df1.xls df1.xls ), let's call it
df1.
I typed: df1<- read.xls("C:/... dir .../df1.xls",colNames= TRUE, rowNames=
TRUE)
Then I splited randomly df1 using splitdf function
(http://gettinggeneticsdone.blogspot.com/2011/03/splitting-
dataset-revisited-keeping.html)
2013 Jun 10
1
modify and append new rows to a data.frame using ddply
Hi,
I have a data.frame that contains a variable act which records the duration (in seconds) of two states (wet-dry) for several individuals (identified by Ring) over a period of time. Since I want to work with daytime (i.e. from sunrise till sunset) and night time (i.e. from sunset till next sunrise), I have to split act from time[i] till sunset and from sunset until time[i+1], and from time[k]
2009 Dec 13
1
xtabs - missing combination
Dear list,
I am trying to make a contingency table with xtabs but I am getting
a 0 where I expect a 'NA'. Here is a simple example:
options(stringsAsFactors = FALSE)
rn <- LETTERS[1:4]
df1 <- data.frame(r07 = rep(rn, each=4),
r08 = rep(rn, 4), value = 1:16)
xtabs(value ~ r07 + r08, df1)
# Delete the combination [A, C]
df1 <- df1[-3,]
# Set 'value'
2024 Jun 15
2
code for year month day hr format
Thank you Rui. I ran the following script
df1 <- read.table("solar_hour", header = TRUE)
df1$date <- as.Date(paste(df1$year, df1$hour),
format = "%Y %j",
origin = "2012-08-01-0")
df2 <- df1[c("date", "IMF", "SWS", "SSN", "Dst", "f10")]
head(df1)
#To display all the rows
print(df2).
It gave me this
2005 Jun 29
3
return NA
A<-c(1,2,NA,7,5)
B<-c(3,4,1,4,1)
C<-c(6,5,6,NA,9)
D<-c(8,7,4,6,2)
df1<-cbind(A,B,C,D)
for(i in seq(1,ncol(df1)-1, by=2)) {
ifelse(df1[,i]=="NA",df1[,i+1]=="NA",df1[,] ) }
Tried several variations but none worked. I wish to find any NA's in
column's 1 or 3 and change the numerical value to the right of the "
NA"'s . In this case I