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

Petr PIKAL petr.pikal at precheza.cz
Mon Jun 14 12:46:39 CEST 2010


Hi

r-help-bounces at r-project.org napsal dne 14.06.2010 11:05:39:

> 
>    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])

E.g. unlist
barplot(unlist(data[row.id, from.field:to.field]))

Regards
Petr


>    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
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list