Kim Kim - 2 months ago 12
R Question

Counting data with same id in R

I am trying to find count how much time the same movid is played.

This is data I am using

Thanks to comments,

This is frequency of movie played

> c<-head(table(B$movid),n=5)
> head(as.data.frame(c),n=5)
id Freq
1 1 452
2 2 131
3 3 90
4 4 209
5 5 86


1. For this data, I would like to know how to +1 to frequency value for each id

This is rating data

> d<-table(B$movid[B$rating>4])
> head(as.data.frame(d),n=5)
id Freq
1 1 119
2 2 9
3 3 11
4 4 29
5 5 6


2. After I find this proportion(d/c) as a vector matrix to create new matrix.

Thank you for your time and thank you for your help!

Answer

We can use table to find the frequency

table(df1$movid)

For the second question

length(unique(df1$movid[df1$rating>3.5]))