Displaying 20 results from an estimated 40000 matches similar to: "debug on lapply"
2012 Dec 13
1
possible bug in function 'mclapply' of package parallel
Dear parallel users and developers,
I might have encountered a bug in the function 'mclapply' of package
'parallel'. I construct a matrix using the same input data and code with a
single difference: Once I use mclapply and the other time lapply.
Shockingly the result is NOT the same.
To evaluate please unpack the attached archive and execute
Rscript mclapply_test.R
I put the
2012 Dec 04
3
How to find matching columns in a matrix of lists?
Dear R users,
I have a matrix composed of lists:
m <- matrix( list(), nrow=1, ncol=3 )
m[[ 1, 1 ]] <- list("A", "B")
m[[ 1, 2 ]] <- list("A", "C")
m[[ 1, 3 ]] <- list("A", "B")
and want to get the sub-matrix where cells contain "B".
But
m[ , "B" %in% m[ 1, ], drop=F ]
as well as
m[ , "B"
2013 Feb 13
2
Is there a place to put executable R scripts in new packages?
Dear R users,
writing an R package I wonder, if there is a place to put executable R
scripts into. So that when the package is installed one can use the
script from the command line.
Say we have e new package called FunkyR and wanted to deliver with it
an executable called FunkyCold.R, so that from the command line, one
could do the following:
Rscript FunkyCold.R argument_1 argument_2
Any
2010 Dec 09
4
lapply getting names of the list
Hello All,
I have a toy dataframe like this. It has 8 columns separated by tab.
Name SampleID Al1 Al2 X Y R Th
rs191191 A1 A B 0.999 0.09 0.78 0.090
abc928291 A1 B J 0.3838 0.3839 0.028 0.888
abcnab A1 H K 0.3939 0.939 0.3939 0.77
rx82922 B1 J K 0.3838 0.393
2013 Apr 02
3
How to do platform independent system calls?
Dear R experts,
I hope everyone has had a happy easter break.
Recently my work included writing R function that need to call external tools.
I did this using R's system function for example:
system( paste( 'tool', '-input', path_to_input, '-output',
path_to_output, '-other_switch', some_val ) )
I have two question about this:
1) Is there a way to implement
2019 Nov 17
2
Inappropriate class(o)[!inherits(o,"AsIs")] in get_all_vars
SVN?revision?77401?changes
????????x[isM]?<-?lapply(x[isM],?function(o)?`class<-`(o,?class(o)[class(o)?!=?"AsIs"]))
to
????????x[isM]?<-?lapply(x[isM],?function(o)?`class<-`(o,?class(o)[!inherits(o,"AsIs")]))
in?function?'get_all_vars'?in?src/library/stats/R/models.R?in?R?devel.
The?change?is?inappropriate.
2019 Nov 18
2
Inappropriate class(o)[!inherits(o,"AsIs")] in get_all_vars
>>>>> Martin Maechler
>>>>> on Mon, 18 Nov 2019 12:15:38 +0100 writes:
>>>>> suharto anggono--- via R-devel
>>>>> on Sun, 17 Nov 2019 10:34:31 +0000 writes:
>> SVN revision 77401 changes
>> x[isM] <- lapply(x[isM], function(o) `class<-`(o, class(o)[class(o) != "AsIs"]))
>> to
2012 Nov 21
1
lists as matrix cells ?
Dear R experts,
since more or less half a year I am using R.
In many of my computations I construct huge matrices. Often I do so using
'cbind' on named lists:
do.call( 'cbind',
list(
"Column_A"=list("Row_one"=1.0, "Row_two"=2.0, "Row_three"=3.0),
"Column_B"=list("Row_one"=4.0, "Row_two"=5.0,
2012 Dec 17
2
Why does matrix selection behave differently when using which?
Dear R community,
I have a medium sized matrix stored in variable "t" and a simple function "
countRows" (see below) to count the number of rows in which a selected
column "C" matches a given value. If I count all rows matching all pairwise
distinct values in the column "C" and sum these counts up, I get the number
or rows of "t". If I delete the
2013 May 24
0
Rcpp with OpenMP - Need example Makevars
Dear R experts,
recently I started developing a Rcpp package "OpenMPTest".
Within that package I want to use OpenMP, as in the following code example:
// header file
#include <omp.h>
using namespace Rcpp ;
RcppExport SEXP testOpenMP( SEXP nThreads ) ;
// cpp file
SEXP testOpenMP( SEXP nThreads ) {
BEGIN_RCPP
NumericVector numberThreads = NumericVector( nThreads );
2003 Dec 22
2
Problems with read.table()
R version 1.8.1, OS Windows 98
Dear colleagues,
if I import vegetation data (first row with column labels and first column
with row labels) like
7MYRGERM;7AGRGIGA;7DRYOCTO;5MYRGERM;7SALELEA;7CHOCHON;7SALNIG?;.......
t401;5;2;2;3;4;2;2;2;1;2;1;2;2;1;2;2;2;1;2;1;0;0;......
t403;3;0;0;6;4;0;3;0;0;3;0;0;0;0;3;0;0;0;2;0;2;0;.....
with read.table("data.file", header=TRUE,
2010 Oct 08
3
Efficiency Question - Nested lapply or nested for loop
My data looks like this:
> data
name G_hat_0_0 G_hat_1_0 G_hat_2_0 G_0 G_hat_0_1 G_hat_1_1 G_hat_2_1 G_1
1 rs0 0.488000 0.448625 0.063375 1 0.480875 0.454500 0.064625 1
2 rs1 0.002375 0.955375 0.042250 1 0.000000 0.062875 0.937125 2
3 rs2 0.050375 0.835875 0.113750 1 0.877250 0.115875 0.006875 0
4 rs3 0.000000 0.074750 0.925250 2 0.897750 0.102000
2014 Mar 27
2
mclapply Segmentation Fault for Ubuntu
Running the example in the documentation causes R to crash.
dario at bioinfo:~$ R
R version 3.0.3 (2014-03-06) -- "Warm Puppy"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or
2014 Jun 23
1
Curious behavior of $ and lapply
There seems to be a funny interaction between lapply and "$" -- also, "$"
doesn't signal an error in some cases where "[[" does.
The $ operator accepts a string second argument in functional form:
> `$`(list(a=3,b=4),"b")
[1] 4
lapply(list(list(a=3,b=4)),function(x) `$`(x,"b"))
[[1]]
[1] 4
... but using an lapply "..."
2018 Sep 19
5
segfault issue with parallel::mclapply and download.file() on Mac OS X
I have an lapply function call that I want to parallelize. Below is a very
simplified version of the code:
url_base <- "https://cloud.r-project.org/src/contrib/"
files <- c("A3_1.0.0.tar.gz", "ABC.RAP_0.9.0.tar.gz")
res <- parallel::mclapply(files, function(s) download.file(paste0(url_base,
s), s))
Instead of download a couple of files in parallel, I get a
2008 Sep 09
2
make methods work in lapply - remove lapply's environment
I've defined my own version of summary.default,
that gives a better summary for highly skewed vectors.
If I call
summary(x)
the method is used.
If I call
summary(data.frame(x))
the method is not used.
I've traced this to lapply; this uses the new method:
lapply(list(x), function(x) summary(x))
and this does not:
lapply(list(x), summary)
If I make a copy of lapply, WITHOUT the
2017 Nov 15
0
lapply and runif issue?
Hi Bert,
On Tue, Nov 14, 2017 at 8:11 PM, Bert Gunter <bgunter.4567 at gmail.com> wrote:
> Could someone please explain the following? I did check bug reports, but
> did not recognize the issue there. I am reluctant to call it a bug, as it
> is much more likely my misunderstanding. Ergo my request for clarification:
>
> ## As expected:
>
>> lapply(1:3, rnorm, n = 3)
2005 Oct 10
2
problem with lapply(x, subset, ...) and variable select argument
I need to extract identically named columns from several data frames in
a list. the column name is a variable (i.e. not known in advance). the
whole thing occurs within a function body. I'd like to use lapply with a
variable 'select' argument.
example:
tt <- function (n) {
x <- list(data.frame(a=1,b=2), data.frame(a=3,b=4))
for (xx in x) print(subset(xx, select = n))
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
2009 Aug 11
1
Passing a list object to lapply
Hello,
I'm having difficulty passing an object name to a lapply function. Can
somebody tell me the trick to make this work?
#Works
T13702 <- TRACKDATA[["13702.xls"]][["data"]]
min(unlist(lapply(list(T13702), function(x) mdy.date(x[1, 2], x[1, 1],
x[1, 3]))))
16553
#Works
d<-2
assign(paste("T",substr(names(TRACKDATA)[d],1,(nchar(names(TRACKDATA)[d]