Hi, I have a dataframe with some 800 rows and 14 columns. Could you please advise how I can concatenate the rows - one after another. Similarly for columns, one below the other. Many thanks. Cheers, Santana [[alternative HTML version deleted]]
On May 20, 2010, at 11:05 PM, santana sarma wrote:> Hi, > > I have a dataframe with some 800 rows and 14 columns. > > Could you please advise how I can concatenate the rows - one after > another. > Similarly for columns, one below the other.Not sure exactly what you are after: unlist might accomplish the second task. Whether c(apply(df, 1, I)) would be satisfactory for the first task might depend on whether the columns in the dataframe were all of the same type. Now that I think of it, both soolutions would force the types to be that same. ?"c" ?I ?apply df[1:nrow(df), ] ... would essentially give you the first request, but it would not be any different than just typing df. So .... what do intend this process to accomplish? -- David Winsemius, MD West Hartford, CT
A dummy way is to resequence or rematrix olddata <- data.frame(matrix(rnorm(200), nrow=40)) newdata <- data.frame(matrix(as.vector(t(olddata)), nrow=nrow(olddata)/10)) dim(olddata) dim(newdata) ----- A R learner. -- View this message in context: http://r.789695.n4.nabble.com/Concatenation-tp2225569p2226200.html Sent from the R help mailing list archive at Nabble.com.
Sorry, I made a mistake. Should add "byrow = TRUE". Using randomly created values can't check the result, a sequence will be better. olddata <- data.frame(matrix(1:200, nrow=40, byrow = TRUE)) newdata <- data.frame(matrix(as.vector(t(olddata)), nrow=nrow(olddata)/10,byrow = TRUE)) dim(olddata) dim(newdata) olddata[1:2,] newdata[1:2,] ----- A R learner. -- View this message in context: http://r.789695.n4.nabble.com/Concatenation-tp2225569p2226259.html Sent from the R help mailing list archive at Nabble.com.