-1

Apologies in advance for the noob question. I have 2 different csv data sets containing different information but share the same primary key "staff name". I'm trying to find out how productive employees are during the hours they worked by pulling the volume.csv and timecard.csv. Is there a way to overlay the data to analyze how productive they are on a given day using the primary key? The timecard.csv file has data by paycode (personal holiday, overtime, regular) and volume.csv file has data by unique visit # (accessions).

R Script: myvoldata=read.csv("Rad Tech Productivity_May 2021 Volume.csv") mytimedata=read.csv("Kronos Employee_May 2021.csv")

illianyc
  • 1
  • 1
  • It shounds as though you actually want a merge based on both "staff.name" and whatever is your date variable is. As such I'm guessing that the current answer will not be adequate for answering the question: "how productive they are on a given day using the primary key?" But I think closing as a duplicate is a useful exercise since it lets you see a well illustrated set of answers using the merge and join functions for the three dominant datatypes for data analysis: data.frames, tibbles, and data.tables. If you want further help you can show us how this doesn't actually answer your problem. – IRTFM Jun 02 '21 at 02:57

1 Answers1

0

Assuming you have already read in each csv using read.csv(), you can simply merge the two into a single data frame for analyzing.

Using the dplyr library: full_join(volume, timesheet, by = "staff name") will keep all columns from both tables, joining on the staff name column.

Kelsey
  • 81
  • 3
  • 1
    You might want to also offer the base R version that would use `merge`. The major difference between the dplyr `*_join`-functions and the `merge`-function being that it has a set of `all`-arguments for merge that make it deliver a (right_, left_ or full_)join. This would also appear to be extremely likely to have been asked and answered, probably with a working example in the question. So the question is rather low quality and probably should have been closed rather than answered. – IRTFM Jun 02 '21 at 02:48