Thanks for all the replies!  

I think I posted a poor example, but now I understand that you can name entries 
in a list.  That is really neat.  

Before I was just letting them default, which is kind of problematic. 

I think I also came across another way and also used the suggestion from Bert 
Gunter - thanks again: 

> example_list<-list(tracking<-c("house"), house_type<-c("brick", "wood"), 
> sizes<-c(1600, 1800, 2000, 2400))
> example_list
[[1]]
[1] "house"

[[2]]
[1] "brick" "wood" 

[[3]]
[1] 1600 1800 2000 2400

> 
> cost_limits<-c(200000.25, 350010.15)
> 
> example_list[[4]]<-cost_limits
> 
> example_list
[[1]]
[1] "house"

[[2]]
[1] "brick" "wood" 

[[3]]
[1] 1600 1800 2000 2400

[[4]]
[1] 200000.2 350010.2



> c(example_list,list(CostStuff=cost_limits))
[[1]]
[1] "house"

[[2]]
[1] "brick" "wood" 

[[3]]
[1] 1600 1800 2000 2400

[[4]]
[1] 200000.2 350010.2

$CostStuff
[1] 200000.2 350010.2





----- Original Message ----
From: Bert Gunter <gunter.ber...@gene.com>
To: Jason Rupert <jasonkrup...@yahoo.com>; R-help@r-project.org
Sent: Thu, February 18, 2010 5:37:09 PM
Subject: RE: [R] Appending Data to A n Existing List...

?c 

but you have to make sure z is a list:

c(pts,z) ## probably is not what you want

c(pts,list(z)) ## probably is, but z will be unnamed

c(pts,list(z=z) ## names z "z"


Cheers,

Bert Gunter
Genentech Nonclinical Biostatistics



-----Original Message-----
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Jason Rupert
Sent: Thursday, February 18, 2010 3:16 PM
To: R-help@r-project.org
Subject: [R] Appending Data to A n Existing List...

What steps can be take to append data to a list? 

Suppose I have the following list and want to append a z axist to the list?

pts <- list(x=cars[,1], y=cars[,2])

z<-rnorm(max(dim(cars)))

How would I go about appending z to an existing list? 

Thanks a ton...

______________________________________________
R-help@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.

______________________________________________
R-help@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.

Reply via email to