purrr

Error when using purrr's map and possibly

我是研究僧i 提交于 2021-02-11 00:10:48
问题 I'm trying to run a looped chi-square dataframe . I'm using map and possibly , both from purrr , to allow the loop to run even if an error is thrown. Somewhere in my data.frame, I have a column that apparently has less than two values -- I can't find it. But, that's why I'm trying to run possibly . But, I'm now getting an error that says: Can't convert a list to function. I'm not sure how to reconcile this error. I've gotten a replicable example that throws the error using the mtcars data

Error when using purrr's map and possibly

二次信任 提交于 2021-02-11 00:10:36
问题 I'm trying to run a looped chi-square dataframe . I'm using map and possibly , both from purrr , to allow the loop to run even if an error is thrown. Somewhere in my data.frame, I have a column that apparently has less than two values -- I can't find it. But, that's why I'm trying to run possibly . But, I'm now getting an error that says: Can't convert a list to function. I'm not sure how to reconcile this error. I've gotten a replicable example that throws the error using the mtcars data

Error running weathercan package - fatal SSL/TLS alert (e.g. handshake failed))

萝らか妹 提交于 2021-02-10 17:49:25
问题 I am running the "weathercan" data package (https://cran.r-project.org/web/packages/weathercan/index.html; https://github.com/ropensci/weathercan) and keep getting an error when trying to retrieved data from the Environment and Climate Change historic weather data website. I've re-installed the package, I even reinstalled R and RStudio after deleting everything R from my system, but the error persists. The package works fine when I look up stations up, e.g., stations_search(coords = c(44

R: Use Regex to Import Specific Sheets from Multiple Excel Files

笑着哭i 提交于 2021-02-10 15:57:02
问题 I have a group of Excel files with multiple sheets which don’t follow a standard naming convention. I want to create a single data frame from specific sheets containing the keyword 'frame' . library(tidyverse) library(openxlsx) # Sample Excel File 1 df1 <- data.frame(replicate(10,sample(0:1,10,rep=TRUE))) data_frame2 <- data.frame(replicate(10,sample(0:1,10,rep=TRUE))) list_of_datasets1 <- list("df" = df1, "date_frame" = data_frame2) write.xlsx(list_of_datasets1, file = "writeXLSX1.xlsx") #

Changing and assigning new variable names with purrr::map()

牧云@^-^@ 提交于 2021-02-10 05:06:39
问题 I am just starting to get the hang of writing functions and using lapply / purrr::map() to make my code more concise, but clearly have not understood it completely yet. In my current example, I want to rename coefficient names of lm_robust objects and then change the lm_robust object to incorporate the new names. I currently do this: library(dplyr) library(purrr) library(estimatr) df <- tibble(interest = rnorm(1000), maturity = runif(1000, 1, 12), genderfemale = rbernoulli(1000), y = 0.5

Changing and assigning new variable names with purrr::map()

倾然丶 夕夏残阳落幕 提交于 2021-02-10 05:03:10
问题 I am just starting to get the hang of writing functions and using lapply / purrr::map() to make my code more concise, but clearly have not understood it completely yet. In my current example, I want to rename coefficient names of lm_robust objects and then change the lm_robust object to incorporate the new names. I currently do this: library(dplyr) library(purrr) library(estimatr) df <- tibble(interest = rnorm(1000), maturity = runif(1000, 1, 12), genderfemale = rbernoulli(1000), y = 0.5

Changing and assigning new variable names with purrr::map()

杀马特。学长 韩版系。学妹 提交于 2021-02-10 04:59:49
问题 I am just starting to get the hang of writing functions and using lapply / purrr::map() to make my code more concise, but clearly have not understood it completely yet. In my current example, I want to rename coefficient names of lm_robust objects and then change the lm_robust object to incorporate the new names. I currently do this: library(dplyr) library(purrr) library(estimatr) df <- tibble(interest = rnorm(1000), maturity = runif(1000, 1, 12), genderfemale = rbernoulli(1000), y = 0.5

Changing and assigning new variable names with purrr::map()

北城余情 提交于 2021-02-10 04:58:02
问题 I am just starting to get the hang of writing functions and using lapply / purrr::map() to make my code more concise, but clearly have not understood it completely yet. In my current example, I want to rename coefficient names of lm_robust objects and then change the lm_robust object to incorporate the new names. I currently do this: library(dplyr) library(purrr) library(estimatr) df <- tibble(interest = rnorm(1000), maturity = runif(1000, 1, 12), genderfemale = rbernoulli(1000), y = 0.5

using quosures within formula inside an anonymous function

Deadly 提交于 2021-02-08 19:43:49
问题 I am trying to use quosures to pass along variable names within a custom function for data processing and use in a formula, but my use of quosures in the formula is not correct. Is there a better way to unquote arguments within a formula? library(dplyr) library(broom) library(purrr) library(tidyr) foo <- function(mydata, dv, iv, group_var) { dv = enquo(dv) iv = enquo(iv) group_var = enquo(group_var) mydata <- mydata %>% group_by(!!group_var) %>% nest() mydata %>% mutate(model = map(data,

using quosures within formula inside an anonymous function

自古美人都是妖i 提交于 2021-02-08 19:42:22
问题 I am trying to use quosures to pass along variable names within a custom function for data processing and use in a formula, but my use of quosures in the formula is not correct. Is there a better way to unquote arguments within a formula? library(dplyr) library(broom) library(purrr) library(tidyr) foo <- function(mydata, dv, iv, group_var) { dv = enquo(dv) iv = enquo(iv) group_var = enquo(group_var) mydata <- mydata %>% group_by(!!group_var) %>% nest() mydata %>% mutate(model = map(data,