On Mar 28, 2012, at 2:23 PM, joel.green wrote:

Hey

I am having trouble importing data into R, my data field looks like this

21  TEST DATA
32  year:2012
33
34
5
36


> read.table(text="21  TEST DATA
+ 32  year:2012
+ 33
+ 34
+ 5
+ 36", fill=TRUE)[1]

  V1
1 21
2 32
3 33
4 34
5  5
6 36

I require the the number at the start of each line however the text is not needed, i am struggling to get R to import the data with out changing the
file itself?

Use , fill =TRUE) and then throw away everything except the first column. Could also use readLines and split on " " and take first element with sapply( ..., "[" , 1)

how do i import the data, i have tried using comment.char=" ", however this
didnt work, any help would be much appreciated thanks


--

David Winsemius, MD
West Hartford, CT

______________________________________________
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.

Reply via email to