I would like to add a column to a data frame with the count of matches in another data frame, this seems pretty trivial but I can’t seem to get it to work. Example:
smaller_df$CountOfMatches <- nrow(subset(larger_df, Date == smaller_df$Date))
This gives me the error:
In `==.default`(Date, smaller_df$Date) :
longer object length is not a multiple of shorter object length
I know the data frames are different lengths, I’m not asking for a merge, I simply need for that for every row/date (valid date object) in the smaller_df; a count how many matches in the larger_df.
I’m very new to R so there must be something fundamental and very trivial I’m missing here.
Thanks in advance
Here’s what seems fairly straightforward: