First of all, although the question uses the term "list", the object named
'a' is clearly not a list as R defines the term. It is a vector.
Thus a better example answer is
a <- c('abc', 'def')
paste(a , collapse=' ')
and this works for however many elements there are in the vector a.
The ex
A.K.
----- Original Message -----
From: purushothaman
To: r-help@r-project.org
Cc:
Sent: Thursday, July 12, 2012 8:22 AM
Subject: Re: [R] How to get all list item to one string variable
hi,
sorry it's not 2 different list all item in same list like this
a[1]="abc"
a[2]=&quo
t.org
Cc:
Sent: Thursday, July 12, 2012 8:22 AM
Subject: Re: [R] How to get all list item to one string variable
hi,
sorry it's not 2 different list all item in same list like this
a[1]="abc"
a[2]="def"
...
output ="abc def ..."
Thanks
B.Purushothaman
--
V
On Thu, Jul 12, 2012 at 05:22:45AM -0700, purushothaman wrote:
> hi,
>
> sorry it's not 2 different list all item in same list like this
>
> a[1]="abc"
> a[2]="def"
> ...
> output ="abc def ..."
Hi.
Try this
a <- list("abc", "def", "ghi")
paste(a, collapse=" ")
[1] "abc def ghi"
Hope t
Hi,
What you did is equivalent to, but more complicated (and slower as well
I guess) than:
paste(a, collapse="")
Ivan
--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calan...@u-bourgogne.fr
http://biogeo
Try this...
a<-c("abc","def","ghi","klm","nop","qrs","tuv","wxyz")
b<-data.frame()
for (i in 1:length(a)){
b<-paste(b,a[i],sep="")
}
print(b)
Thanks
Arun
---
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-get-all-list-item-to-one-string-variable-tp4636283p4636291.html
S
hi,
sorry it's not 2 different list all item in same list like this
a[1]="abc"
a[2]="def"
...
output ="abc def ..."
Thanks
B.Purushothaman
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-get-all-list-item-to-one-string-variable-tp4636283p4636287.html
Sent from the R help
With paste().
On Thursday, July 12, 2012, purushothaman wrote:
> Hi,
>
> How to get all list item to one string variable.
>
> example
>
> a[1]="abc"
> b[1]="def"
>
> output="abc def"
>
> Thanks
> B.Purushothaman
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/How-to-get-all
Hi,
How to get all list item to one string variable.
example
a[1]="abc"
b[1]="def"
output="abc def"
Thanks
B.Purushothaman
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-get-all-list-item-to-one-string-variable-tp4636283.html
Sent from the R help mailing list archive a
9 matches
Mail list logo