Skip to content

Simple question

6 messages · Steven Wolf, David Winsemius, Rolf Turner +3 more

#
On Apr 19, 2011, at 3:19 PM, Steven Wolf wrote:

            
It produces a list. To return an unlist-ed version, what else?
 > unlist(list)
[1] "1" "1" "2" "3" "5" "8"

And to make it a numeric vector ... also simple:
 > as.numeric(unlist(list))
[1] 1 1 2 3 5 8
 > vec <- as.numeric(unlist(list))
 > vec == c(1,1,2,3,5,8)
[1] TRUE TRUE TRUE TRUE TRUE TRUE
 > all.equal(vec , c(1,1,2,3,5,8) ) # better practice with numeric  
values
[1] TRUE
 > identical(vec , c(1,1,2,3,5,8) )
  # will not be true in all situations where newbs think it will be
[1] TRUE
#
On 20/04/11 07:19, Steven Wolf wrote:
<SNIP>

It sounds to me like you don't understand lists.  If you are going to use
R you really should understand them.  They are a wonderfully useful
concept and make doing many otherwise complex tasks an absolute
breeze.  Learn to love lists.  It will be rewarding! :-)

     cheers,

         Rolf Turner
#
On Apr 19, 2011, at 4:08 PM, Rolf Turner wrote:

            
Fortunes candidate....  :-)

Cheers,

Marc Schwartz
#
On Apr 19, 2011, at 21:56 , David Winsemius wrote:

            
Also, there is the possibility to use scan() on a text connection
Read 6 items
[1] 1 1 2 3 5 8

In r-devel, this works too:

  
    
#
Seconded.

Peter Ehlers
On 2011-04-19 14:11, Marc Schwartz wrote:
[...snip...]