search for: purrr

Displaying 20 results from an estimated 65 matches for "purrr".

2017 Mar 27
2
A trap for young players with the lapply() function.
...a warning to the help for lapply(), to the effect that if FUN has an > optional argument named "X" then passing this argument via "..." will > cause this argument to be taken as the first argument to lapply() and > thereby induce an error? Another idea might be to use purrr:map instead, which is quite happy with X in your function: > xxx <- purrr::map(y,function(x,X){cos(x*X)},X=2*pi) > xxx [[1]] [1] 0.08419541 [[2]] [1] 0.6346404 [[3]] [1] 0.9800506 [[4]] [1] 0.8686734 [[5]] [1] -0.9220073 But don't feed `.x` to your purrrring cats, or fails sil...
2017 Jun 07
2
purrr::pmap does not work
...;, ylab = "Independent #1" ) -- cut -- It is tedious to repeat the statement for all independent variables. Found an alternative, i.e. : -- cut -- mu <- list(5, 10, -3) sigma <- list(1, 5, 10) n <- list(1, 3, 5) fargs <- list(mean = mu, sd = sigma, n = n) fargs %>% purrr::pmap(rnorm) %>% str() -- cut -- I tried to use this for may scatterplot task: -- cut -- var_battery$v08 <- paste0("v08_", formatC(1:8, width = 2, format = "d", flag = "0")) v08_var_labs <- paste0("Label_", 1:8) dataset <- as.data.frame(...
2017 Feb 15
2
convertir múltiples listas de múltiples dataframes en un único dataframe
Carlos: Agradecido por tu interés. Adjunto la lista que me solicitas. Saludos, Manuel --- _______________________________________________________ El 15/02/2017 17:45, Carlos Ortega escribió: > Hola, > > ¿Puedes pasar parte de estas listas para no picar un ejemplo desde cero... ? > Puedes pasarlo en un fichero ".RData" Y si te da problemas el adjuntarlo a toda la
2017 Mar 27
0
A trap for young players with the lapply() function.
...p for lapply(), to the effect that if FUN has an >> optional argument named "X" then passing this argument via "..." will >> cause this argument to be taken as the first argument to lapply() and >> thereby induce an error? > > Another idea might be to use purrr:map instead, which is quite happy > with X in your function: > > > xxx <- purrr::map(y,function(x,X){cos(x*X)},X=2*pi) > > xxx > [[1]] > [1] 0.08419541 > > [[2]] > [1] 0.6346404 > > [[3]] > [1] 0.9800506 > > [[4]] > [1] 0.8686734 > > [[...
2019 Jan 31
2
Runnable R packages
Would you care to share how your package installs its own dependencies? I assume this is done during the call to `main()`? (Last time I checked, R CMD INSTALL would not install a package's dependencies...) On Thu, Jan 31, 2019 at 4:38 PM Barry Rowlingson < b.rowlingson at lancaster.ac.uk> wrote: > > > On Thu, Jan 31, 2019 at 3:14 PM David Lindelof <lindelof at ieee.org>
2017 Mar 29
1
A trap for young players with the lapply() function.
...he effect that if FUN has an >>> optional argument named "X" then passing this argument via "..." will >>> cause this argument to be taken as the first argument to lapply() and >>> thereby induce an error? >> >> Another idea might be to use purrr:map instead, which is quite happy >> with X in your function: >> >> > xxx <- purrr::map(y,function(x,X){cos(x*X)},X=2*pi) >> > xxx >> [[1]] >> [1] 0.08419541 >> >> [[2]] >> [1] 0.6346404 >> >> [[3]] >> [1] 0.9800506...
2017 Dec 08
1
lmerTest Issues
...lo all, Everything was working very well. Now when I try to load lmerTest using: library("lmerTest"), I get this error: Error: package or namespace load failed for ?lmerTest? in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ?purrr? Nothing I've done has worked. I have uninstalled both R and R studio. I've updated packages as well, but nothing works. Any suggestions? Thanks, Drew [[alternative HTML version deleted]]
2017 Aug 14
2
tidyverse repeating error: "object 'rlang_mut_env_parent' not found"
...for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Desktop> library(tidyverse) Loading tidyverse: ggplot2 Loading tidyverse: tibble Loading tidyverse: tidyr Loading tidyverse: readr Loading tidyverse: purrr Loading tidyverse: dplyr Conflicts with tidy packages -------------------------------------------------------------- filter(): dplyr, stats lag(): dplyr, stats Desktop> library(magrittr) Attaching package: ?magrittr? The following object is masked from ?package:purrr?: set_names The f...
2017 Aug 14
0
tidyverse repeating error: "object 'rlang_mut_env_parent' not found"
...help, or > 'help.start()' for an HTML browser interface to help. > Type 'q()' to quit R. > > Desktop> library(tidyverse) > Loading tidyverse: ggplot2 > Loading tidyverse: tibble > Loading tidyverse: tidyr > Loading tidyverse: readr > Loading tidyverse: purrr > Loading tidyverse: dplyr > Conflicts with tidy packages -------------------------------------------------------------- > filter(): dplyr, stats > lag(): dplyr, stats > Desktop> library(magrittr) > > Attaching package: ?magrittr? > > The following object is maske...
2023 Mar 19
1
WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
...quot; mode. TEASER: Here's an example why using <<- for assigning to the global environment is a bad idea: This works: $ R --vanilla > y <- lapply(1:3, function(x) { if (x > 2) keep <<- x; x^2 }) > keep > [1] 3 This doesn't work: $ R --vanilla > library(purrr) > y <- lapply(1:3, function(x) { if (x > 2) keep <<- x; x^2 }) Error in keep <<- x : cannot change value of locked binding for 'keep' But, if we "declare" the variable first, it works: $ R --vanilla > library(purrr) > keep <- 0 > y <- lapply...
2020 Apr 16
2
suggestion: "." in [lsv]apply()
...d allow you to write: sapply(split(mtcars, mtcars$cyl), F(summary(lm(mpg ~ wt,.))$r.squared)) Such an F() function would apply elsewhere too. /Henrik On Thu, Apr 16, 2020 at 9:30 AM Michael Mahoney <mike.mahoney.218 at gmail.com> wrote: > > This syntax is already implemented in the {purrr} package, more or > less -- you need to add a tilde before your function call for it to > work exactly as written: > > purrr::map_dbl(split(mtcars, mtcars$cyl), ~ summary(lm(wt ~ mpg, .))$r.squared) > > is equivalent to > > sapply(split(mtcars, mtcars$cyl), function(d) summa...
2023 Mar 19
2
WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
...gt; > > > This works: > > > > $ R --vanilla > >> y <- lapply(1:3, function(x) { if (x > 2) keep <<- x; x^2 }) > >> keep > >> [1] 3 > > > > > > This doesn't work: > > > > $ R --vanilla > >> library(purrr) > >> y <- lapply(1:3, function(x) { if (x > 2) keep <<- x; x^2 }) > > Error in keep <<- x : cannot change value of locked binding for 'keep' > > > > > > But, if we "declare" the variable first, it works: > > > > $ R -...
2023 Mar 19
1
WISH: Optional mechanism preventing var <<- value from assigning non-existing variable
...or assigning to the global > environment is a bad idea: > > This works: > > $ R --vanilla >> y <- lapply(1:3, function(x) { if (x > 2) keep <<- x; x^2 }) >> keep >> [1] 3 > > > This doesn't work: > > $ R --vanilla >> library(purrr) >> y <- lapply(1:3, function(x) { if (x > 2) keep <<- x; x^2 }) > Error in keep <<- x : cannot change value of locked binding for 'keep' > > > But, if we "declare" the variable first, it works: > > $ R --vanilla >> library(purrr)...
2017 Nov 22
2
Tibble o data.table?
Buenas Os queria preguntar que ventaja le veis a las tibbles frente a los data.table, ya que para mi, quitando el uso de librerias como tidyr o purrr, en el resto prefiero usar data.table. Me parece igual de potente y mucho más rápido, y no le veo las supuestas ventajas, pero quiero conocer vuestra opinion. Gracias Jesús [[alternative HTML version deleted]]
2017 Jun 08
2
add_model paquete modeval
Estimados compañeros me gustaría saber si alguno ha utilizado la función add_model del paquete modeval cuando la variable de clasificación (y) tiene más de dos niveles. Porque si la utilizo con más niveles siempre me sale el error: Error: length(levels(factor((purrr::as_vector(y))))) == 2 is not TRUE Me parece muy interesante el paquete y no veo donde indica esta limitación. Un cordial saludo, Juan -- Juan Antonio Gil Pascual Profesor de Metodología de la Investigación Cuantitativa correo: jgil en edu.uned.es web: www.uned.es/personal/jgil Dpto. MIDE Facu...
2017 Aug 17
2
How to install Tidyverse on Ubuntu 17.04? Getting gcc errors for -fstack-protector-strong and -Wdate-time
...specified) also installing the dependencies ?colorspace?, ?munsell?, ?plyr?, ?psych?, ?reshape2?, ?bindrcpp?, ?Rcpp?, ?digest?, ?scales?, ?curl?, ?openssl?, ?cellranger?, ?stringi?, ?selectr?, ?tidyselect?, ?broom?, ?dplyr?, ?forcats?, ?ggplot2?, ?haven?, ?httr?, ?jsonlite?, ?lubridate?, ?modelr?, ?purrr?, ?readr?, ?readxl?, ?stringr?, ?tibble?, ?rvest?, ?tidyr?, ?xml2? trying URL 'https://cran.rstudio.com/src/contrib/colorspace_1.3-2.tar.gz' Content type 'application/x-gzip' length 293433 bytes (286 KB) ================================================== downloaded 286 KB trying U...
2017 Apr 11
3
Uso reiterado de la funcion seq
Hola a todos, Escribo debido a una duda en la aplicacion de la funcion seq en cada uno de los "n" componentes de un vector "x". Hasta donde yo se, dicha funcion no permite el uso de vectores. En consecuencia, y como primera aproximacion a lo que deseo hacer, he construido un bucle  que retorne una lista de "n" vectores (de distinta longitud), donde cada uno de estos
2019 Feb 01
0
Runnable R packages
To download a package with all its dependencies and install it, use the install.packages() functions instead of 'R CMD INSTALL'. E.g., in bash: mkdir /tmp/libJunk env R_LIBS_SITE=libJunk R --quiet -e 'if (!requireNamespace("purrr",quietly=TRUE)) install.packages("purrr")' For corporate "production use" you probably want to set up your own repository containing fixed versions of packages instead of using CRAN. Then edd repos="..." to the install.packages() call. Of course you can put...
2019 Jul 21
1
Recommended Reading: Advanced R Second Edition
...al copy of "Advanced R Second Edition", I recommend that: Any community member interested in the development of R reads "Advanced R Second Edition", which explains R Language Core concepts cristal clear, and shows the motivation behind libraries such as "rlang", "purrr", "bench", "profvis", "sloop", "lobstr", above others. I'm sure you will learn something new and enjoy the Reading! Digital Book (Free): https://adv-r.hadley.nz/ Physical Book: https://www.amazon.com/Advanced-Second-Chapman-Hall-CRC/dp/0815384572/...
2024 Feb 29
0
Low level subsetting and S3 subsetting
...s another issue, we don't have `.subset<-` and `.subset2<-` so we have to jump through many hoops to robustly assign to a deep nested element in a classed list containing classed elements. Interestingly, for loops work with low level subsetting, while lapply works with S3 (and, fun fact, purrr::map works with low level subsetting too). This idiom is robust with a consistent class, because lapply uses `as.list()` : x[] <- lapply(x, fun) But these are brittle, we're looping at a low level and assigning with S3 :: x[] <- purrr::map(x, fun) for (i in x) { x[[i]] <- fun(x[[I]]...