Displaying 20 results from an estimated 10000 matches similar to: "merging environments"
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
2007 Mar 06
2
bug: sticky symbol refs? (PR#9555)
Hello. What happens in the following is that I create two simple functions, f and g, on the workspace. Then I
replace g. When I then call f, it uses the old version of g. Now clearly, the circumstances for this to happen
must be quite special and rare. But I'd say they're not pathological. It seems to require two things: 1) masked versions
of f and g on a search position lower down the
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
>
2011 Sep 02
3
merge some columns
Dear all,
I would like to know how to merge columns like:
Input file:
V1 V2 V3 V4 V5 V6
1 G A G G G G
2 A A G A A G
Desired output file:
V1 V2 V3
1 G/A G/G G/G
2 A/A G/A A/G
So for every 2 consecutive columns merge their content into one.
Thanks in advance.
[[alternative HTML version deleted]]
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
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
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
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
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
2006 May 01
5
Adding elements in an array where I have missing data.
This is a simple question but I cannot seem to find
the answer.
I have two vectors but with missing data and I want to
add them together with
the NA's being ignored.
Clearly I need to get the NA ignored. na.action?
I have done some searching and cannot get na.action to
help.
This must be a common enough issue that the answer is
staring me in the face
but I just don't see it.
Simple
2015 Oct 12
2
identical(..., ignore.environment=TRUE)
It seems odd/inconvenient to me that the "ignore.environment" argument
of identical() only applies to closures (which I read as 'functions' --
someone can enlighten me about the technical differences between
functions and closures if they like -- see below for consequences of my
confusion). This is certainly not a bug, it's clearly documented, but
it seems like a design
2015 Oct 12
2
identical(..., ignore.environment=TRUE)
On 12/10/2015 9:51 AM, Ben Bolker wrote:
> Duncan Murdoch <murdoch.duncan <at> gmail.com> writes:
>
> BB>
>>>> It seems odd/inconvenient to me that the "ignore.environment" argument
>>>> of identical() only applies to closures (which I read as 'functions' --
>>>> someone can enlighten me about the technical differences
2015 Oct 12
2
identical(..., ignore.environment=TRUE)
On 11/10/2015 10:36 PM, Duncan Murdoch wrote:
> On 11/10/2015 8:05 PM, Ben Bolker wrote:
>>
>> It seems odd/inconvenient to me that the "ignore.environment" argument
>> of identical() only applies to closures (which I read as 'functions' --
>> someone can enlighten me about the technical differences between
>> functions and closures if they like
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
2010 Nov 15
3
indexing lists
Hi List,
I'm trying to work out how to use which(), or another function, to find the
top-level index of a list item based on a condition. An example will clarify
my question.
a <- list(c(1,2),c(3,4))
a
[[1]]
[1] 1 2
[[2]]
[1] 3 4
I want to find the top level index of c(1,2), which should return 1 since;
a[[1]]
[1] 1 2
I can't seem to work out the syntax. I've tried;
which(a
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
2015 Oct 13
1
identical(..., ignore.environment=TRUE)
MM> but I don't think we'd want to
MM> change all.equal.language() at this point in time
Although it would be nice if all.equal looked at least at attributes of
formulas
so we did not get results like
> form <- y ~ x1 %in% x2
> all.equal(form, terms(form))
[1] TRUE
> all.equal(terms(y~x1+x2+Error(x3/x2), specials="Error"),
terms(y~x1+x2+Error(x3/x2)))
2011 Feb 23
2
list multiplied by a factor / mapply
Dear list,
this works fine:
x <- split(iris, iris$Species)
x1 <- lapply(x, function(L) transform(L, g = L[,1:4] * 3))
but I would like to multiply each Species with another factor:
setosa by 2, versicolor by 3 and virginica by 4. I've tried mapply but
without success.
Any thoughts? Thanks for any idea!
Patrick
2011 Sep 29
1
Looking for internal of a function
Dear all, when I look at the internal of mapply() function, I see a line of
code:
answer <- .Call("do_mapply", FUN, dots, MoreArgs, environment(),
PACKAGE = "base")
Can somebody please tell me how to find the source code of 'do_mapply'
Thanks,
[[alternative HTML version deleted]]
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 =