[R] How to convert data frame row to vector?

Jörg Meyer joerg.meyer at jogisoft.de
Mon Jun 14 11:05:39 CEST 2010


   Hi,
   I have a data frame that looks like this:

   ID
   Var
   Var2
   Var3
   xxx
   100
   909
   920
   yyy
   110
   720
   710
   zzz
   140
   680
   690

   I can load the file and produce a plot from values from one column.
   > data <- read.csv("test.csv")
   > barplot(data$Var2)
   So far it's fine.
   The data frame however has more columns with integer values in reality and I
   want to plot from consecutive values of the SAME ROW.
   Something like:
   > barplot(data[1, 2:3])
   or more generic:
   > barplot(data[row.id, from.field:to.field])
   Unfortunately this no longer is a vector! I understand that it could contain
   non-numeric values which in my data frame is not the case.
   How can I convert a "horizontal" one-line-data-frame into a vector?
   Any help appreciated,
   best regards,
   Jörg


More information about the R-help mailing list