Related
4galaxy7: i have df df = data.frame(
group = c(rep("A", 3), rep("B", 3)),
vt = c("SO:0001574", "SO:0001619", "SO:0001619", "SO:0001619", "SO:0001619", "SO:0001821")
)
and two vectors: tier_1 = c("SO:0001574", "SO:0001575")
tier_2 = c("SO:0001821"
4galaxy7: i have df df = data.frame(
group = c(rep("A", 3), rep("B", 3)),
vt = c("SO:0001574", "SO:0001619", "SO:0001619", "SO:0001619", "SO:0001619", "SO:0001821")
)
and two vectors: tier_1 = c("SO:0001574", "SO:0001575")
tier_2 = c("SO:0001821"
tics Following the example given in the dplyr::case_when()documentation : x <- 1:50
case_when(x %% 35 == 0 ~ "fizz buzz",
x %% 5 == 0 ~ "fizz",
x %% 7 == 0 ~ "buzz",
TRUE ~ as.character(x))
I expected this number 35to produce, "b
James DeWeese I'm trying to convert mutate_at() to mutate() using dplyr's new "cross" function and am having some difficulty. In short, I need to compare the values in a range of columns to a "baseline" column. I need to use the baseline value when the value i
tics Following the example given in the dplyr::case_when()documentation : x <- 1:50
case_when(x %% 35 == 0 ~ "fizz buzz",
x %% 5 == 0 ~ "fizz",
x %% 7 == 0 ~ "buzz",
TRUE ~ as.character(x))
I expected this number 35to produce, "b
James DeWeese I'm trying to convert mutate_at() to mutate() using dplyr's new "cross" function and am having some difficulty. In short, I need to compare the values in a range of columns to a "baseline" column. I need to use the baseline value when the value i
James DeWeese I'm trying to convert mutate_at() to mutate() using dplyr's new "cross" function and am having some difficulty. In short, I need to compare the values in a range of columns to a "baseline" column. I need to use the baseline value when the value i
tics Following the example given in the dplyr::case_when()documentation : x <- 1:50
case_when(x %% 35 == 0 ~ "fizz buzz",
x %% 5 == 0 ~ "fizz",
x %% 7 == 0 ~ "buzz",
TRUE ~ as.character(x))
I expected this number 35to produce, "b
tics Following the example given in the dplyr::case_when()documentation : x <- 1:50
case_when(x %% 35 == 0 ~ "fizz buzz",
x %% 5 == 0 ~ "fizz",
x %% 7 == 0 ~ "buzz",
TRUE ~ as.character(x))
I expected this number 35to produce, "b
James DeWeese I'm trying to convert mutate_at() to mutate() using dplyr's new "cross" function and am having some difficulty. In short, I need to compare the values in a range of columns to a "baseline" column. I need to use the baseline value when the value i
James DeWeese I'm trying to convert mutate_at() to mutate() using dplyr's new "cross" function and am having some difficulty. In short, I need to compare the values in a range of columns to a "baseline" column. I need to use the baseline value when the value i
Lou Mills I can't figure this out. Suppose I want to create a condition variable that returns a hit whenever any row in the dataframe has a column containing the target. It's always easier to illustrate with an example. This is toy data set.seed(10)
d <- data.
Anthony W I have two dataframes: df1 <- data.frame(A = c(1, 2, 3), B = c(0,0,3), C = c(3,2,1))
df2 <- data.frame(A = c(0, 2, 4), B = c(1,0,3), C = c(0,1,4))
I would like to generate a third dataframe by comparing entries between equivalent named columns by a
Anthony W I have two dataframes: df1 <- data.frame(A = c(1, 2, 3), B = c(0,0,3), C = c(3,2,1))
df2 <- data.frame(A = c(0, 2, 4), B = c(1,0,3), C = c(0,1,4))
I would like to generate a third dataframe by comparing entries between equivalent named columns by a
Anthony W I have two dataframes: df1 <- data.frame(A = c(1, 2, 3), B = c(0,0,3), C = c(3,2,1))
df2 <- data.frame(A = c(0, 2, 4), B = c(1,0,3), C = c(0,1,4))
I would like to generate a third dataframe by comparing entries between equivalent named columns by a
Anthony W I have two dataframes: df1 <- data.frame(A = c(1, 2, 3), B = c(0,0,3), C = c(3,2,1))
df2 <- data.frame(A = c(0, 2, 4), B = c(1,0,3), C = c(0,1,4))
I would like to generate a third dataframe by comparing entries between equivalent named columns by a
Anthony W I have two dataframes: df1 <- data.frame(A = c(1, 2, 3), B = c(0,0,3), C = c(3,2,1))
df2 <- data.frame(A = c(0, 2, 4), B = c(1,0,3), C = c(0,1,4))
I would like to generate a third dataframe by comparing entries between equivalent named columns by a
user3614648: I'm trying to use dplyr::case_wheninside dplyr::mutateto create a new variable where I set some missing values and recode others at the same time. However, if I try to set the value to NA, I get an error saying we can't create the variable newbeca
pgcudahy It's late and I must be making a stupid mistake, but why does this usage case_whenproduce an error? x <- 1:5
dplyr:::case_when(
x == 1 ~ TRUE,
x != 1 ~ print(x))
#> [1] 1 2 3 4 5
#> Error: must be a logical vector, not an integer vector
Ronal
mokhovu I've read the Programming with dplyr documentation and tried to write a simple case_when()function around that . library(dplyr)
data_test <- data.frame(
a = rep(c("a", "b", "c"), each = 5),
b = rnorm(15)
)
fun_test <- function(df, var1, var2)
Simon Want to use dplyr and case_whencollapse a series of indicator columns into one column. The challenge is that I want to be able to collapse an unspecified/dynamic number of columns. Consider the following dataset, which gearhas been divided into a series
Simon Want to use dplyr and case_whencollapse a series of indicator columns into one column. The challenge is that I want to be able to collapse an unspecified/dynamic number of columns. Consider the following dataset, which gearhas been divided into a series
Simon Want to use dplyr and case_whencollapse a series of indicator columns into one column. The challenge is that I want to be able to collapse an unspecified/dynamic number of columns. Consider the following dataset, which gearhas been divided into a series
Ahu Suppose I generate a probability table by country, type and type in each round of research. Also, I need to calculate weights based on the rounds a person has participated in up to that point. Weights are calculated as the sum of all probabilities (p) minu
user3614648: I'm trying to use dplyr::case_wheninside dplyr::mutateto create a new variable where I set some missing values and recode others at the same time. However, if I try to set the value to NA, I get an error saying we can't create the variable newbeca
Aitan I have this column in my data: table(data$year)
2011 2012 2013 2014 2015 2016 2017 2018 2019
2 28 17 36 26 29 37 33 10
is.numeric(data$year)
[1] TRUE
I want to make changes to case_when using the following code: data <- data %>%
m
username I have a dataset with studyid, year and two markers: event and popular. I want all year variables to be TRUE (1) after the event is marked true (and the event variable can only be true once). case_when and lag seem to be the perfect combination, but i
nt I have a list with 31 site names. > typeof(Asites)
[1] "list"
> str(Asites)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 31 obs. of 1 variable:
$ Asites: chr "45.88:-64.35" "45.88:-64.37" "45.89:-64.33" "45.89:-64.34" ...
I want to write a case_when stat
Malinga I try to write a simple function around the dplyr::case_when() function. I read the program with dplyr documentation at https://cran.r-project.org/web/packages/dplyr/vignettes/programming.html but can't figure out how the case_when() function works. I