This question already has an answer here:
I have data that looks like the following. I'm fairly new to programming and am not sure how to subset my data into variables that split the dataframes into divisions by week. I want to do it without having to type
DataWeek1=Data[which(Data$Week==1),]
52 times. I assume I have to use a for loop of some kind, but am not sure how to do so?
REGION YEAR WEEK
1 Alabama 2010 40
2 Alaska 2010 40
3 Arizona 2010 40
4 Arkansas 2010 40
5 California 2010 40
6 Colorado 2010 40