How to fill in NA values according to a categorial variable in R

I have some NA values in my data that I would like to fill in according to the filename column. In order words, every observation with the same filename should have the same values in the discipline, nativeness, year, and gender columns. structure(list(TA = c("future_perfect", "future_progressive", "future_simple", "past_perfect", "past_perfect_progressive", "past_progressive", "past_simple", "present_perfect", "present_perfect_progressive", "present_progressive", "present_simple",… Read More How to fill in NA values according to a categorial variable in R

R dplyr pivot (rankings table) – new column with unique row values from multiple columns, then assign row values from another column

Let’s say we have the following tibble ( rank = c(1, 2, 3), race_A = c("John", "Nick", "George"), race_B = c("Jay", "Nick", "John"), race_C = c("Jay", "Jack", "Robbie") ) which generates this tibble # A tibble: 3 × 4 rank race_A race_B race_C <dbl> <chr> <chr> <chr> 1 1 John Jay Jay 2 2 Nick… Read More R dplyr pivot (rankings table) – new column with unique row values from multiple columns, then assign row values from another column

R how to change data types in list.file to prevent bind_rows error

I have multiple (~40) excel files with identical column names and want to bring them all into 1 df and bind_rows but getting error due to data type mismatch. How/when do I convert all to character so that I can bind rows into 1 df? library(readxl) library(tidyverse) file.list <- list.files(pattern=’*.xlsx’, recursive = TRUE) df.list <-… Read More R how to change data types in list.file to prevent bind_rows error

How to use multiple variable from tibble in an user-defined function?

I have created a tibble consisting of 6 columns containing 6 different variables that will be input for a user defined function. I am new to r, and I don’t know how to connect the tibble with user defined function. Please help. I have replaced the complex user defined function with simple user_defined_function for the… Read More How to use multiple variable from tibble in an user-defined function?