[R] data management

jim holtman jholtman at gmail.com
Sun Jan 18 20:25:01 CET 2009


Does this give you what you want:

> x <- read.table(textConnection("p(1) 10
+ p(1) 3
+ p(1) 4
+ p(2) 20
+ p(2) 30
+ p(2) 40
+ p(3) 4
+ p(3) 1
+ p(1) 2"), as.is=TRUE)
> # remove parenthesis
> x$V1 <- gsub("[()]", "", x$V1)
>
>
> x
  V1 V2
1 p1 10
2 p1  3
3 p1  4
4 p2 20
5 p2 30
6 p2 40
7 p3  4
8 p3  1
9 p1  2
>


On Sun, Jan 18, 2009 at 12:13 PM, oscar linares <winsaam at gmail.com> wrote:
> Dear Rxperts,
>
> I have a varaibles data file that looks like this
>
> p(1) 10
> p(1) 3
> p(1) 4
> p(2) 20
> p(2) 30
> p(2) 40
> p(3) 4
> p(3) 1
> p(1) 2
>
> I cannot process these data with R because it does not like the parentheses.
> How can I get these to look like:
>
> p1 10
> p1 3
> p1 4
> p2 20
> p2 30
> p2 40
> p3 4
> p3 1
> p3 2
>
> The data is in a tab delimited text file and I want to get it into a
> data.frame().
>
> Many thanks in advance.
>
> OAL
> p1
> p1
>
> --
> Oscar
> Oscar A. Linares
> Molecular Medicine Unit
> Bolles Harbor
> Monroe, Michigan
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list