similar to: merging environments

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
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
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
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
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
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 =
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
2010 Nov 23
3
how to update my own function
Hello all, I wrote a function with many arguments. Then I need to call it many times with changes on some arguments only. Is there any way to write a function or have a method to "update" it, like the relationship between lm() and update()? Many thanks, Edwin Sun ------------ This is the sample code. > test <- function(y, z) { + x <- y +1 + w <- z * 2 + result
2005 Feb 11
3
formatC with illegal input crashes Rgui (PR#7686)
Full_Name: Peter Ehlers Version: rw2001pat (2005-02-03) OS: Win XP Submission from: (NULL) (136.159.61.115) formatC(1, flag="s") crashes Rgui. Similarly for flag=[SnZ]. Stupid input, of course, but I'm error-prone. Peter