Hi,
Provide a list of a list in the second assignment:
--
TunePar <- matrix(list(NULL), 2, 2)
TunePar[2,1] <- list(list(G = 2))
TunePar[2,1]
TunePar[2,1][[1]]$G
TunePar[[2]]$G
---
The point is that "[" returns the list element of the same level as the
original object (TunePar in the present example). So in the assignment
if you extracted one element on the LHS, it expects a one-element vector
on the RHS, e.g., check this out:
---
# this throws an error
TunePar[1,2] <- list(H = 1:3, I = letters[1:2])
# this is fine
TunePar[1,2] <- list(list(H = 1:3, I = letters[1:2]))
TunePar[1,2]
TunePar[1,2][[1]]$I
---
HTH,
Denes
On 01/22/2016 08:29 AM, TJUN KIAT TEO wrote:
TunePar<-matrix(list(Null),2,2)
TunePar[1,1]=list(G=2)
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.