[R] Container/Collection Object to keep data structures and object

Amir Liu amirkliu88 at hotmail.com
Wed Dec 2 02:53:05 CET 2009




Here is an example of how I attempt to add elements to a given list denoted as l:

> l <- list()
> l
list()
> l[1] <- 5
> l
[[1]]
[1] 5

> l[2] <- "cd"
> l
[[1]]
[1] 5

[[2]]
[1] "cd"

> l[3] <- matrix(1:4,2,2)
Warning message:
In l[3] <- matrix(1:4, 2, 2) :
  number of items to replace is not a multiple of replacement length



----------------------------------------
> Date: Tue, 1 Dec 2009 17:31:41 -0800
> From: chuck at sharpsteen.net
> To: r-help at r-project.org
> Subject: Re: [R] Container/Collection Object to keep data structures and object
>
>
>
> Amir Liu wrote:
>>
>> I want to have a collection object that can store objects. In R I only saw
>> lists. But these only seem to be able to handle basic objects like numbers
>> and strings. Whenever I tried to add more complicated objects or just very
>> simple data structures like matrices I would get an error like:
>>
>> "number of items to replace is not a multiple of replacement length"
>>
>> What is the general purpose collection object in R to store more complex
>> objects, or how are these things generally approached?
>>
>>
>> Kind Regards,
>>
>> Amir
>>
>
> Lists should be capable of holding any arbitrary R object. How are you
> trying to insert components such as a matrix?
> --
> View this message in context: http://n4.nabble.com/Container-Collection-Object-to-keep-data-structures-and-object-tp932656p932666.html
> Sent from the R help mailing list archive at Nabble.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.
 		 	   		  
_________________________________________________________________
Add your Gmail and Yahoo! Mail email accounts into Hotmail - it's easy




More information about the R-help mailing list