Displaying 20 results from an estimated 10000 matches similar to: "holding argument(s) fixed within lapply"
2011 Apr 05
1
Help in splitting a list
Dear R users,
Let's say I have a list with components being 'm' matrices (as exemplified
in the "mylist" object below). Now, I'd like to subset this list based on an
index vector, which will partition each matrix 'm' in 2 sub-matrices. My
questions are:
1. Is there an elegant way to have the results shown in mylist2 for an
arbitrary number of matrices in mylist?
2011 Apr 03
1
Help in splitting ists into sub-lists
Dear List,
Let's say I have a list whose components are 2 matrices (as exemplified in
the "mylist" object below). I'd like to create a list with components being
4 matrices based on an logical index vector. is there a way to simplify what
I'm doing to obtain the results in "mylist2"? I'd like something that would
work on an arbitrary number of elements in
2010 Oct 28
1
Merging nested lists
Hello All,
I have multiple "list of lists" in the form of
Mylist1[[N]][[K]]$Name_i,
with N=1..6, K=1..3, and i=1..7. Each Name_i is a matrix. I have 30 of these objects Mylist1, Mylist2, ...
I would like to merge these lists by each Name_i using rbind, but I couldn't figure out how to do it. What I want at the end is a single "list of lists", again in the form of
2010 Sep 09
0
Fast / dependable way to "stack together" data frames from a list
Hi, everybody:
I asked about this in r-help last week and promised
a summary of answers. Special thanks to the folks
that helped me understand do.call and pointed me
toward plyr.
We face this problem all the time. A procedure
generates a list of data frames. How to stack them
together?
The short answer is that the plyr package's rbind.fill
method is probably the fastest method that is not
2010 Aug 26
3
Passing data to aov
Hello Again Gurus and Lurkers:
I?m trying to build a very user-friendly function which does aov without
having the user type in a formula (which would be tedious in this case).
The idea is to take the response from a PCA score matrix, and the factors
from a list. A simple example is the function given below, along with test
data and a sample call to the function.
I'm certainly having
2010 Feb 19
4
Accessing values of a matrix
hello all,
thank you for taking the time
I have a matrix A that have column names (let say n columns), I want to
reduce the matrix to have just a few of those column (p colums, this is
trivial), but for the lines I want only the lines such that A(i,J) is part
of a list (J is fixed and known)
I am sure it is very easy but I don't find it (I tryed which but it doesn't
seem to work)
Surely
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 <-
2011 Nov 08
3
lapply to list of variables
Hi
Can someone help me with this?
How can I apply a function to a list of variables.
something like this
listvar=list("Monday","Tuesday","Wednesday")
func=function(x){x[which(x<=10)]=NA}
lapply(listvar, func)
were
Monday=[213,56,345,33,34,678,444]
Tuesday=[213,56,345,33,34,678,444]
...
in my case I have a neverending list of vectors.
Thanks!
2010 Sep 26
4
Problem with unlist
Hello I want to unlist the attached element getting only the first element
in each element of the list. The last element of the list looks as this:
[[5065]]
[[5065]]$Pluv3Meses
[1] 274.4
[[5065]]$PluvMesesMedio
[1] 378.2667
[[5065]]$Pluv2UltimosMeses
[1] 23.33333
So I would like to get for each element of the list the element called
Pluv3Meses. The whole list has 5065 elements but when I try to
2006 Mar 30
3
access list component names with lapply
I have a question regarding accessing the names of list
components when applying a function with lapply.
Here is an example that demonstrates what I'd like to do.
I have a list like this one:
mylist <- list(a=letters[1:10], b=letters[10:1], c=letters[1:3])
Now I would like to append the names of the list components to their
corresponding vectors with the c() function. I thought this
2004 Feb 11
6
lapply and dynamically linked functions
Hi all,
I'm trying to use lapply on a list with the following command:
out<-lapply(mylist,myfun,par1=p,par2=d) (1)
where
myfun<-function(x,par1,par1) {.....} (2)
now this function is in fact a wrapper for some Fortran code I have
written so I think this might be the problem. When I call lapply() as in
(1) I get the following message:
Error in get(x,
2010 Mar 08
1
lapply and list indexing basics
I have split my original dataframe to generate a list of dataframes each of
which has 3 columns of factors and a 4th column of numeric data.
I would like to use lapply to apply the fitdistr() function to only the 4th
column (x$isi) of the dataframes in the list.
Is there a way to do this or am I misusing lapply?
As a second solution I tried splitting only the numeric data column to yield
a list
2012 Jan 12
2
defmacro installation issue
Hi everybody,
I want to use macro in my R code. But defmacro was not in my libraries. So I
installed it :
> install.packages("gtools")
Installing package(s) into ?C:/Program Files/R/R-2.13.2/library?
(as ?lib? is unspecified)
essai de l'URL
'http://cran.cict.fr/bin/windows/contrib/2.13/gtools_2.6.2.zip'
Content type 'application/zip' length 102500 bytes (100 Kb)
2012 Nov 09
5
using lapply with recode
Hello:
Forgive me, this is surely a simple question but I can't figure it out, having consulted the help archives and "Data Manipulation With R" (Spector).
I have a list of 11 data frames with one common variable in each (prov). I'd like to use lapply to go through and recode one particular level of that common variable.
I can get the recode to work, but it only returns the
2017 Sep 28
1
[PATCH net-next RFC 2/5] vhost: introduce helper to prefetch desc index
On Fri, Sep 22, 2017 at 4:02 AM, Jason Wang <jasowang at redhat.com> wrote:
> This patch introduces vhost_prefetch_desc_indices() which could batch
> descriptor indices fetching and used ring updating. This intends to
> reduce the cache misses of indices fetching and updating and reduce
> cache line bounce when virtqueue is almost full. copy_to_user() was
> used in order to
2017 Sep 28
1
[PATCH net-next RFC 2/5] vhost: introduce helper to prefetch desc index
On Fri, Sep 22, 2017 at 4:02 AM, Jason Wang <jasowang at redhat.com> wrote:
> This patch introduces vhost_prefetch_desc_indices() which could batch
> descriptor indices fetching and used ring updating. This intends to
> reduce the cache misses of indices fetching and updating and reduce
> cache line bounce when virtqueue is almost full. copy_to_user() was
> used in order to
2018 Mar 13
4
Possible Improvement to sapply
While working with sapply, the documentation states that the simplify argument will yield a vector, matrix etc "when possible". I was curious how the code actually defined "as possible" and see this within the function
if (!identical(simplify, FALSE) && length(answer))
This seems superfluous to me, in particular this part:
!identical(simplify, FALSE)
The preceding
2004 Feb 26
3
my own function given to lapply
Hi
It seems, I just miss something. I defined
treshold <- function(pred) {
if (pred < 0.5) pred <- 0 else pred <- 1
return(pred)
}
and want to use apply it on a vector
sapply(mylist[,,3],threshold)
but I get:
Error in match.fun(FUN) : Object "threshold" not found
thanks for help
cheers
chris
--
Christoph Lehmann <christoph.lehmann at gmx.ch>
2008 May 22
1
How to account for autoregressive terms?
Hi,
how to estimate a the following model in R:
y(t)=beta0+beta1*x1(t)+beta2*x2(t)+...+beta5*x5(t)+beta6*y(t-1)+beta7*y(t-2)+beta8*y(t-3)
1) using "lm" :
dates <- as.Date(data.df[,1])
selection<-which(dates>=as.Date("1986-1-1") & dates<=as.Date("2007-12-31"))
dep <- ts(data.df[selection,c("dep")])
indep.ret1
2017 Sep 26
2
[PATCH net-next RFC 2/5] vhost: introduce helper to prefetch desc index
On Fri, Sep 22, 2017 at 04:02:32PM +0800, Jason Wang wrote:
> This patch introduces vhost_prefetch_desc_indices() which could batch
> descriptor indices fetching and used ring updating. This intends to
> reduce the cache misses of indices fetching and updating and reduce
> cache line bounce when virtqueue is almost full. copy_to_user() was
> used in order to benefit from modern cpus