Hi, I am trying to create a data frame using the dimensions of another data frame that I have input. This is the code I am using:
tab is the data frame that is input. c.leng<-length(tab[,1]); r.leng<-length(tab[1,]); opdf<-data.frame(ncol=c.leng, nrow=r.leng); a<-1; while(a<=c.leng) { opdf[[1]][a]<-tab[[1]][a]; a<-a+1; } This is the error message I am getting: Error in `[[<-.data.frame`(`*tmp*`, 1, value = c(4626L, 1L)) : replacement has 2 rows, data has 1 I have tried printing out the dimensions of tab and mat separately to see if they are the same, but tab is 4626 rows, 21 columns (which is correct), while mat says 1row and 2columns. Would be grateful if you could tell me where I am going wrong? Is there are better function to transfer/copy values? [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.