Re: [R] Loop over a split string

From: peter dalgaard <pdalgd_at_gmail.com>
Date: Wed, 11 May 2011 12:48:31 +0200

On May 11, 2011, at 11:35 , Joel wrote:

> Thx
>
> Paul
>
> My string aint that simple its just that if it works for this simple example
> it will work for my string therefor I just used the "a b c d e f" syntax.

> strsplit(string," ")

[[1]]
[1] "a" "b" "c" "d" "e" "f"

> strsplit(string," ")[[1]]
[1] "a" "b" "c" "d" "e" "f"
> for(i in strsplit(string," ")[[1]]) cat(i, "\n")
a
b
c
d
e
f
> cat(strsplit(string," ")[[1]], sep="\n")
a
b
c
d
e
f
>

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes_at_cbs.dk  Priv: PDalgd_at_gmail.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.
Received on Wed 11 May 2011 - 10:55:00 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