You can let lapply() do the preallocation and the looping for you with
ASL <- lapply(1:5, function(j) lapply(1:5, function(i) i^j))
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Feb 16, 2015 at 9:46 AM, Jeff Newmiller
wrote:
> You have two named objects when your goal is to have one
Thanks to Jim, Peter and Jeff who all saw the solution!
Best wishes
Troels
Den 16-02-2015 kl. 18:46 skrev Jeff Newmiller:
You have two named objects when your goal is to have one that contains five
others.
ASL <- vector( "list", 5 )
for (j in 1:5){
ASL[[j]] <- vector( "list", 5 )
for (i
You have two named objects when your goal is to have one that contains five
others.
ASL <- vector( "list", 5 )
for (j in 1:5){
ASL[[j]] <- vector( "list", 5 )
for (i in 1:5) {
ASL[[j]][[i]] <- i^j
}
}
---
Jeff New
On 16 Feb 2015, at 17:43 , Troels Ring wrote:
> Dear friends - this is simple I know but I can figure it out without your
> help.
> I have for each of 2195 instances 10 variables measured at specific times
> from 6 to several hundred, so if I just take one of the instances, I can make
> a lis
Is this what you mean:
ASL <- list()
for (j in 1:5){
RES <- list()
for (i in 1:5) RES[[i]] <- i ^ j # create list
ASL[[j]] <- RES # store 'list of list'
}
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want t
Dear friends - this is simple I know but I can figure it out without
your help.
I have for each of 2195 instances 10 variables measured at specific
times from 6 to several hundred, so if I just take one of the instances,
I can make a list of the 10 variables together with their variable
times.
On Jan 31, 2011, at 8:45 PM, Gundala Viswanath wrote:
Dear sirs,
I have a data that is generated like this:
dat1 <- data.frame(V1 = rep(1, 5), V2 = sample(c(40:45), 5))
dat2 <- data.frame(V1 = sample(c(0,1), 5, replace = TRUE), V2 =
sample(c(40:45), 5, replace = TRUE))
What I want to do
Dear sirs,
I have a data that is generated like this:
> dat1 <- data.frame(V1 = rep(1, 5), V2 = sample(c(40:45), 5))
> dat2 <- data.frame(V1 = sample(c(0,1), 5, replace = TRUE), V2 =
> sample(c(40:45), 5, replace = TRUE))
What I want to do is to obtain a data frame that contain list of list.
>
?unlist
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Rajasekaramya
Sent: Friday, November 21, 2008 2:14 PM
To: r-help@r-project.org
Subject: [R] list of list objects
hi there,
I have a list of list objects i need to remove the top layer
[[1]]
[1
?unlist
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Rajasekaramya
Sent: Friday, November 21, 2008 2:14 PM
To: r-help@r-project.org
Subject: [R] list of list objects
hi there,
I have a list of list objects i need to remove the top layer
[[1]]
[1
Will one of these two solutions work for you:
> x <- list(list(1,2), list(3,4), list(5,6))
> x
[[1]]
[[1]][[1]]
[1] 1
[[1]][[2]]
[1] 2
[[2]]
[[2]][[1]]
[1] 3
[[2]][[2]]
[1] 4
[[3]]
[[3]][[1]]
[1] 5
[[3]][[2]]
[1] 6
>
> lapply(x, "[[", 1)
[[1]]
[1] 1
[[2]]
[1] 3
[[3]]
[1] 5
> lapply(x,
hi there,
I have a list of list objects i need to remove the top layer
[[1]]
[1].0
"ABC" "DEF""LMN"
[1].1
"WER" "ERT" "TRY"
[[2]]
[2].0
"ASD","wer""qwe"
[2].1
"wdv""ghj""ggj"
I wanna avoid the top layer...that is [[1]] [[2]] shouldnt be there
just a simple list is wat i need.
[1].0
"ABC" "DEF"
12 matches
Mail list logo