After trying what was recommended previously for a similar challenge, I'm still lost and perhaps am missing something simple.
I have two data frames Uniques and Uniques2.
In Uniques, I have a column with 49,999 rows of a variable.
In Uniques2, I have separated out the unique variables and come up with a total of 403.
Now I would like to count how many time each variable in Uniques2$aa.IndustryGroup appears in a certain column in Uniques$aa.IndustryGroup. I would like it to display in a new column $Count in the Uniques2 data frame.
A previous Stack question recommended using == and SUM to find out the answer, which I thought was straightforward enough.
So I've tried this,
Uniques2$Count = data.frame(sum(Uniques$aa.IndustryGroup == Uniques2$aa.IndustryGroup))
And it returns errors about length which I know means that I'm not asking it to do what I want correctly.
Error in `$<-.data.frame`(`*tmp*`, "Count", value = list(sum.Uniques.aa.IndustryGroup....Uniques2.aa.IndustryGroup. = 138L)) :
replacement has 1 row, data has 403
In addition: Warning messages:
1: In is.na(e1) | is.na(e2) :
longer object length is not a multiple of shorter object length
2: In `==.default`(Uniques$aa.IndustryGroup, Uniques2$aa.IndustryGroup) :
longer object length is not a multiple of shorter object length
Thanks for being a stellar community and leaving a trail of breadcrumbs. The success of this adventure would be improbable without you.