[R] How to transfer variable names to column names?
Kelly.Vining at oregonstate.edu
Tue Sep 20 20:23:59 CEST 2011
Hello R users,
I have a set of data frames for which I am tallying row numbers, as shown below.
I want to create a new data frame which has the variable names as column headings, and then a single row with the nrow tallies. My first step was this:
dfIntron <- c(nrow(mC_Explant), nrow(mC_Callus), nrow(mC_RegenPlant))
Then, to set the column names, I tried this, and got the following error:
colnames(dfIntron) <- c("mC_Explant", "mC_Callus", "mC_RegenPlant")
Error in `colnames<-`(`*tmp*`, value = c("mC_Explant", "mC_Callus", "mC_RegenPlant" :
attempt to set colnames on object with less than two dimensions
Even my first step seems wildly inefficient, and obviously doesn't work. There must be a simple way to do this, but I can't use table(), for example, as there are multiple data frames.
Any help will be appreciated.
More information about the R-help