count - Counting activity within a time period in R -
i have data set each data point question answered in math program.
a sample data set be
user_id correct time 5409 0 2016-03-09 10:58:53 5409 1 2016-02-16 09:50:42 5409 0 2016-01-28 09:46:43 5409 1 2016-03-09 10:58:32 i count number of questions answered per day , have count of how many answered correct , how many answered wrong.
i have tried use function count in r:
df$time <- as.posixct(strftime(oneuser$time, format='%y/%m/%d'),format='%y/%m/%d',tz="cet") count(df, user_id, time ,correct) which give following result:
user_id time correct n 1 540952 2015-08-13 0 11 2 540952 2015-08-13 1 39 3 540952 2015-08-17 0 6 4 540952 2015-08-17 1 12 5 540952 2015-08-20 0 25 6 540952 2015-08-20 1 58 7 540952 2015-08-27 0 11 but rearrange have total number of question answered, number of questions answered correctly , number of questions answered wrong in columns next each other e.g.
user_id time correct wrong total 540952 2015-08-13 39 11 50 540952 2015-08-17 12 6 18
Comments
Post a Comment