Displaying 20 results from an estimated 20000 matches similar to: "How can I access the list argument within a "for" function call"
2013 Mar 13
2
holding argument(s) fixed within lapply
|Hello,
Given a function with several arguments, I would like to perform an
lapply (or equivalent) while holding one or more arguments fixed to some
common value, and I would like to do it in as elegant a fashion as
possible, without resorting to wrapping a separate wrapper for the
function if possible. Moreover I would also like it to work in cases
where one or more arguments to the original
2011 Jan 15
3
get list element names within lapply / sapply call
Hi all,
I would like to iterate through a list with named elements and access the
names within an lapply / sapply call. One way to do this is iterate through
the names and index the list with the name. Is there a way to iterate
through the list elements themselves and access the element names within in
the function? For example,
mylist <-
2009 Jul 02
2
Passing expression as argument to do.call
Dear R-users,
I would like to know how expressions could be passed as arguments to
do.call functions. As illustrated in the short example below,
concatenating lists objects and an expression creates an expression
object, which is not an acceptable argument for do.call. Is there a way
to avoid that?
Thanks you
Sebastien
foo <- list(x=1:10, y=1:10)
mylist <- list(pch=6, col=2)
title
2009 Jul 14
2
How to provide list as an argument for the data.frame()
Hi R -users,
i've a table as describe below. I'm reading the numeric value presented in this table to populate a list.
#table
#============
#X A B C
#x1 2 3 4
#x2 5 7 10
#x4 2 3 5
#============
rawData <- read.table("raw_data.txt",header=T, sep="\t")
myList=list()
counter=0
for (i in c(1:length(rawData$X)))
{
print (i)
2004 Apr 14
2
attaching data.frame/list within a function
I'm trying to find a good way of attaching a list within a function such
that the attached variables (the list's members) precede the global
environment (.GlobalEnv) in the search list. Here is a non-working example
using attach(), which hopefully explains better what I'm trying to do:
> foo <- function(x=0, input=list(a=10)) {
+ attach(input)
+ on.exit(detach(input))
+
2003 Apr 09
7
Caller press "0" in Voicemail
I would like to add the ability for our users to be able to press "0" whenever reaching someone's voicemail box to re-reroute them to the auto-attendant.
Here's a sample extensions.conf:
[incoming]
include => ciscophones
exten => s,1,Wait,1
exten => s,2,Answer
exten => s,3,DigitTimeout,5
exten => s,4,ResponseTimeout,15
exten => s,5,BackGround(auto-greeting)
2010 Aug 12
2
accessing tcl variables within R and tcl
Dear R users,
I have some troubles with dealing with tclObj objects. I try to explain
it with a toy example:
Say I define the following tcl procedure which just prints out each list
element
library(tcltk)
.Tcl('proc test {myList} {
foreach i $myList {
puts stdout $i
}
}')
and I call it with:
> tcl('test',letters[1:5]) # Works as expected
Now say I define
2008 Jan 19
1
how to use different variable to store values with different length in a loop
Hi, List
I am trying to use variables named A1, A2, ..., A100 to store some values,
each variable could store some values with different length, how can I
achieve this?
Thanks,
Jack
[[alternative HTML version deleted]]
2011 Nov 30
1
install "multtest" and "preprocessCore" packages in Bioconductor library
Hi Nguyen,
> Subject: [R] install "multtest" and "preprocessCore" packages in
> Bioconductor library
> Date: Wed, 30 Nov 2011 09:57:36 -0800
> From: UyenThao Nguyen <unguyen at tethysbio.com>
> To: r-help <r-help at r-project.org>
> CC: uth.nguyen at ucdavis.edu <uth.nguyen at ucdavis.edu>
>
> Hi All,
>
> I've tried to
2010 Sep 04
4
Please explain "do.call" in this context, or critique to "stack this list faster"
I've been doing some consulting with students who seem to come to R
from SAS. They are usually pre-occupied with do loops and it is tough
to persuade them to trust R lists rather than keeping 100s of named
matrices floating around.
Often it happens that there is a list with lots of matrices or data
frames in it and we need to "stack those together". I thought it
would be a simple
2009 Jul 23
2
alternative to rbind within a loop
Hi,
I often have to do this:
select a folder (directory) containing a few hundred data files in csv
format (up to 1000 files, in fact)
open each file, transform some character variables in date-tiime format
make into a dataframe (involves getting rid of a few variables I don't
need
concatenate to the master dataframe that will eventually contain the
data from all the files in the
2005 Nov 29
1
Indexing variables within lapply?
Hello
I am using R 2.2.0 with Windows XP.
I've got a five element list object, each element containing two
dataframes of equivalent size.
> str(mylist)
List of 1
$ data1:List of 2
..$ data1a :`data.frame': 77 obs. of 63 variables:
.. ..$ var1 : num [1:77] 0.41375 0.00056 1.43040 1.43528 0.61730 ...
.. ..$ var2 : num [1:77] 1.154 1.686 0.673 0.800 0.760 ...
..
2015 May 04
2
Define replacement functions
Hello
I tried to define replacement functions for the class "mylist". When I test them in an active R session, they work -- however, when I put them into a package, they don't. Why and how to fix?
make_my_list <- function( x, y ) {
return(structure(list(x, y, class="mylist")))
}
mylist <- make_my_list(1:4, letters[3:7])
mylist
mylist[['x']] <- 4:6
2017 Jun 15
4
is.null(mylist[1]) and is.null(mylist$a) returns different values
Hi
I have a list :
mylist <- list( a = NULL, b = 1, c = 2 )
> mylist[1]
$a
NULL
> is.null(mylist[1])
[1] FALSE
> is.null(mylist$a)
[1] TRUE
why? I need to use mylist[1]
2009 Oct 25
3
NULL elements in lists ... a nightmare
I can define a list containing NULL elements:
> myList <- list("aaa",NULL,TRUE)
> names(myList) <- c("first","second","third")
> myList
$first
[1] "aaa"
$second
NULL
$third
[1] TRUE
> length(myList)
[1] 3
However, if I assign NULL to any of the list element then such
element is deleted from the list:
> myList$second <-
2010 May 17
3
applying quantile to a list using values of another object as probs
Hi r-users,
I have a matrix B and a list of 3x3 matrices (mylist). I want to
calculate the quantiles in the list using each of the value of B as
probabilities.
The codes I wrote are:
B <- matrix (runif(12, 0, 1), 3, 4)
mylist <- lapply(mylist, function(x) {matrix (rnorm(9), 3, 3)})
for (i in 1:length(B))
{
quant <- lapply (mylist, quantile, probs=B[i])
}
But quant
2005 Mar 16
8
Summing up matrices in a list
Dear all,
I think that my question is very simple but I failed to solve it.
I have a list which elements are matrices like this:
>mylist
[[1]]
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
[[2]]
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 8 10 12
I'd like to create a matrix M<-mylist[[1]]+mylist[[2]]
[,1] [,2] [,3]
[1,] 8 12 16
[2,] 10 14 18
2001 Oct 18
2
Parsing for list components
How do I parse an identifier of a list component, e.g.
mylist$mycomponent
or
mylist[[1]] ?
Parse does not do the job, e.g.
parse(text="mylist$mycomponent")
returns an expression with just one term, instead of "mylist", "$",
"mycomponent".
What I need is a way to extract the list name (e.g. "mylist"), given
an identifier of a component.
2004 May 10
2
Lists and outer() like functionality?
Hi,
I'm have a list of integer vectors and I want to perform an outer()
like operation on the list. As an example, take the following list:
mylist <- list(1:5,3:9,8:12)
A simple example of the kind of thing I want to do is to find the sum
of the shared numbers between each vector to give a result like:
result <- array(c(15,12,0,12,42,17,0,17,50), dim=c(3,3))
Two for() loops is the
2019 Jan 15
2
preallocate working incorrectly in 3.1.3
I believe that the changes to support --preallocate and --sparse together
have broken --preallocate by itself (commit
f3873b3d88b61167b106e7b9227a20147f8f6197)
The previous behavior of --preallocate was to do just that: reserve blocks
in the filesystem WITHOUT setting the size of the file to the final
length. The reported filesize would change as the preallocated blocks were
actually written.