I'm quite new to R or programming in general, so it's hard to articulate my thoughts right now.
I have a huge database that has two main differentiation factors name and date. The final product will be something that will look like this:
name W1 W2 W3
A 10 12 22
B 20 13 44
C 15 14 11
But also, it has to allow me to add a new week to the column.
Currently, I have managed to write the code for only one week. I guess I can put the weeks together, one by one, but I am sure that there should be another simpler/automatic method.
I have managed to write a code to identify the week based on the date, so in the database i have a column with the week.
With summarise and group by, I have managed to create a function that sum all identical names and split them by weeks. The data frame looks like this:
Channel Week allday.sum
ALL 41 870969
ALL 42 5317647
A 41 261623
A 42 223144
Now I need a method that will allow me to add to another data frame a new column with any possible weeks that may appear - so the data.frame will look like this
name W41 W42 W43
ALL 10 12 22
A 20 13 44
B 15 14 11
I hope I was descriptive enough :D