[R] Collapsing Arrays/Lists to scalar values

Adaikalavan RAMASAMY ramasamya at gis.a-star.edu.sg
Fri Dec 19 03:36:28 CET 2003


> li <- list(1, 2, 3)
> li
[[1]]
[1] 1

[[2]]
[1] 2

[[3]]
[1] 3

> paste(unlist(li), collapse=" ") 
[1] "1 2 3"

> length( paste(unlist(li), collapse=" ")  )
[1] 1

--
Adaikalavan Ramasamy 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Christopher Brown
Sent: Friday, December 19, 2003 1:25 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Collapsing Arrays/Lists to scalar values




This is probably an easy question.

I want to join the elements of a list/array into a single scalar value.
How can I do this?

More Background:

I have sql queries stored in external flat text files.  When I read
these queries into R using the normal functions, I get a list where each
line is an element in the list.  

When I try to pass this to the appropriate RODBC function, I get an
errror.  The function expects a scalar value for the query text.

Someone must have run into this problem before.  So thanks in advance
for the help.

Chris.

Christopher Brown


---------------------------------


	[[alternative HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list