Hi,
Really struggling to get the desired output.
I have a vector containing a range of characters.
I also have a data frame containing a range of categories.
Current vector:
vector = c("1","1","2","3","3","3")
Current dataframe:
df <- data.frame(
Door.Number = c("1", "2", "3")
)
How would I create a new column within the dataframe, with the count of records in the vector?
Desired Output
data.frame(
Door.Number = c("1", "2", "3"),
Count = c(2, 1, 3)
)
I've tried methods like the one below with no luck. Just seems to create a column with the total.
mutate(count = sum(df[,1] %in% vector))
Thanks for all guidance, help!