[R] scanning data into r
David Winsemius
dwinsemius at comcast.net
Wed Mar 28 22:12:12 CEST 2012
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
More information about the R-help
mailing list