Displaying 20 results from an estimated 2000 matches similar to: "skip lapply item for conditions(RAM, execution time)"
2011 Oct 07
1
BitSet equivalent? Java code usable?
Hi all,
I consider writing a R package on statistics for the sorting method as a hobby. I have written a private Java application that I could use as a basis. Therefore I'd like to ask two questions:
1) logical vectors: Bit storage (small) and capable of bit operations?
The Java application relies on BitSet(s) for efficiency reasons. Arrays of logical values cost far too much memory (in the
2011 May 30
3
ideas about how to reduce RAM & improve speed in trying to use lapply(strsplit())
hi all,
I'm full of questions today :). Thanks in advance for your help!
Here's the problem:
x <- c('18x.6','12x.9','302x.3')
I want to get a vector that is c('18x','12x','302x')
This is easily done using this code:
unlist(lapply(strsplit(x,".",fixed=TRUE),function(x) x[1]))
So far so good. The problem is that x is a vector
2008 Nov 01
1
lapply item names
Dear all,
I am using lapply to generate plots by applying a plot function to a list of
dataframes. e.g.
lapply(dataSet, FUN = plotFunction)
Is there a way to call the list item number inside the plot function so that
I can identify each graph?
Thanks
Chibisi
[[alternative HTML version deleted]]
2011 Apr 12
0
lapply over list and the respective name of the list item
Hi all,
I find myself sometimes in the situation where I lapply over a list and
in the particular function I'd like to use the name and or position of
the respective list item. What I usually do is to use mapply on the list
and the names of the list / a position list:
o <- list(A=1:3, B=1:2, C=1)
mapply(function (item, name) paste(name, sum(item), sep="="), o,
names(o))
2009 Mar 22
2
Following progress in a lapply() function
Dear all,
I am processing a very long and complicated list using lapply through a custom function and I would like to generate some sort of progress report. For instance, print a dot on the screen every time 1000 item have been process. Or even better, reporting the percent of the list that have been process every 10%. However, I can't seem to figure out a way to achieve that.
For instance,
2006 Mar 15
2
lapply vs. for (was: Incrementing a counter in lapply)
> From: Thomas Lumley
>>
>> On Tue, 14 Mar 2006, John McHenry wrote:
>>
>> > Thanks, Gabor & Thomas.
>> >
>> > Apologies, but I used an example that obfuscated the question that I
>> > wanted to ask.
>> >
>> > I really wanted to know how to have extra arguments in
>> functions that
>> > would allow,
2007 Jan 07
0
Multiple plots via sapply or lapply?
Hi all,
I've got the following problem. I have a vector containing file names. I
want to read these files as csv and calculate the density-function for
each file (has just one column with data). Then, I'd like to plot all
density functions into one window. I did the following to calculate the
density data:
s <- sapply(filelist, function(x) {
if(file.exists(x))
{
file <-
2003 Feb 11
0
Parallel Processing Interface for lapply()
In co-operation with Markus Hegland and myself, Zhongwen Ding
has written a package, based partly on Markus Hegland's code,
that provides a parallel processing interface to a remote
multi-processsor system. Pyro (Python Remote Objects) and R
must both be installed, both on the client machine and on the remote
server. The system uses rsync, with an ssh protocol, to handle
file transfer.
Once
2004 Oct 18
0
Increasing computiation time per column using lapply
Hi,
Would be very glad for help on this problem. Using this code:
temp<-function(x, bins, tot) {
return(as.numeric(lapply(split(x, bins), wtest, tot)));
}
wtest <- function(x, y) {
return(wilcox.test(x,y)$p.value);
}
rs <- function(x, bins) {
binCount <- length(split(x[,1], bins));
tot <- as.numeric(x);
result<-matrix(apply(x, 2, temp, bins, tot),
2013 Oct 14
0
R Help-Implicit loop-lapply
Hi,The conditions are not very clear.
set.seed(285)
?RN <- sample(1:100,20,replace=FALSE)
aList <- lapply(1:10,function(i) sample(RN,i,replace=FALSE))
?sapply(aList,tail,1)
# [1] 87 60 96 87 60 67 42 96 73 24
A.K.
I was wondering if I could obtain some help on how to do this.
I feel as if I'm supposed to use the vector that i made with sample in order to use this function
2011 Apr 20
1
lapply sequence
Good day,
My question is: Does the lapply function guarantee a particular sequence in
which elements are mapped? And, are we guaranteed that lapply will always be
sequential (i.e. never map elements in parallel) ?
The reason I ask is if I use lapply with the mapping function set to
something that has side-effects that need to be executed in a particular
sequence.
If this is not possible, is
2011 Apr 26
0
Problem with lapply and splitted variables
Dear Community,
I have the following two variables, which I have split according to a
factor:
*y1*
[1]
1
2
3 [2]
2
3
4
and
*y2*
A B [1]
1 4
2 5
3 6 [2]
2 5
3 6
4 7
Now I need the following Vector Autoregressive Models:
VAR(cbind(y1[1],y2[1]$A)), VAR(cbind(y1[1],y2[1]$B)),
VAR(cbind(y1[2],y2[2]$A)), VAR(cbind(y1[2],y2[2]$B)). My problem is that
when using this argument: lapply(y2,
2017 Aug 07
2
Nested cross validation with lapply
Hi all!!
How can i do nested cross validation with lapply??
I know caret package, but I want to do it manuallly using lapply instead for bucle.
Thanks!!
Jes?s
[[alternative HTML version deleted]]
2013 Sep 10
0
Looping an lapply linear regression function
Hi,
Try:
dat2<- read.csv("BOlValues.csv",header=TRUE,sep="\t",row.names=1)
dim(dat2)
#[1] 20 28
indx2<-expand.grid(names(dat2),names(dat2),stringsAsFactors=FALSE)
nrow(indx2)
#[1] 784
indx2New<- indx2[indx2[,1]!=indx2[,2],]
nrow(indx2New)
#[1] 756
res2<-sapply(seq_len(nrow(indx2New)),function(i) {x1<- indx2New[i,];
2002 Mar 19
1
should lapply preserve attributes?
I have an application where I need to preserve object attributes across
calls to 'lapply'. The current definition is:
lapply <- function (X, FUN, ...)
{
FUN <- match.fun(FUN)
if (!is.list(X))
X <- as.list(X)
rval <- .Internal(lapply(X, FUN))
names(rval) <- names(X)
return(rval)
}
Would it make sense to replace
names(rval) <- names(X)
2008 Sep 04
1
lapply(NULL, ...) returns empty list
Dear R-devel,
Is there a reason that lapply(NULL, ...) returns the empty list, rather than NULL? It seems intuitive to expect the latter, and rather counterintuitive that lapply(list(), ... ) returns the same value as lapply(NULL, ...).
> lapply(list(), function(x) 1)
list()
> lapply(NULL, function(x) 1)
list()
> version
_
platform i386-pc-mingw32
arch
2010 Sep 21
2
lapply version with [ subseting - a suggestion
Dear R developers,
Reviewing my code, I have realized that about 80% of the time in the lapply I
need to access the names of the objects inside the loop.
In such cases I iterate over indexes or names:
lapply(names(x), ... [i]),
lapply(seq_along(x), ... x[[i]] ... names(x)[i] ), or
for(i in seq_along(x)) ...
which is rather inconvenient.
How about an argument to lapply which would specify the
2013 Oct 21
0
lapply(ts(1:2), length) inconsistent answers
Hello, All:
I'm getting different answers from "lapply(ts(1:2), length)",
depending on what is attached, with nothing obviously masked.
1. Am I correct that the answer to "lapply(ts(1:2),
length)" should be a list of length 2 consisting of "int 1" twice? This
is what I get from R 3.0.2 with nothing else attached. If I've attached
2015 Feb 23
0
iterated lapply
On 23/02/2015 3:57 PM, Daniel Kaschek wrote:
> Hi everybody,
>
> with the following code I generate a list of functions. Each function
> reflects a "condition". When I evaluate this list of functions by
> another lapply/sapply, I get an unexpected result: all values coincide.
> However, when I uncomment the print(), it works as expected. Is this a
> bug or a
2015 Feb 25
0
iterated lapply
Actually, it depends on the number of cores:
> fun1 <- function(c){function(i){c*i}}
> fun2 <- function(f) f(2)
> sapply(mclapply(1:4, fun1, mc.cores=1L), fun2)
[1] 8 8 8 8
> sapply(mclapply(1:4, fun1, mc.cores=2L), fun2)
[1] 6 8 6 8
> sapply(mclapply(1:4, fun1, mc.cores=4L), fun2)
[1] 2 4 6 8
> >/ On Feb 24, 2015, at 10:50 AM,