What you have now is a list with one element which happens to be a
character vector. Try:
> vec <- scan(textConnection(myline))
Read 5 items
> vec
[1] 0.100000 1.500000 0.600000 538.000000 0.369404
--
David Winsemius
On Apr 11, 2009, at 8:23 PM, Juliet Hannah wrote:
Hi,
I have a line such as:
myline <- " 0.100000 1.5000 0.6000 538
0.369404"
and I would like to put the numbers into a vector. Some combination of
tabs and spaces occur between the numbers.
I tried:
try1 <- strsplit(myline,"[[:blank:]]+")
try1
[[1]]
[1] "" "0.100000" "1.5000" "0.6000" "538" "0.369404"
The first element is "", which I do not want. I can get rid of the
"", but I was wondering if someone can show me the proper way to do
this in 1 line.
Thanks,
Juliet
______________________________________________
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.
David Winsemius, MD
Heritage Laboratories
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.