Re: [R] Using Partial Column Matching for Mutate

2019-08-06 Thread Shawn Way
Frankly, this is great. I don’t really care if it base or tidy, I just need it to work. Thank you kindly! Shawn Way, PE From: Eric Berger Sent: Tuesday, August 06, 2019 8:30 AM To: Shawn Way Cc: r-help@r-project.org Subject: Re: [R] Using Partial Column Matching for Mutate ** External

Re: [R] Using Partial Column Matching for Mutate

2019-08-06 Thread Eric Berger
Hi Shawn, Here is a solution using base R (no dplyr). The only regex appears in the statement to get the common prefixes. colsPrefixes <- sub("_Planned$","",colnames(gross_test)[ grep("_Planned$",colnames(gross_test))]) f <- function(s) { gross_test[,paste(s,"Diff",sep="_")] <<- gross_test[,past

[R] Using Partial Column Matching for Mutate

2019-08-06 Thread Shawn Way
I have a tibble that has a large number of variables and because I'm partial lazy (and I really want to know how to do this), I would like find out if it possible to partial column matching with the mutate function in the tidyverse. I have a tibble with the following > gross_test <- gross_df %