I have a very large dataset showing logins to a website. I'm trying to calculate the frequency of logins by username.
What I hope to get is a table like the below where the period is listed as column header and the frequency is the row name and the data is the number of users who logged in on the given day for the number of times in the header row, i.e.
[weekday] [Mon][tue][etc]
[logins ]
[ 1][123][456][789]
[ 2][987][654][321]
[ etc][123][456][789]
The source data is simply login id, date/time login. I've been able to add columns appending the month, name of the day, and day number based on the date of login.
Ideally I'd like to be able to get the same sort of summary as above for each category (Month, day of month, day name).
library(lubridate )
library(dplyr)
library(rpivotTable)
df = data.frame(datasource)
df$MonthNumber <- month(df$Date)
df$DayNumber <- wday(df$Date, FALSE, FALSE)
df$DayName <- wday(df$Date, TRUE, FALSE)
#problem is here, i dont know how to get the count of user logins per day
Results <- xtabs(~ DayCount + c(DayName,USERID), df)
write.csv(Results, file="weekdata.csv")
Results