[R] turning data in list format into a matrix format
Marietta Suarez
marietta0423 at gmail.com
Fri Jul 1 21:53:28 CEST 2016
As of now, I simulate 6 variables and manipulate 2 of them. The way my
syntax is written my final database is in list mode. I need all of it to be
in just 1 database. any help would be MUCH appreciated. Here's my syntax:
fun=function(n, k,rep){
#prepare to store data
data=matrix(0,nrow=10*k, ncol=6)
db=vector("list",length=rep) #here's the problem
for (j in 1:rep){
for (i in 1:k){
#generate data under normal, skewed, and logistic distributions here
data[,1]<-seq(1,nrow(data),1)
data[,2]<-rep(i,nrow(data))
data[,3]<-rep(n,nrow(data))
data[,4]<-rnorm(n, 100, 15)
data[,5]<-rsnorm(n, 100, 15, 1)
data[,6]<-rlogis(n, 100, 15)
}
db[[j]]<-data
}
DataReturn<<-db
return(DataReturn)
#DataReturn <- data.frame(matrix(unlist(DataReturn), nrow=rep,
byrow=T)) #here's
where I tried to solve it unsuccessfully
}
[[alternative HTML version deleted]]
More information about the R-help
mailing list