Sorry for gibberish title, I'm bad at being succinct when I don't understand something fully.
The Access database this originates from is broken up into tables keyed by IDs unique in one table, but non-unique in others, in this case the parent contains all of the surveys, each with a unique id, and the child table contains all of the sample data for each survey (roughly 10 samples per survey) but none of the survey data such as region or date. This leads me to the problem, being that I want to be able to attribute data from the survey to each sample for analysis. I've tried Samples$Year <- Surveys$Year[Samples$SurveyID %in% Surveys$SurveyID]
which doesn't work due to the unequal length of the frames, and I've tried a very long roundabout and slow nested loop with if/then statements, but there has to be a better way I'm not familiar with as I am fairly new to R and self taught. What would the best way to accomplish either adding the correct column to the child dataframe, or pulling the relevant associated data when needed for each row?
What I have is something like
Surveys:
SurveyID Date Region
1 10 12-MAR-2020 A
2 11 16-APR-2020 B
3 12 20-APR-2020 C
Samples:
SurveyID SampleID Count
1 10 123 23
2 10 124 54
3 11 125 65
4 11 126 0
5 11 127 3
6 12 128 43
and I want to ideally join them to create something like
Samples:
SurveyID SampleID Count Date Region
1 10 123 23 12-MAR-2020 A
2 10 124 54 12-MAR-2020 A
3 11 125 65 16-APR-2020 B
4 11 126 0 16-APR-2020 B
5 11 127 3 16-APR-2020 B
6 12 128 43 20-APR-2020 C
I've tried searching for similar problems, and I'm either using the wrong keywords due to inexperience, barking up the wrong tree, or haven't come across someone in a similar predicament. It may also be worth noting that I did not design the database, and although I do have some SQL experience it's not much to shake a stick at.