I created a df called 'employee', and separated the name col, into 'first_name ' & 'last_name'. I am now trying to unite the 'first_name' col with the 'last_name' col into a new col called 'full_name', but getting an error indicating that the 'first_name' col does not exist when it clearly does.
library("tidyverse")
id <- c(1:2)
name <- c("John Mendes", "Rob Stewart")
job_title <- c("Professional", "Programmer")
employee <- data.frame(id, name, job_title)
print(employee)
#> id name job_title
#> 1 1 John Mendes Professional
#> 2 2 Rob Stewart Programmer
separate(employee,name,into = c('first_name','last_name'), sep = ' ')
#> id first_name last_name job_title
#> 1 1 John Mendes Professional
#> 2 2 Rob Stewart Programmer
unite(employee,'full_name',first_name,last_name,sep=' ')
#> Error in `chr_as_locations()`:
#> ! Can't subset columns that don't exist.
#> ✖ Column `first_name` doesn't exist.