Hi. Have you tried 'help.search('list')' ?
See ?lapply
> lapply(z, function(s) s[2:3,,drop=F])
[[1]]
[,1] [,2]
[1,]25
[2,]36
[[2]]
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 19 22 25 28 31 34
[2,] 20 23 26 29 32 35
Marco Geraci
--- Federico Calboli <[E
On Tue, 2006-02-28 at 17:14 +, Federico Calboli wrote:
> Hi All,
>
> I have a list of matrices:
>
> > x
> [,1] [,2]
> [1,]14
> [2,]25
> [3,]36
> > y
> [,1] [,2] [,3] [,4] [,5] [,6]
> [1,] 18 21 24 27 30 33
> [2,] 19 22 25 28 31 34
> [3
Federico Calboli wrote:
> Hi All,
>
> I have a list of matrices:
>
>
>>x
>
> [,1] [,2]
> [1,]14
> [2,]25
> [3,]36
>
>>y
>
> [,1] [,2] [,3] [,4] [,5] [,6]
> [1,] 18 21 24 27 30 33
> [2,] 19 22 25 28 31 34
> [3,] 20 23 26 29
Try this:
lapply(z, "[", 2:3, TRUE)
On 2/28/06, Federico Calboli <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have a list of matrices:
>
> > x
> [,1] [,2]
> [1,]14
> [2,]25
> [3,]36
> > y
> [,1] [,2] [,3] [,4] [,5] [,6]
> [1,] 18 21 24 27 30 33
> [2,] 1
Hi All,
I have a list of matrices:
> x
[,1] [,2]
[1,]14
[2,]25
[3,]36
> y
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 18 21 24 27 30 33
[2,] 19 22 25 28 31 34
[3,] 20 23 26 29 32 35
> z =list(x,y)
I want to create a second list that is
On Fri, 21 Oct 2005, Martin Maechler wrote:
>> "PaCo" == Patrick Connolly <[EMAIL PROTECTED]>
>> on Fri, 21 Oct 2005 13:26:08 +1300 writes:
>
>PaCo> On Wed, 19-Oct-2005 at 05:09PM +0200, Martin Maechler wrote:
>PaCo> |> Lists can have 'dim' attributes and hence be treated as ar
> "PaCo" == Patrick Connolly <[EMAIL PROTECTED]>
> on Fri, 21 Oct 2005 13:26:08 +1300 writes:
PaCo> On Wed, 19-Oct-2005 at 05:09PM +0200, Martin Maechler wrote:
PaCo> |> Lists can have 'dim' attributes and hence be treated as arrays;
PaCo> |> Note that this is pretty rarely
On Wed, 19-Oct-2005 at 05:09PM +0200, Martin Maechler wrote:
|> Lists can have 'dim' attributes and hence be treated as arrays;
|> Note that this is pretty rarely used and not too well supported
|> by some tools, one could say even 'print()' :
|>
|> > set.seed(0); L0 <- L <- lapply(rpois(12, lam
Le 19 Octobre 2005 11:09, Martin Maechler a écrit :
[...]
> Lists can have 'dim' attributes and hence be treated as arrays;
For me, this is an amazing feature that I discovered almost by accident (I
tried it an it worked)! This creates a sort of three-dimensional object ---
much like an array
> "Jose" == José Ernesto Jardim <[EMAIL PROTECTED]>
> on Tue, 18 Oct 2005 15:30:59 +0100 writes:
Jose> Dennis Fisher wrote:
>> Colleagues,
>>
>> I have created a list in the following manner:
>> TEST<- list(c("A1", "A2"), c("B1", "B2"), c("C1", "C2"))
>>
Dennis
Try
> TEST[-3]
[[1]]
[1] "A1" "A2"
[[2]]
[1] "B1" "B2"
for removing more than one element from the list (say 2 & 3) --
> TEST[-c(2,3)]
[[1]]
[1] "A1" "A2"
HTH
John
Dennis Fisher wrote---
Colleagues,
I have created a list in the following manner:
TEST<- list(c("A1",
Hi, you can use this:
TEST[[3]]<-NULL
> TEST
[[1]]
[1] "A1" "A2"
[[2]]
[1] "B1" "B2"
Saludos
Jaime Arturo Coral
student PUCP - PERU
On 10/18/05, Dennis Fisher <[EMAIL PROTECTED]> wrote:
>
> Colleagues,
>
> I have created a list in the following manner:
> TEST <- list(c("A1", "A2"), c("B1",
tholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
- Original Message -
From: "Dennis Fisher" <[EMAIL PROTECTED]&
Dennis Fisher wrote:
>Colleagues,
>
>I have created a list in the following manner:
> TEST<- list(c("A1", "A2"), c("B1", "B2"), c("C1", "C2"))
>
>I now want to delete one element from the list, e.g., the third. The
>command
> TEST[[3]]
>yields (as expected):
> [1] "C1" "C2"
>
>T
You have to use "[" instead of "[[" to return a sub-list.
Reid Huntsinger
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dennis Fisher
Sent: Tuesday, October 18, 2005 10:12 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Subsetting a l
On 10/18/2005 10:11 AM, Dennis Fisher wrote:
> Colleagues,
>
> I have created a list in the following manner:
> TEST<- list(c("A1", "A2"), c("B1", "B2"), c("C1", "C2"))
>
> I now want to delete one element from the list, e.g., the third. The
> command
> TEST[[3]]
> yields (as exp
Colleagues,
I have created a list in the following manner:
TEST<- list(c("A1", "A2"), c("B1", "B2"), c("C1", "C2"))
I now want to delete one element from the list, e.g., the third. The
command
TEST[[3]]
yields (as expected):
[1] "C1" "C2"
The command
TEST[[-3]]
yields:
0)x^2 else NA, rm=NA )
---
Date: Mon, 10 Nov 2003 00:23:17 -0500 (EST)
From: Gabor Grothendieck <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Subject: Re: [R] Subsetting a list of vectors
Thanks to you all for your helpful solutions. I particularly like the
simplicity of Gabor's na.omit( sapply(... ) ) formulation, but you've
all given me some ideas to think about.
Thanks again,
Hadley
__
[EMAIL PROTECTED] mailing list
https://www.s
Hi,
I propose here a solution that relies on names of elements:
# From a list, with any names
ll=list(v1=1:4,v2=1:2,v3=5:7,v4=9:11,v5=1,v6=rnorm(4))
# Make a copy to be able to change names
ll2=ll
names(ll2)=rep("a",lengh(ll2))
# Use unlist, which "autobuilds" names based on
# previous names and
Dirk and Ray have provided two very clever solutions which
perform transformation and selection in one go
by returning NA and NULL respectively for unwanted elements
and then eliminating the NAs and NULLs.
I thought it would be worthwhile to bring them together and
make some further minor
On Sun, Nov 09, 2003 at 09:29:26PM -0600, Dirk Eddelbuettel wrote:
> On Sun, Nov 09, 2003 at 10:00:42PM -0500, Gabor Grothendieck wrote:
> > There are languages that do allow this. For example, Python
> > has list comprehensions which are things like this:
> >
> ># give me the squares of the
On Sun, Nov 09, 2003 at 10:00:42PM -0500, Gabor Grothendieck wrote:
> There are languages that do allow this. For example, Python
> has list comprehensions which are things like this:
>
># give me the squares of the even numbers from 1-10, in a list.
>>>> [ x*x for x in range(1,11) if x
xpression in the terms we want.)
---
Date: Mon, 10 Nov 2003 13:43:07 +1300
From: Hadley Wickham <[EMAIL PROTECTED]>
To: R-Help Mailing List <[EMAIL PROTECTED]>
Subject: [R] Subsetting a list of vectors
Hi,
I'm trying to subset a list which contains variable length vectors.
When I did it in S-Plus 6.1 and R 1.8.0, I didn't get NULL entries: I
got NAs. There is a difference between NULLs and NAs. The NAs can be
deleted using is.na, as follows:
> list.of.vectors <- list(a=1, b=1:3)
> x3 <- sapply(list.of.vectors, function(x)x[3])
> x3
a b
NA 3
> x3
a b
NA 3
>
Hi,
I'm trying to subset a list which contains variable length vectors.
What I want to do is extract (eg.) the 3rd item in each vector (with
length >= 3). At the moment I'm using sapply(list.of.vectors,
function(x) {x[3]}). The problem with this is that sapply returns a
list of the same len
26 matches
Mail list logo