You can always add those names to the list: is this what you are after?
> example.names <- c("con1-1-masked-bottom-green.tsv",
"con1-1-masked-bottom-red.tsv"
+ , "con1-1-masked-top-green.tsv","con1-1-masked-top-red.tsv")
> example.list <- strsplit(example.names, "-")
> names(example.l
They aren't being stored, they are being generated on the fly. You can
create the same names using make.names()
example.names <- c("con1-1-masked-bottom-green.tsv",
"con1-1-masked-bottom-red.tsv", "con1-1-masked-top-green.tsv",
"con1-1-masked-top-red.tsv")
example.list <- strsplit(example.names,
On 22/01/2016 2:29 AM, TJUN KIAT TEO wrote:
I am trying to populate an array of lists in R . Here is my code
TunePar<-matrix(list(Null),2,2)
TunePar[1,1]=list(G=2)
But when I type TunePar[1,1,], all I get is 2. The G has disappeared. why?
If I do this
Test=list(G=2)
Test
$G
[1] 2
Matric
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 ex
Hi,
Not sure this is what you wanted.
lstNew <- list(Spans, lapply(lapply(Spans,`[`,1),as.character) )
str(lstNew)
#List of 2
$ :List of 3
..$ : num [1:2] 8.37e+08 8.42e+08
..$ : num [1:2] 8.32e+08 8.37e+08
..$ : num [1:2] 9.30e+08 9.35e+08
$ :List of 3
..$ : chr "8.37e+08"
..$ : chr "8
A matrix may only contain one data type. By not specifying when you
created m, it was filled with logical values of NA.
A logical value can't hold a list.
You can see that with
str(m)
which returns:
> str(m)
logi [1:3, 1:2] NA NA NA NA NA NA
- attr(*, "dimnames")=List of 2
..$ : chr [1:3] "Ro
First, some general suggestions:
To see the structure of an object I would recommend
the str() function or, for a more concise output,
the class() function.
I don't think most ordinary users should be using
is.list() and, especially, is.vector().
Now for the particulars.
dbGetQuery pr
-help@r-project.org Help
Subject: Re: [R] Lists of tables and conditional statements
On Mar 30, 2011, at 7:27 PM, Henrique Dallazuanna wrote:
> Try this:
>
> lapply(l, function(x)x[x[,'Sum'] == 3,])
If this is the right answer, you should send a "solved" message. The
On Mar 30, 2011, at 7:27 PM, Henrique Dallazuanna wrote:
Try this:
lapply(l, function(x)x[x[,'Sum'] == 3,])
If this is the right answer, you should send a "solved" message. The
dput extract was incomplete.
--
David.
On Wed, Mar 30, 2011 at 7:38 PM, Herbert, Alan G
wrote:
Hi R-users
Try this:
lapply(l, function(x)x[x[,'Sum'] == 3,])
On Wed, Mar 30, 2011 at 7:38 PM, Herbert, Alan G wrote:
> Hi R-users,
>
> I have a list containing numeric tables of differing row length. I want to
> make a new list that contains only rows from tables with a "Sum" greater than
> 3, plus the
On Mar 30, 2011, at 5:38 PM, Herbert, Alan G wrote:
Hi R-users,
I have a list containing numeric tables of differing row length. I
want to make a new list that contains only rows from tables with a
"Sum" greater than 3, plus the names of each table. I was wondering
whether there is an el
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 12/08/2010 11:22 AM, jim holtman wrote:
> It sounds like you want to use a "list" instead of a dataframe,
No - I would like to have a data,frame. I am aware of the differences,
but as far as I understand, each column in a data.frame can have a
diff
It sounds like you want to use a "list" instead of a dataframe,
especially if the elements are a different length.
> d <- list() # initialize
> d[[length(d) + 1]] <- list() # extend
> d[[length(d)]]$fun <- sin # add a function
> d[[length(d) + 1]] <- list() # extend again
> d[[length(d)]]$fun
alf Of Peter Langfelder
> Sent: Monday, September 20, 2010 9:52 PM
> To: r-help
> Subject: Re: [R] Lists with NULL entries
>
> Hi Joshua,
>
> thanks, I came up with that solution myself after a bit of thinking.
> Normally I wouldn't worry about NULL components of lists
Hi Joshua,
thanks, I came up with that solution myself after a bit of thinking.
Normally I wouldn't worry about NULL components of lists, but dimnames
is a list and often some components are null and is therefore a bit
tricky to manipulate...
Peter
On Mon, Sep 20, 2010 at 7:39 PM, Joshua Wiley
Sorry, that was a really half-hearted reply. This will create a new
list that is the old list shifted down (and should be much faster than
the for loop too).
lst <- list(NULL,2)
lst2 <- vector("list", length(lst) + 1)
lst2[2:length(lst2)] <- lst
lst
lst2
If you really need to use a for loop, may
Hello Peter,
This is because assigning a value of NULL removes that element of the
list. I am not quite sure what the reference for that is. I remember
reading it in the documentation once though. I looked through ?list
to no avail. At any rate, to avoid it, you would have to assign
something
Tena koe Edward
It is difficult to know the best approach from the information supplied,
but using unlist() at the appropriate place in your code, maybe
unlist(stats[[i]]$means), will probably get you where you want to be.
HTH .
Peter Alspach
> -Original Message-
> From: r-help-bou
On Feb 22, 2010, at 8:27 PM, ewaters wrote:
Related questions to this have been asked before, but I have tried all
options they gave me unsuccessfully (do.call and unlist).
I start with three lists of summary statistics, 100 elements each,
which I
bind together:
None of this represents
How about like this:
for (i in seq_along(a)) {
result <- as.list(a[1:i])
cat("iterator", i, ":\n")
print(result)
}
On Sat, Jul 25, 2009 at 6:48 AM, Alberto Lora M wrote:
> Hi Everybody
>
> I have the following problem
>
> suppose that we
>
> a<-c("uno","dos","tres")
>
> I am working with a
Here is one way:
> a<-c("uno","dos","tres")
> x <- list()
> a<-c("uno","dos","tres")
> x <- list()
> for (i in seq_along(a)){
+ # add to the list
+ x[[i]] <- a[i]
+ str(x)
+ }
List of 1
$ : chr "uno"
List of 2
$ : chr "uno"
$ : chr "dos"
List of 3
$ : chr "uno"
$ : chr "dos"
$ : chr "t
I think this is what you want. You need to look at the help file for
?'[' and ?'[['. Also understand the differences between a data.frame
and a list. in the case of defining qn you need to use a list and not
a data.frame because here is what happens with a data.frame:
> q1 <- data.frame(q=d1, n
22 matches
Mail list logo