On Mar 14, 2011, at 16:32 , Allan Engelhardt wrote:
> You could try
>
> scan(what=character(0), sep=",", file=textConnection("first,second,third"))
>
>
> but better to put the strings in a file (say, strings.txt), one per line, and
> read it using
>
> scan("strings.txt", what=character(0), sep="\n")
Also, things like this come in handy at times:
## From dept. of slightly dirty trix:
txt <- "fmffmfmfmfmfmmmmfmmmffmff"
lizards$sex <- factor(unlist(strsplit(txt,"")),levels=c("m","f"))
It is easily generalized to include a delimiter.
--
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: [email protected] Priv: [email protected]
______________________________________________
[email protected] 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.