I have a data frame that consists of one row for each user. For each user, I have information on when they first logged on to a website (row 1), and for each day after that (each day is a column) how many times per day they logged in.
I would like to create a new column that tells me the number of times, within the 7 days after they first logged on, a user logged on to a website. This 7-day period is different for every user.
I would like to do a for-loop, but don't know how to make changes to include varying column names for that summation.
tibble(id=c(1:4), first_log = c("18-12-01", "18-12-02", "18-12-02",
"18-12-05"), X18_12_01 = c(NA,1,1,2), X18_12_02 = c(5,2,1,1))
Of course, the data set has many more columns and rows just like that.