In R I have a data.frame data
containing user
, game
and number
which is the number of times a game
has been played for a fixed user
.
Let a fixed user be given and consider this
user game number
1 1 110
1 2 95
1 3 263
1 4 55
1 5 24
1 6 10
Now Im looking for games that are dominant. A dominant game is a game than a user has played 25% of the times. I want to find which games has been played more than 25% of the times in this case, so I type
u=c()
for(j in 1:6) {
# Check if the percentages is higher than 25
if(data[j,3] / sum(data[,3]) > 0.25) {
u[j]=data[j,2]
}
else{u[j]=0}
But when I type this in R I get this strange message
Error in if(....): missing value where TRUE/FALSE needed