similar to: mapply on multiple data frames

Displaying 20 results from an estimated 130 matches similar to: "mapply on multiple data frames"

2013 Jul 24
3
Change values in a dateframe
Hello I have the following problem : The dataframe TEST has multiple lines for a same person because : there are differents values of Nom or differents values of Prenom but the values of Matricule or Sexe or Date.de.naissance are the same. TEST <- structure(list(Matricule = c(66L, 67L, 67L, 68L, 89L, 90L, 90L, 91L, 108L, 108L, 108L), Nom = structure(c(1L, 2L, 2L, 4L, 8L, 5L, 6L, 9L, 3L, 3L,
2013 Sep 22
2
Coding several dummy variables into a single categorical variable
Colleagues, I have generated several dummy variables: n$native0 <- 1 * (n$re=="white" & n$usborn=="yes") n$native1 <- 1 * (n$re=="afam" & n$usborn=="yes") n$native2 <- 1 * (n$re=="carib" & n$usborn=="yes") n$native3 <- 1 * (n$re=="carib" & n$usborn=="no") I would now like to combine these
2013 Jul 12
4
simplify a dataframe
Hello I have the following problem : group the lines of a dataframe when no information change (Matricule, Nom, Sexe, DateNaissance, Contrat, Pays) and when the value of Debut of lines i = value Fin of lines i-1 I can obtain it with a do loop. Is it possible to avoid the loop ? The dataframe initial is df1 dput(df1) structure(list(Matricule = c(1L, 1L, 1L, 6L, 6L, 6L, 6L, 6L, 6L, 8L, 8L, 8L,
2013 Sep 10
3
to delete lines by means of a vector
Hi I would like to eliminate a large number of lines of the dataframe df1 The lines to delete are given here by the values of Mat (ex : 2,4,7,10). but I have a large number (300) values of Mat dput(df1) structure(list(Mat = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 11,
2006 Feb 09
1
List Conversion
Hello, I have a list (mode and class are list) in R that is many elements long and of the form: >length(list) [1] 5778 >list[1:4] $ID1 [1] "num1" $ID2 [1] "num2" "num3" $ID3 [1] "num4" $ID4 [1] NA I'd like to convert the $ID2 value to be in one element rather than in two.?? It shows up as c(\"num2\", \"num3\") if I try to use
2005 Jul 28
1
Unexpected behavior in recode{car}
Thanks to the R creators for such a great statistical system. Thanks to the R help list, I have (finally) gotten far enough in R to have a question I hope to be worth posting. I'm using the recode function from John Fox's car package and have encountered some unexpected behavior. Consider the following example: ## Begin cut-and-paste example require( car ) set.seed(12345) nn <-
2010 Feb 01
1
How to repeat "for" function?
Dear Users, I have one problem here, I tried many time and even read a few notes on writing function but still..... Can anyone help me on how to simplify Part B (please refer the programming below), so that I don't have to repeat the calculation of "num" and "r" ? Thank you very much..every help is very much appreciated... ## Part A n=1400 m=matrix(c(0,0,0,0),4,1)
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
2010 Apr 13
0
Multicore mapply
Quick question regarding multicore versions of mapply. Package 'multicore' provides a parallelized version of 'lapply', called 'mclapply'. I haven't found any parallelized versions of 'mapply', however (although one can use the lower level function 'parallel', it becomes harder to control the number of spawned processes etc). Is anyone aware of a
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 >
2010 Jul 22
0
sweep / mapply question
Dear list, I have a matrix, spc, that should row-wise be interpolated: E.g. spc <- matrix (1:1e6, ncol = 250, nrow = 4000, byrow = TRUE) spc [1:10, 1:10] shifts <- seq_len (nrow (spc)) wl <- seq_len (ncol (spc)) interpolate <- function (spc.row, shift, wl) spline (wl + shift, spc.row, xout = wl, method = "natural")$y interpolate (spc [1,], shift = shifts [1], wl = wl)
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
2008 Oct 21
4
Multi matrix row-wise mapply?
Hi group! Suppose I have 2 matrices A and B of equal dimensions. I want to apply a function f to all corresponding pairs of rows from A and B in an efficient manner. Basically, I want mapply(f, data.frame(A), data.frame(B)) but for rows. How do I do it? Thanks, Andrey
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
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
2012 May 03
2
`mapply(function(x) function() x, c("a", "b"))$a()' returns `"b"'
As the title says, I want to apply a function (which itself returns a function) to a list (or vector), and get a list (or vector) of generated functions as the return value, but get unexpected result. Anyone with an idea about the reason of this phenomenon and a correct way to implement the requirements? Thanks very much :) -- Using GPG/PGP? Please get my current public key (ID: 0xAEF6A134,
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
2009 Dec 14
1
lapply , mapply questions
Dear all, i have a programming problem that should be simple, though i am stuck with it. Please note that this is not a specific geonames problem, though i use it as an example - it´s just a basic problem with lapply. I use the geonames webservices with the R geonames packages which works almost smoothly. I have a vector of Zipcodes and i want to do a geonames lookup for all of them, which
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