Displaying 20 results from an estimated 10000 matches similar to: "Looking for internal of a function"
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
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
>
2012 Dec 11
1
Rprof causing R to crash
I'm trying to use Rprof() to identify bottlenecks and speed up a particullary
slow section of code which reads in a portion of a tif file and compares
each of the values to values of predictors used for model fitting. I've
written up an example that anyone can run. Generally temp would be a
section of a tif read into a data.frame and used later for other processing.
The first portion
2013 Mar 03
1
Missing PROTECT in mkPRIMSXP ?
The Bioconductor build for a package DirichletMultinomial on
R Under development (unstable) (2013-02-26 r62077) -- "Unsuffered Consequences"
at
http://bioconductor.org/checkResults/devel/bioc-LATEST/DirichletMultinomial/george2-buildsrc.html
shows
* creating vignettes ... ERROR
...
Error: processing vignette ?DirichletMultinomial.Rnw? failed with diagnostics:
chunk 21 (label
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
2008 Mar 07
3
merging environments
Despite the spirited arguments of various R-core folks
who feel that mle() doesn't need a "data" argument, and
that users would be better off learning to deal with function
closures, I am *still* trying to make such things work
in a reasonably smooth fashion ...
Is there a standard idiom for "merging" environments?
i.e., suppose a function has an environment that I want
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
2008 Oct 05
1
plyr package: passing further arguments fail
Dear list and Hadley,
The new plyr package seems to provide a clean and consistent way to apply a function on several arguments. However, I don't understand why the following example does not work like the standard mapply,
library(plyr)
df <- data.frame(a=1:10 , b=1:10)
foo1 <- function(a, b, cc=0, d=0){
a + b + cc + d
}
mdply(df, foo1, cc=1) # fine
mdply(df, foo1, d=1) #
2010 Dec 02
2
Hmisc label function applied to data frame
Hello,
I'm attempting to create a data frame with correlations between every pair
of variables in a data frame, so that I can then sort by the value of the
correlation coefficient and see which pairs of variables are most strongly
correlated.
The sm2vec function in the corpcor library works very nicely as shown here:
library(Hmisc)
library(corpcor)
# Create example data
x1 = runif(50)
x2 =
2013 Jan 04
2
Working with Matrix
Hello again,
Let say I have 2 matrices which equal number of columns but different
number of rows like:
Mat1 <- matrix(1:20, 4, 5)
Mat2 <- matrix(1:25, 5, 5)
Now for each column 1-to-5 I need to fetch the corresponding columns
of these 2 matrices and add the corresponding elements (ignoring NA
values if any). Therefore for the 1st column I need to do:
(1+1), (2+2),...,(4+4), (NA+5)
and
2011 Apr 06
2
A zoo related question
Dear all, please consider my following workbook:
library(zoo)
lis1 <- vector('list', length = 2)
lis2 <- vector('list', length = 2)
lis1[[1]] <- zooreg(rnorm(20), start = as.Date("2010-01-01"), frequency = 1)
lis1[[2]] <- zooreg(rnorm(20), start = as.yearmon("2010-01-01"), frequency =
12)
lis2[[1]] <- matrix(1:40, 20)
lis2[[2]] <-
2006 Jun 29
3
advice on arguments
I have a general style question about R coding.
Suppose I'm writing a function (foo1) that calls other functions
(foo2, foo3, ...) which have complicated argument
lists (e.g. optim(), plot()), _and_
I may be calling several different functions in the body of
foo1. Since foo2 and foo3 have different sets of arguments, I
can't just use "..." ; I did write some code a while ago
2011 Feb 02
2
Help me apply mapply
Hello all I would like to ask your help use mapply.
I have a function called findCell that takes two arguments(x,sr)
where x is a vector of size two (e.g x<-c(2,3) and sr is a matrix.
I would like to call many times the findCell function (thus I need mapply) for different x inputs but always for the same sr.
as x is a vector of size two (two cells) I want to pass inside inside the following
2011 Feb 25
1
speed up process
Dear users,
I have a double for loop that does exactly what I want, but is quite
slow. It is not so much with this simplified example, but IRL it is slow.
Can anyone help me improve it?
The data and code for foo_reg() are available at the end of the email; I
preferred going directly into the problematic part.
Here is the code (I tried to simplify it but I cannot do it too much or
else it
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,
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 Aug 24
1
setMethods/setGeneric problem when R CMD CHECK'ing a package
R-helpers:
I'm trying to build a package, but I'm a bit new to the whole S3/S4
methods concept. I'm trying to add a new definition of the zoo
function "as.yearmon", but I'm getting the following error when it
gets to this point during a package install:
***
R CMD INSTALL STARStools
* installing to library
2011 Jan 21
3
How to look into the asterisked function?
Hi friends, there is methods() function to see the all available methods for
a particular function, for example:
> head(methods("print"))
[1] "print.acf" "print.anova" "print.aov" "print.aovlist"
"print.ar" "print.Arima"
In this list, there are some functions which are asterisked like
print.acf().
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