Re: [R] extract data from a column

2011-06-19 Thread Nanami
I figured it out:


x<-sub("^.*:([[:digit:]]+)..([[:digit:]]+).*", "\\1 \\2", CTSS$V4)

--
View this message in context: 
http://r.789695.n4.nabble.com/extract-data-from-a-column-tp3609890p3610147.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] extract data from a column

2011-06-19 Thread Nanami
So if I am given some data that look like this:

> head(CTSS)
V1 V2 V3V4   V5 V6  V7   
1 chr1 564563 564598 chr1:564588..564589,+ 1336  
2 chr1 564620 564649 chr1:564644..564645,+   94 
3 chr1 565369 565404 chr1:565371..565372,+  217  
4 chr1 565463 565541 chr1:565480..565481,+ 1214 
5 chr1 565653 565697 chr1:565662..565663,+ 1031  
6 chr1 565861 565922 chr1:565883..565884,+  316 

what I would like to do is to obtain two columns from column V4 like:
start_coord  stop_coord
564588564589
564644564645

I will try and see if it works what you suggested. 
Thank you,
Best,
Nanami




--
View this message in context: 
http://r.789695.n4.nabble.com/extract-data-from-a-column-tp3609890p3610049.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] extract data from a column

2011-06-19 Thread Sam Albers
If I understand what you want (which I may very well not) you could use
something like this:

If this is an example of your type of data:
564589,+

substr(x, 1, 6)
as.numeric(x)

Please try to post something more thorough if you would like a better
answer.

Sam

--
View this message in context: 
http://r.789695.n4.nabble.com/extract-data-from-a-column-tp3609890p3610030.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.