Filtering a tibble in R by list of strings and returning all records that end with the strings in the list

I have a huge data frame. One of the columns in the data frame is an email address. In addition, I have a vector with domain extensions (for example: c(".ac",".ad",".ae",".af",".ag",".ai") – a total length of 259 extensions.) I want to filter my data frame to contain records whose email ends with one of the strings… Read More Filtering a tibble in R by list of strings and returning all records that end with the strings in the list

Getting grepl to return TRUE only if there is a match with the full string

I have example data as follows: library(data.table) dat <- fread("q1 q2 …1 ..2 q3..1 ..1 NA response other else response other 1 4 NA NA 1 NA") I wanted to filter out all columns that are automatically named when reading in an Excel file with missing column names, which have names like ..x. I thought… Read More Getting grepl to return TRUE only if there is a match with the full string

Extract and create columns from character strings separated by "_" in R

I’m trying to extract the character string "segments" separated by an "_" and make them their own columns. I know how to combine many columns to a single one, but I’m curious how going backwards works (single column to many). My data: structure(list(REF = c("M120", "M70", "M100", "M94", "M74", "M54", "M99", "M09", "M111", "M17"), SEAS… Read More Extract and create columns from character strings separated by "_" in R