Displaying 20 results from an estimated 6000 matches similar to: "mapply error with Math (S4 group generic)"
2010 Aug 26
1
Passing arguments between S4 methods fails within a function:bug? example with raster package.
Dear all,
This problem came up initially while debugging a function, but it
seems to be a more general problem of R. I hope I'm wrong, but I can't
find another explanation. Let me illustrate with the raster package.
For an object "RasterLayer" (which inherits from Raster), there is a
method xyValues defined with the signature
2018 Nov 03
1
odd NOTE in R CMD check of data; Rcpp module related
With the current version of the "raster" package (that I maintain), R CMD
check on packages "soilDB" and "PopGenReport" have this NOTE:
Package: soilDB
Check: data for non-ASCII characters
New result: NOTE
Error in .requirePackage(package) :
unable to find required package 'raster'
Calls: <Anonymous> ... .findInheritedMethods ->
2008 Mar 23
1
mapply
In an earlier post, a person wanted to divide each of the rows of
rawdata by the row vector sens so he did below but didn't like it and
asked if there was a better solution.
rawdata <- data.frame(rbind(c(1,2,2), c(4,5,6))) sens <- c(2,4,6)
temp <- t(rawdata)/sens
temp <- t(temp)
print(temp)
Gabor sent three other solutions and I understood 2 of them but not the
2012 Nov 15
1
bug with mapply() on an S4 object
Hi,
Starting with ordinary vectors, so we know what to expect:
> mapply(function(x, y) {x * y}, 101:106, rep(1:3, 2))
[1] 101 204 309 104 210 318
> mapply(function(x, y) {x * y}, 101:106, 1:3)
[1] 101 204 309 104 210 318
Now with an S4 object:
setClass("A", representation(aa="integer"))
a <- new("A", aa=101:106)
> length(a)
2012 Oct 29
3
How can I map numbers to colours with raster?
This code will read binary file and display it as a map. may problem is that
this code is using a continuous colour scheme, even though I have discrete
data (which is a classification scheme). How can I map numbers to colours
with raster? Please
require(raster)
conne <- file("C:\\lai.bin", "rb")
sd<- readBin(conne, integer(), size=1, n=360*720, signed=F)
2006 Aug 31
2
Wish: keep names in mapply() result
Hello!
I have noticed that mapply() drops names in R 2.3.1 as well as in
r-devel. Here is a simple example:
l <- list(a=1, b=2)
k <- list(1)
mapply(FUN="+", l, k)
[1] 2 3
mapply(FUN="+", l, k, SIMPLIFY=FALSE)
[[1]]
[1] 2
[[2]]
[1] 3
Help page does not indicate that this should happen. Argument USE.NAMES
does not have any effect here as it used only in a bit special
2011 Jul 31
1
Trouble Using mapply
Dear all,
I am having a problem with mapply. I guess the reason is that mapply is not "vectorized". But could you please take a look at my code below and help me to find a solution (either a better way to use mapply or a different function to call). Thanks a lot!
##beginning of my code
myfun <- function(threshold, all.data) {
##Just a demostration of a function that takes a
2012 Mar 12
2
mapply & assign to generate functions
Hi,
I have a problem that I'm finding a bit tricky. I'm trying to use
mapply and assign to generate curried functions. For example, if I
have the function divide
divide <- function(x, y) {
x / y
}
And I want the end result to be functionally equivalent to:
half <- function(x) divide(x, 2)
third <- function(x) divide(x, 3)
quarter <- function(x) divide(x, 4)
But I want
2005 Nov 20
1
mapply() gives seg fault (PR#8332)
--KsGdsel6WgEHnImy
Content-Type: text/plain; charset=iso-8859-1; format=flowed
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
Hi, people. Wandering in R archives, and seeing the message attached
below, I noticed that:
mapply(rep,times=1:4, MoreArgs=42)
still segfaults on R 2.2.0, and thought I should be a good citizen and
report it, even if I do not have an actual problem
2003 Oct 14
3
mapply() gives seg fault
Hello everybody.
I've been experimenting with mapply(). Does anyone else have problems with:
R> mapply(rep,times=1:4, MoreArgs=42)
(I get a seg fault).
robin
R> R.version
_
platform powerpc-apple-darwin6.6
arch powerpc
os darwin6.6
system powerpc, darwin6.6
status beta
major 1
minor 8.0
year 2003
month 10
day 02
language R
>
2009 Oct 14
1
using mapply to avoid loops
Hello, I would like to use mapply to avoid using a loop but for some reason, I can't seem to get it to work. I've included copies of my code below. The first set of code uses a loop (and it works fine), and the second set of code attempts to use mapply but I get a "subscript out of bounds" error. Any guidance would be greatly appreciated. Xj, Yj, and Wj are also lists, and s2,
2007 Nov 08
2
mapply, coxph, and model formula
Hello -
I am wanting to create some Cox PH models with coxph (in package
survival) using different datasets.
The code below illustrates my current approach and problem with
completing this.
### BEGIN R SAMPLE CODE ##############################
library(survival)
#Define a function to make test data
makeTestDF <- function(n) {
times <- sample(1:200, n, replace = TRUE)
event
2006 Mar 14
1
R CMD check: problems possibly from mapply?
Dear expeRts,
I am trying to wrap up a package "utilities" (for my internal use). After
adding a function datNAtreat that uses mapply, R CMD check gives WARNINGs
for "S3 generic/method consistency", "checking replacement functions"
and?"checking foreign function calls", all of which are accompanied by the
following error message:
Error in .try_quietly
2013 Dec 06
2
Using assign with mapply
I have a data frame whose first colum contains the names of the variables
and whose second colum contains the values to assign to them:
: kkk <- data.frame(vars=c("var1", "var2", "var3"),
vals=c(10, 20, 30), stringsAsFactors=F)
If I do
: assign(kkk$vars[1], kkk$vals[1])
it works
: var1
[1] 10
However, if I try with mapply
2013 Jun 11
1
mapply on multiple data frames
Hi all-
I am wondering about using the mapply function to multiple data frames. Specifically, I would like to do a t-test on a subset of multiple data frames. All data frames have the same structure.
Here is my code so far:
f<-function(x,y) {
test<-t.test(x$col1[x$col3=="num",],v$col2[x$col3=="num",],paired=T,alternative="greater")
out<-test$p.value
2011 Feb 03
1
mapply question (?)
Hi,
I have a function myFun which I want to call multiple times, using different
argument lists.
myFun("v1", "2009", 1)
myFun("v2", "2008", 1)
myFun("q", "2001")
How can I easily do this in R? Should I use mapply?
I unsuccessfully tried something like:
x <- list(c("v1", "2009", 1), c("v2",
2012 Oct 30
1
mapply instead for loop
Hi all!
My question in about using mapply instead for loop. Below is a example with for loop: Is it posible to give same results with mapply function?
Thanks for help!
OV
x <- 1:10
y <- 1:10
xyz <- data.frame(expand.grid(x,y)[1], expand.grid(x,y)[2], z = rnorm(100))
names(xyz) <- c("x", "y", "z")
head(xyz)
size <- 2
output <- NULL
### for
2006 Jul 20
2
Timing benefits of mapply() vs. for loop was: Wrap a loop inside a function
List:
Thank you for the replies to my post yesterday. Gabor and Phil also gave
useful replies on how to improve the function by relying on mapply
rather than the explicit for loop. In general, I try and use the family
of apply functions rather than the looping constructs such as for, while
etc as a matter of practice.
However, it seems the mapply function in this case is slower (in terms
of CPU
2011 Nov 14
1
mapply then export
To use the gauss.quad function: gauss.quad(n,type) which returns two lists
$nodes and $weights whose length will each equal n. I'd like to do this for
n=1 to 40 (type will not change) and have a dataset with 40 rows and 81
columns with all the nodes and weights. The first record would have N1 and
W1 only and N2--N40 and W2--W40 would be missing. The last record would be
full. I've
2004 Apr 08
1
Why are Split and Tapply so slow with named vectors, why is a for loop faster than mapply
First, here's the problem I'm working on so you understand the context. I
have a data frame of travel activity characteristics with 70,000+ records.
These activities are identified by unique chain numbers. (Activities are
part of trip chains.) There are 17,500 chains.
I use the chain numbers as factors to split various data fields into lists
of chain characteristics with each element of