Re: [R] scan - open text file as list

2015-04-15 Thread Hermann Norpois
Thanks. Actually, I thought there was a way to do it with scan only ... 2015-04-15 16:40 GMT+02:00 William Dunlap : > > strsplit(x=sub(pattern="^\\* ", replacement="", x=test), split=" ") > [[1]] > [1] "a" "b" "d" > > [[2]] > [1] "z" "u" "i" "h" "hh" > > [[3]] > [1] "h" "bh" "kk" > > > Bill

Re: [R] scan - open text file as list

2015-04-15 Thread William Dunlap
> strsplit(x=sub(pattern="^\\* ", replacement="", x=test), split=" ") [[1]] [1] "a" "b" "d" [[2]] [1] "z" "u" "i" "h" "hh" [[3]] [1] "h" "bh" "kk" Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Apr 14, 2015 at 2:34 PM, Hermann Norpois wrote: > Hello, > > I try to open a text file

Re: [R] scan - open text file as list

2015-04-15 Thread Jim Lemon
Hi Hermann, This isn't much more elegant, but test.list<-sapply(test,function(x) { strsplit(x," ") },simplify=TRUE) names(test.list)<-NULL Jim On 4/15/15, Hermann Norpois wrote: > Hello, > > I try to open a text file test.txt with the content > > * a b d > * z u i h hh > * h bh kk > > so that

[R] scan - open text file as list

2015-04-14 Thread Hermann Norpois
Hello, I try to open a text file test.txt with the content * a b d * z u i h hh * h bh kk so that I get a list with each line as a vector with the letters as elements of the the vector. My approach ... test <- scan ("test.txt", what="character", sep="\n") Read 3 items > test.list <- lapply (tes