tidyverse

Error in bind_rows_(x, .id) : Argument 1 must have names

本秂侑毒 提交于 2020-05-12 11:34:09
问题 Here is a code snippet: y <- purrr::map(1:2, ~ c(a=.x)) test1 <- dplyr::bind_rows(y) test2 <- do.call(dplyr::bind_rows, y) The first call to bind_rows ( test1 ) generates the error Error in bind_rows_(x, .id) : Argument 1 must have names Using do.call to invoke bind_rows ( test2 ), on the other hand, works as expected: test2 # A tibble: 2 x 1 a <int> 1 1 2 2 Why? This is using dplyr 0.7.6 and purrr 0.2.5. If I use map_df instead of map , it fails with the same error. Note: It doesn't appear

Use broom and tidyverse to run regressions on different dependent variables

筅森魡賤 提交于 2020-05-11 04:43:00
问题 I'm looking for a Tidyverse / broom solution that can solve this puzzle: Let's say I have different DVs and a specific set of IVS and I want to perform a regression that considers every DV and this specific set of IVs. I know I can use something like for i in or apply family, but I really want to run that using tidyverse . The following code works as an example ds <- data.frame(income = rnorm(100, mean=1000,sd=200), happiness = rnorm(100, mean = 6, sd=1), health = rnorm(100, mean=20, sd = 3),

Use broom and tidyverse to run regressions on different dependent variables

吃可爱长大的小学妹 提交于 2020-05-11 04:41:44
问题 I'm looking for a Tidyverse / broom solution that can solve this puzzle: Let's say I have different DVs and a specific set of IVS and I want to perform a regression that considers every DV and this specific set of IVs. I know I can use something like for i in or apply family, but I really want to run that using tidyverse . The following code works as an example ds <- data.frame(income = rnorm(100, mean=1000,sd=200), happiness = rnorm(100, mean = 6, sd=1), health = rnorm(100, mean=20, sd = 3),

How to pivoting dataframe consisting column with section and sub section In R

我是研究僧i 提交于 2020-05-10 04:11:17
问题 I have a below-mentioned dataframe: structure( list(ID = c("P-1", " P-1", "P-1", "P-2", "P-3", "P-4", "P-5", "P-6", "P-7", "P-8"), Date = c("2020-03-16 12:11:33", "2020-03-16 13:16:04", "2020-03-16 06:13:55", "2020-03-16 10:03:43", "2020-03-16 12:37:09", "2020-03-16 06:40:24", "2020-03-16 09:46:45", "2020-03-16 12:07:44", "2020-03-16 14:09:51", "2020-03-16 09:19:23"), Status = c("SA", "SA", "SA", "RE", "RE", "RE", "RE", "XA", "XA", "XA"), Flag = c("L", "L", "L", NA, "K", "J", NA, NA, "H", "G"

How to pivoting dataframe consisting column with section and sub section In R

放肆的年华 提交于 2020-05-10 04:10:08
问题 I have a below-mentioned dataframe: structure( list(ID = c("P-1", " P-1", "P-1", "P-2", "P-3", "P-4", "P-5", "P-6", "P-7", "P-8"), Date = c("2020-03-16 12:11:33", "2020-03-16 13:16:04", "2020-03-16 06:13:55", "2020-03-16 10:03:43", "2020-03-16 12:37:09", "2020-03-16 06:40:24", "2020-03-16 09:46:45", "2020-03-16 12:07:44", "2020-03-16 14:09:51", "2020-03-16 09:19:23"), Status = c("SA", "SA", "SA", "RE", "RE", "RE", "RE", "XA", "XA", "XA"), Flag = c("L", "L", "L", NA, "K", "J", NA, NA, "H", "G"

Select rows with common ids in grouped data frame

大兔子大兔子 提交于 2020-05-08 18:53:11
问题 I am searching for a simpler solution to the following problem. Here is my setup: test <- tibble::tribble( ~group_name, ~id_name, ~varA, ~varB, "groupA", "id_1", 1, "a", "groupA", "id_2", 4, "f", "groupA", "id_3", 5, "g", "groupA", "id_4", 6, "x", "groupA", "id_4", 6, "h", "groupB", "id_1", 2, "s", "groupB", "id_2", 13, "y", "groupB", "id_4", 14, "t", "groupC", "id_1", 3, "d", "groupC", "id_2", 7, "j", "groupC", "id_3", 8, "k", "groupC", "id_4", 9, "l", "groupC", "id_5", 0, "o", "groupC", "id

R Find the Distance between Two US Zipcode columns

谁说我不能喝 提交于 2020-04-30 07:24:26
问题 I was wondering what the most efficient method of calculating the distance in miles between two US zipcode columns would be using R. I have heard of the geosphere package for computing the difference between zipcodes but do not fully understand it and was wondering if there were alternative methods as well. For example say I have a data frame that looks like this. ZIP_START ZIP_END 95051 98053 94534 94128 60193 60666 94591 73344 94128 94128 94015 73344 94553 94128 10994 7105 95008 94128 I

Reorganize data frame elements depending on the content of the rows in R

孤街浪徒 提交于 2020-04-17 22:00:58
问题 I have this dataset: df <- structure(list(V1 = c("B1D01", "B1D01", "B1D01", "B1D01", "B1D01", "B1D01", "U0155"), V2 = c("U0155", "U0155", "U0155", "U0155", "U0155", "U0155", "U3003"), V3 = c("U3003", "U3003", "C1B00", "U3003", "U3003", "U3003", "C1B00"), V4 = c("C1B00", "C1B00", "U0073", "C1B00", "C1B00", "C1B00", "P037D"), V5 = c("P037D", "P037D", NA, "P037D", "P037D", "P037D", "P0616"), V6 = c("P0616", "P0616", NA, "P0616", "P0616", "P0616", "P0562"), V7 = c("P0562", "P0562", NA, "P0562",

Reorganize data frame elements depending on the content of the rows in R

你说的曾经没有我的故事 提交于 2020-04-17 22:00:17
问题 I have this dataset: df <- structure(list(V1 = c("B1D01", "B1D01", "B1D01", "B1D01", "B1D01", "B1D01", "U0155"), V2 = c("U0155", "U0155", "U0155", "U0155", "U0155", "U0155", "U3003"), V3 = c("U3003", "U3003", "C1B00", "U3003", "U3003", "U3003", "C1B00"), V4 = c("C1B00", "C1B00", "U0073", "C1B00", "C1B00", "C1B00", "P037D"), V5 = c("P037D", "P037D", NA, "P037D", "P037D", "P037D", "P0616"), V6 = c("P0616", "P0616", NA, "P0616", "P0616", "P0616", "P0562"), V7 = c("P0562", "P0562", NA, "P0562",

Reorganize data frame elements depending on the content of the rows in R

橙三吉。 提交于 2020-04-17 21:59:45
问题 I have this dataset: df <- structure(list(V1 = c("B1D01", "B1D01", "B1D01", "B1D01", "B1D01", "B1D01", "U0155"), V2 = c("U0155", "U0155", "U0155", "U0155", "U0155", "U0155", "U3003"), V3 = c("U3003", "U3003", "C1B00", "U3003", "U3003", "U3003", "C1B00"), V4 = c("C1B00", "C1B00", "U0073", "C1B00", "C1B00", "C1B00", "P037D"), V5 = c("P037D", "P037D", NA, "P037D", "P037D", "P037D", "P0616"), V6 = c("P0616", "P0616", NA, "P0616", "P0616", "P0616", "P0562"), V7 = c("P0562", "P0562", NA, "P0562",