Re: [R] Loop over a split string

From: Paul Hiemstra <paul.hiemstra_at_knmi.nl>
Date: Wed, 11 May 2011 09:30:24 +0000

 Hi Joel,

This looks so much like homework I would give studens that I'm not surprised Uwe jumped to conclusions...

ontopic:
You did not specify your earlier attempts, just that they failed. This makes it hard for us to judge what went wrong. Using strsplit I would do:

string<-"a b c d e f"

# The important bit is the subset ([[1]])
# strsplit can work on a vector of strings
# so just splitting on string requires this step
splitted <- strsplit(string, ' ')[[1]]
for(entry in splitted) print(entry)

cheers,
Paul

On 05/11/2011 09:22 AM, Joel wrote:
> This is no homework, Im just trying to learn R but sorry for wasting your
> time you all mighty God of R Uwe Ligges.
>
> And if this is not a forum to ask simple questions can you please redirect
> me to where I might get help?
>
> //Joel
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Loop-over-a-split-string-tp3514204p3514225.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_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.

-- 
Paul Hiemstra, MSc
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

______________________________________________
R-help_at_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.
Received on Wed 11 May 2011 - 09:33:22 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 11 May 2011 - 11:00:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive