Category "dplyr"

In dplyr using str_detect and case_when in R

This is my df: mydf <- structure(list(Action = c("Passes accurate", "Passes accurate", "Passes accurate", "Passes accurate", "Lost balls", "Lost balls (in o

Include 'blank' filters in dplyr filter chain in Shiny app

I have a shiny application with numerous user inputs including numericInput and textInput and pickerInput. These inputs are used to filter a dataframe. In my fi

separate_columns for tidyr

Let's say I had a survey question that read: What did you eat? [ ] apple [ ] pear [x] banana [x] grapes Now, I have the endorsed options as comma-separated st

Calculate Stock

Is it possible calculated stock using R? The formula is stock+purchase-sold. In this case first stock (row1) is 0, rg first result stockB1= 12 - 3 = 9 the secon

grouped data frame to list

I've got a data frame that contains names that are grouped, like so: df <- data.frame(group = rep(letters[1:2], each=2), name = LETTERS[1:4

Difference between pull and select in dplyr?

It seems like dplyr::pull() and dplyr::select() do the same thing. Is there a difference besides that dplyr::pull() only selects 1 variable?

R how to group part of overlapped values among rows?

I have a data frame that some rows that need to be further grouped by some of the overlapped values among rows col1, col2 a1, 2;3 a2, 2 a3, 3;4 a4, 4 a

How to fix the var(X) is now defunct

I used the following function to find standard error of variables. but when I run the same function now, it is not working. st.err <- function(x) { sd(

Taking only the maximum values of duplicate IDs for all columns of a data frame in R

I have data frame of 24525 rows and 22 columns. Last column is the ID column, other are numeric. Number of unique IDs is 18414 and some IDs are repeated more th

Using dplyr to conditionally replace values in a column

I have an example data set with a column that reads somewhat like this: Candy Sanitizer Candy Water Cake Candy Ice Cream Gum Candy Coffee What I'd like to do

Using dplyr to conditionally replace values in a column

I have an example data set with a column that reads somewhat like this: Candy Sanitizer Candy Water Cake Candy Ice Cream Gum Candy Coffee What I'd like to do

How to add a total distance column in 'flights' dataset? DPLYR, Group_by, Ungroup

I am working with 'flights' dataset from 'nycflights13' package in R. I want to add a column which adds the total distance covered by each 'carrier' in 2013. I

dplyr::select function clashes with MASS::select

If I load the MASS package: library(MASS) then load try to run dplyr::select, I get a error: library(dplyr) mtcars %.% select(mpg) # Error in select(`__pre

Calling user defined functions from dplyr::mutate

I'm working on a project that involves many different tibbles, all of which have a period variable of the format YYYYMM. Below is an example of how all my tibbl

Calling user defined functions from dplyr::mutate

I'm working on a project that involves many different tibbles, all of which have a period variable of the format YYYYMM. Below is an example of how all my tibbl

Trying to be benchmark dplyr vs data.table

Why does this code not work? How can I benchmark these to expressions? library(data.table) library(dplyr) dt <- as.data.table(mtcars) (lb <- bench::mar