Skip to content

Rearranging columns with cbind

2 messages · vin691, Cliff Clive

#
I'm getting an error that I don't understand when trying to rearrange my data
columns with cbind. My data is in 27 columns, like so:
[1] "MF_not_mC"          "MF_promoter"        "MF_genebody"       
"FF_not_mC"         
 [5] "FF_promoter"        "FF_genebody"        "Leaf_not_mC"       
"Leaf_promoter"     
 [9] "Leaf_genebody"      "Root_not_mC"        "Root_promoter"     
"Root_genebody"     
[13] "Xylem_not_mC"       "Xylem_promoter"     "Xylem_genebody"    
"Phloem_not_mC"     
[17] "Phloem_promoter"    "Phloem_genebody"    "Fallbud_not_mC"    
"Fallbud_promoter"  
[21] "Fallbud_genebody"   "Winterbud_not_mC"   "Winterbud_promoter"
"Winterbud_genebody"
[25] "Springbud_not_mC"   "Springbud_promoter" "Springbud_genebody"
 
When I do this operation, I get the following "unused arguments" command:
Error in `[.data.frame`(data, 19:27, 1:12, 13:15, 16:18) : 
  unused argument(s) (16:18)

Can anyone tell me why I'm getting this? When I apply the same command to
different combinations of columns, or to 16:18 by itself, there is no
problem.

--
View this message in context: http://r.789695.n4.nabble.com/Rearranging-columns-with-cbind-tp3466767p3466767.html
Sent from the R help mailing list archive at Nabble.com.
#
It's just a typo.
You're missing a comma at the beginning of your index, and you should list
all of the rows in a vector, like this:

data[, c(19:27, 1:12, 13:15, 16:18)]

The way you entered it, R is looking for rows 19:27, columns 1:12, and
doesn't know what to do with the other numbers.

--
View this message in context: http://r.789695.n4.nabble.com/Rearranging-columns-with-cbind-tp3466767p3466804.html
Sent from the R help mailing list archive at Nabble.com.