Displaying 3 results from an estimated 3 matches for "resultdf".
2010 Sep 09
0
Fast / dependable way to "stack together" data frames from a list
...m(100))
df3 <- data.frame(x=rnorm(100),y=rnorm(100))
df4 <- data.frame(x=rnorm(100),y=rnorm(100))
mylist <- list(df1, df2, df3, df4)
## Here's the way we have done it. We understand this,
## we believe the result, it is easy to remember. It is
## also horribly slow for a long list.
resultDF <- mylist[[1]]
for (i in 2:4) resultDF <- rbind(resultDF, mylist[[i]])
## It works better to just call rbind once, as in:
resultDF2 <- rbind( mylist[[1]],mylist[[2]],mylist[[3]],mylist[[4]])
## That is faster because it calls rbind only once.
## But who wants to do all of that typing...
2010 Sep 04
4
Please explain "do.call" in this context, or critique to "stack this list faster"
...case
df1 <- data.frame(x=rnorm(100),y=rnorm(100))
df2 <- data.frame(x=rnorm(100),y=rnorm(100))
df3 <- data.frame(x=rnorm(100),y=rnorm(100))
df4 <- data.frame(x=rnorm(100),y=rnorm(100))
mylist <- list(df1, df2, df3, df4)
## Usually we have done a stupid
## loop to get this done
resultDF <- mylist[[1]]
for (i in 2:4) resultDF <- rbind(resultDF, mylist[[i]])
## My intuition was that this should work:
## lapply( mylist, rbind )
## but no! It just makes a new list
## This obliterates the columns
## unlist( mylist )
## I got this idea from code in the
## "complete" f...
2011 Mar 18
1
help please: put output into dataframe
...MD1 <- c(medianx + 2*madx)
MD2 <- c(medianx - 2*madx)
out1[i] <- which(getdata[,i] > MD1) # store data that are
greater than median + 2 mad
out2[i] <- which (getdata[,1] < MD2) # store data that are
greater than median - 2 mad
resultdf <- data.frame(out1, out2)
write.table (resultdf, "out.csv", sep=",")
}
My idea here is to store those value which are either greater than median +
2 *MAD or less than median - 2*MAD. Each variable have different length of
output.
The following la...