tat.math.ethz.ch
Subject: RE: [R] Indexing Lists and Partial Matching
This came up a few months ago. Check the thread on hashing and partial
matching around Nov 18. The short answer is no, you can't turn it off
because lots of code relies on that behavior.
Reid Huntsinger
-Original Me
lf Of McGehee, Robert
Sent: Thursday, January 27, 2005 9:34 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Indexing Lists and Partial Matching
I was unaware until recently that partial matching was used to index
data frames and lists. This is now causing a great deal of problems in
my code as I some
This has been discussed a few times on this list before, so you might want
to dig into the archive...
You might want to check existence of name instead of checking whether the
component is NULL:
> x <- list(bc="bc", ab="ab")
> is.null(x$b)
[1] FALSE
> "b" %in% names(x)
[1] FALSE
Andy
> From: M
I was unaware until recently that partial matching was used to index
data frames and lists. This is now causing a great deal of problems in
my code as I sometimes index a list without knowing what elements it
contains, expecting a NULL if the column does not exist. However, if
partial matching is u
-- Original Message -
From: Perez Martin, Agustin <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 16, 2004 1:33 PM
Subject: [R] Indexing lists
> DeaR useRs:
>
> I have a list with 500 elements, in each other there are data.frames and I
> want to take
m <- matrix(1:9, nc=3)
a <- list(m, m+10, m+100, m+1000)
sapply(a, function(mat) mat[1,1])
[1]1 11 101 1001
On Thu, 2004-09-16 at 12:33, Perez Martin, Agustin wrote:
> DeaR useRs:
>
> I have a list with 500 elements, in each other there are data.frames and I
> want to take the first row
Perez Martin, Agustin umh.es> writes:
: I have a list with 500 elements, in each other there are data.frames and I
: want to take the first row and the first column of each elements of my list
: since the first to the 500-th.
Here are some variations depending on what you want. Also try
all t
On Sep 16, 2004, at 7:57 AM, Peter Dalgaard wrote:
Sean Davis <[EMAIL PROTECTED]> writes:
Maybe not the best solution, but something like:
lapply(mylist,function(x)
{return(list(FirstCol=mylist[,1],FirstRow=mylist[1,]))})
ITYM list(FirstCol=x[,1],FirstRow=x[1,])
Uh, Duh!
Thanks. Some help I am...
Sean Davis <[EMAIL PROTECTED]> writes:
> Maybe not the best solution, but something like:
>
> lapply(mylist,function(x)
> {return(list(FirstCol=mylist[,1],FirstRow=mylist[1,]))})
ITYM list(FirstCol=x[,1],FirstRow=x[1,])
--
O__ Peter Dalgaard Blegdamsvej 3
c/ /'_ ---
"Perez Martin, Agustin" <[EMAIL PROTECTED]> writes:
> DeaR useRs:
>
> I have a list with 500 elements, in each other there are data.frames and I
> want to take the first row and the first column of each elements of my list
> since the first to the 500-th.
>
> Thanks and excuse my bad English.
Maybe not the best solution, but something like:
lapply(mylist,function(x)
{return(list(FirstCol=mylist[,1],FirstRow=mylist[1,]))})
In any case, look at ?lapply
Sean
On Sep 16, 2004, at 7:33 AM, Perez Martin, Agustin wrote:
DeaR useRs:
I have a list with 500 elements, in each other there are data
DeaR useRs:
I have a list with 500 elements, in each other there are data.frames and I
want to take the first row and the first column of each elements of my list
since the first to the 500-th.
Thanks and excuse my bad English.
---
[[alternative HTML version deleted]]
__
12 matches
Mail list logo