Hi all,
I have a column that has the following format:
chr1:564588..564589,+ and I want to extract only the coordinates; I have
tried writing a regular expression but I couldn't figure out how I should
write it. Does anyone know?
Thank you,
Best,
Nanami
[[alternative HTML version
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:
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
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.
4 matches
Mail list logo