[R] converting multiple lines of text to a data frame
Phil Spector
spector at stat.berkeley.edu
Sat Mar 6 05:52:47 CET 2010
Andrew-
Maybe something like this:
> dd = read.table(filename)
> unstack(dd,V2~V1)
A. B. C.
1 1 2 10.0
2 34 20 6.7
3 2 78 35.0
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Fri, 5 Mar 2010, Andrew Yee wrote:
> I'm trying to find a way for converting multiple lines of text into a
> table. I'm not sure if there's a way where you can use read.delim()
> to read in multiple lines of text and create the following data frame
> with something akin to rehape()?. Apologies if there is an obvious
> way to do this.
>
> A: 1
> B: 2
> C: 10
> A: 34
> B: 20
> C: 6.7
> A: 2
> B: 78
> C: 35
>
> Convert the above lines into the following data frame
>
> A B C
> 1 2 10
> 34 20 6.7
> 2 78 35
>
> Thanks,
> Andrew
>
> ______________________________________________
> 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