Skip to main content
0 votes
1 answer
113 views

How do I get the mutate function, from the dplyr package, to work when R says I have input problems due to vec_is_vector being defunct? I’ve recently updated R and noticed that some of my old code no ...
Rana's user avatar
  • 9
0 votes
2 answers
153 views

Consider the following example: df<-data.frame(x_1=c(NA,1,NA), x_2=c(1,1,NA), y=c(NA,1,1)) What's the minimum number of code characters that allows me to use ...
robertspierre's user avatar
4 votes
1 answer
254 views

Consider the following code: require(dplyr) require(data.table) dt_original <- data.table( colA_char = c("A1", "A2", "A3"), colB_char = c("B1", "...
Vasily A's user avatar
  • 8,744
Best practices
2 votes
3 replies
126 views

I haven't used meta-programming operators in R for a while, and I came across this today. What is the recommended way to add a new column? # Using embrace operator add_col1 <- function(data, ...
MoltenLight's user avatar
2 votes
3 answers
133 views

I've made a function to calculate the percentage of students who progressed to HE. Now I want to filter and group my data in different ways and calculate the percentage of each group that progressed ...
Sophie Elizabeth's user avatar
4 votes
3 answers
184 views

How to mutate new variable according the string my_formula1 and my_formula2 ? library(tidyverse) # sample 1 : this can work ,by the new variable not 'total' ( it's is `eval(str2lang(my_f))`) ...
anderwyang's user avatar
  • 2,659
6 votes
7 answers
541 views

in below code ,there are two case_when(),the conditions are the same. Is the any way to simplify it ? library(tidyverse) diamonds %>% mutate(kpi_a = case_when( color %in% c('E','I') ~ "A&...
anderwyang's user avatar
  • 2,659
7 votes
2 answers
245 views

I was trying the case_when() call in R and realized an interesting behavior. A simplified example: Expected behavior > case_when(0 < 1 ~ "a", 2 > 3 ~ "b", ...
francesc2's user avatar
Best practices
1 vote
1 replies
69 views

I will use Euler diagrams (from the eulerr package) to visualize A, B, and the intersections of A and B. My data points are A: 21%, B: 24%, and “A&B”: 14%, and my goal is to visualize all three ...
jbopp's user avatar
  • 37
1 vote
2 answers
120 views

I have data that looks like this: individual <- 1:10 group <- c("A", "A", "B", "B", "B", "C", "C", "D", "D&...
Will Hamilton's user avatar
3 votes
3 answers
214 views

I want to create a column that labels each row as belonging to a group based on the date in one of the other columns. I want to be able to set the time window that define groupings, eg within 1 week ...
Will Hamilton's user avatar
1 vote
7 answers
315 views

I have a dataframe with >100 variables, and I want to rearrange only some of the variables alphabetically whilst leaving the rest where they are I know there are MANY posts that answer how to ...
missanita's user avatar
  • 306
Best practices
0 votes
3 replies
80 views

I have a dataframe called Profile_1_2 of data that is formatted like this: Profile_number chl_z Cphyto_z 1 0.2 10 1 0.6 100 2 0.1 20 2 0.5 90 Profile_number denotes a group, each profile contains 200 ...
amazing_zebra's user avatar
3 votes
1 answer
150 views

I have the following dataframe: df <- data.frame( Form=rep(c("Fast", "Medium", "Slow"), each = 3), Parameter =rep(c("Fmax", "TMAX", "B&...
Maz's user avatar
  • 33
5 votes
2 answers
195 views

I am trying to set up a conditional argument in a function to drop columns from the tibble based on column name. There are a large number of columns but many are adjacent to one another and I would ...
user2352714's user avatar

15 30 50 per page
1
2 3 4 5
2508