join - Error with R dplyr left_join -


so i've been trying use left_join columns of new dataset onto main dataset (called employee)

i've double checked vector names , cleaning i've don't , nothing seems work. here code. appreciate help.

job_codes <- read_csv("quest_umms_jobcodes.csv") job_codes <- job_codes %>% clean_names() %>% select(job_code, pos_desc = pos_des_desc)  job_codes$is_nurse <- str_detect(tolower(job_codes$pos_desc), "nurse")   employee <- employee %>% left_join(job_codes, = "job_code") 

the error keep getting:error in eval(substitute(expr), envir, enclos) : 'job_code' column not found in rhs, cannot join

here results of

names(job_code) > names(job_codes) [1] "job_code" "pos_desc" "is_nurse"  names(employee) > names(employee)  [1] "rec_num"             "zip"                 "state"                [4] "sex"                 "eeo_class"           "birth_year"           [7] "emp_status"          "process_level"       "department"           [10] "job_code"            "union_code"          "supervisor"           [13] "date_hired"          "r_shift"             "salary_class"         [16] "exempt_emp"          "pay_rate"            "adj_hire_date"        [19] "annivers_date"       "term_date"           "nbr_fte"              [22] "pension_plan"        "pay_grade"           "schedule"             [25] "ot_plan_code"        "deceased"            "position"             [28] "work_sched"          "supervisor_ind"      "fte_total"            [31] "pro_rate_total"      "pro_rate_a_sal"      "new_hire_date"        [34] "county"              "fst_day_worked"      "date_hired"           [37] "date_hired_adj"      "term_date"           "employment_duration"  [40] "current"             "age"                 "emp_duration_years"   [43] "description.x"       "pay_status.x"        "description.y"        [46] "pay_status.y"       

now, after op has added column names of both tables in q, evident column join on written in different ways (upper vs lower case).

if column names different, help("left_join") suggests:

to join different variables on x , y use named vector. example, = c("a" = "b") match x.a y.b.

so, in case should read

employee <- employee %>% left_join(job_codes, = c("job_code" = "job_code")) 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -