R pivot to wide and back to long (multiple groups) - r

I've been using wide table format to create a migration variable (year, municipality -> year, municipality, move) and was wondering if I can flip it back into long table format. However, I now 2 groups per year instead of one. I looked through the existing posts on SO, but couldn't find anything similar.
Here's what I have done:
library(tidyverse)
library(rlang)
# sample data
mydata <- data.frame(id = sort(rep(1:10,3)),
year = rep(seq(2009,2011),10),
municip = sample(c(NA,1:3),30,replace=TRUE))
The data looks like this:
id
year
municip
1
2009
2
1
2010
1
1
2011
3
2
2009
1
2
2010
1
2
2011
3
3
2009
NA
3
2010
NA
3
2011
NA
# turn sideways
mydata.wide <- mydata %>%
pivot_wider(names_from = year,
names_prefix = "municip.",
values_from = municip)
Now it looks like this:
id
municip.2009
municip.2010
municip.2011
1
2
1
3
2
1
1
3
3
NA
NA
NA
4
1
NA
3
5
1
NA
2
6
3
2
2
7
2
NA
3
8
3
NA
3
9
NA
1
NA
10
1
NA
2
Then I'm adding a migration variable (in reality this is done for 12 years):
# create migration variable
for (i in 2009:2010){
text.string <- paste0("mydata.wide <- mydata.wide %>%
mutate(move.",i+1," = case_when(
is.na(municip.",i,") & is.na(municip.",i+1,") ~ \"NA\",
is.na(municip.",i,") & !is.na(municip.",i+1,") ~ \"1\",
!is.na(municip.",i,") & !is.na(municip.",i+1,")
& municip.",i," != municip.",i+1," ~ \"3\",
!is.na(municip.",i,") & is.na(municip.",i+1,") ~ \"4\",
TRUE ~ \"2\"
))")
eval(parse_expr(text.string))
}
# NA: missing in both cases
# 1: move into region
# 2: stayed in region
# 3: moved within region
# 4: moved out of region
Now the table looks like this:
id
municip.2009
municip.2010
municip.2011
move.2010
move.2011
1
2
1
3
3
3
2
1
1
3
2
3
3
NA
NA
NA
NA
NA
4
1
NA
3
4
1
5
1
NA
2
4
1
6
3
2
2
3
2
7
2
NA
3
4
1
8
3
NA
3
4
1
9
NA
1
NA
1
4
10
1
NA
2
4
1
What I want to do is to flip it back to create something like this:
id
year
municip
move
1
2009
2
NA
1
2010
1
3
1
2011
3
3
2
2009
1
NA
2
2010
1
2
2
2011
3
3
3
2009
NA
NA
3
2010
NA
NA
3
2011
NA
NA
I'm not sure if this can be done with just pivot_longer on it's own. I tried a couple of variations. Any ideas?

You can try this:
df <- tribble(~id, ~municip.2009, ~municip.2010, ~municip.2011, ~move.2010, ~move.2011,
1, 2, 1, 3, 3, 3,
2, 1, 1, 3, 2, 3,
3, NA, NA, NA, NA, NA,
4, 1, NA, 3, 4, 1,
5, 1, NA, 2, 4, 1,
6, 3, 2, 2, 3, 2,
7, 2, NA, 3, 4, 1,
8, 3, NA, 3, 4, 1,
9, NA, 1, NA, 1, 4,
10, 1, NA, 2, 4, 1
)
df %>%
pivot_longer(cols = -1, names_to = "temp1", values_to = "count") %>%
separate(col = temp1, c("temp2", "year")) %>%
pivot_wider(names_from = temp2, values_from = count)
pivot_longer collects municip and move in the same column; with separate split municip and move by the years; finally with pivot_wider you get the final result.

Don't think sideways, think longways!
Now, I cannot answer your question completly, because I don't really understand what you are calculating. Is it some sort of factor (1-4)? But I believe you can finish this yourself. Consider the following:
> mydata %>% group_by(id) %>%
arrange(year) %>%
mutate(last_year = lag(municip)) %>%
ungroup %>%
arrange(id) %>% as.data.frame # ignore this line, it is simply for the pleasure of seeing the data.frame
id year municip last_year
1 1 2009 3 NA
2 1 2010 2 3
3 1 2011 NA 2
4 2 2009 NA NA
5 2 2010 NA NA
6 2 2011 1 NA
7 3 2009 3 NA
8 3 2010 2 3
9 3 2011 2 2
10 4 2009 2 NA
11 4 2010 NA 2
12 4 2011 1 NA
13 5 2009 3 NA
14 5 2010 NA 3
15 5 2011 2 NA
16 6 2009 1 NA
17 6 2010 3 1
18 6 2011 2 3
19 7 2009 3 NA
20 7 2010 2 3
21 7 2011 2 2
22 8 2009 NA NA
23 8 2010 NA NA
24 8 2011 3 NA
25 9 2009 1 NA
26 9 2010 NA 1
27 9 2011 1 NA
28 10 2009 3 NA
29 10 2010 NA 3
30 10 2011 NA NA
You see? In long-form, you now can simply continue with
%>% mutate(move = case_when(
is.na(.$municip) & is.na(.$last_year) ~ \"NA\",
# etc.
))
Did you want the comparision from year i to the following year? Use the function lead instead of lag.
Lastly, your text-code might not work; when using case_when you have to refer to variables in the piped result with .$.

Something like this?
mydata.wide %>%
pivot_longer(
cols = -id,
names_pattern = "([a-z]+?)\\.(\\d+)",
names_to = c("name", "year"),
values_to = "val",
values_transform = list(val = as.character)
) %>%
pivot_wider(
names_from = name,
values_from = val
) %>%
print(n=30)
A tibble: 30 × 4
id year municip move
<int> <chr> <chr> <chr>
1 1 2009 2 NA
2 1 2010 3 3
3 1 2011 NA 4
4 2 2009 2 NA
5 2 2010 NA 4
6 2 2011 2 1
7 3 2009 1 NA
8 3 2010 2 3
9 3 2011 1 3
10 4 2009 NA NA
11 4 2010 NA NA
12 4 2011 1 1
13 5 2009 NA NA
14 5 2010 2 1
15 5 2011 3 3
16 6 2009 3 NA
17 6 2010 3 2
18 6 2011 3 2
19 7 2009 NA NA
20 7 2010 NA NA
21 7 2011 NA NA
22 8 2009 NA NA
23 8 2010 2 1
24 8 2011 NA 4
25 9 2009 3 NA
26 9 2010 2 3
27 9 2011 NA 4
28 10 2009 2 NA
29 10 2010 3 3
30 10 2011 1 3

Related

Replace duplicated values with NA by group

I have a data frame like so:
subject <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5)
day <- c(20, 20, 20 , 20, 20, 40 , 40 , 40 , 40 , 50, 50, 50, 40, 40, 40, 40, 20, 20)
ex <- data.frame(subject, day)
Within each subject, I want to change duplicate 'day' to NA:
subject day
1 1 20
2 1 NA
3 1 NA
4 1 NA
5 1 NA
6 2 40
7 2 NA
8 2 NA
9 2 NA
10 3 50
11 3 NA
12 3 NA
13 4 40
14 4 NA
15 4 NA
16 4 NA
17 5 20
18 5 NA
library(dplyr)
ex %>%
group_by(subject) %>%
mutate(day = ifelse(duplicated(day), NA, day)) %>%
ungroup()
# # A tibble: 18 × 2
# subject day
# <dbl> <dbl>
# 1 1 20
# 2 1 NA
# 3 1 NA
# 4 1 NA
# 5 1 NA
# 6 2 40
# 7 2 NA
# 8 2 NA
# 9 2 NA
# 10 3 50
# 11 3 NA
# 12 3 NA
# 13 4 40
# 14 4 NA
# 15 4 NA
# 16 4 NA
# 17 5 20
# 18 5 NA
library(dplyr)
ex %>%
group_by(subject) %>%
mutate(day = ifelse(row_number()==1, day, NA_real_)) %>%
ungroup()
subject day
<dbl> <dbl>
1 1 20
2 1 NA
3 1 NA
4 1 NA
5 1 NA
6 2 40
7 2 NA
8 2 NA
9 2 NA
10 3 50
11 3 NA
12 3 NA
13 4 40
14 4 NA
15 4 NA
16 4 NA
17 5 20
18 5 NA
We may use
ex$day <- NA^duplicated(ex) * ex$day
-output
> ex
subject day
1 1 20
2 1 NA
3 1 NA
4 1 NA
5 1 NA
6 2 40
7 2 NA
8 2 NA
9 2 NA
10 3 50
11 3 NA
12 3 NA
13 4 40
14 4 NA
15 4 NA
16 4 NA
17 5 20
18 5 NA

Remove NAs in each column by group

I have a dataframe with rows grouped by Year. Variables don't always have observations in each year but when they do, there are 3 observations in that year but appear in different rows.
> na_data
Year Peter Paul John
1 2011 1 NA NA
2 2011 2 NA NA
3 2011 3 NA NA
4 2011 NA 1 NA
5 2011 NA 2 NA
6 2011 NA 3 NA
7 2012 1 NA NA
8 2012 NA 3 NA
9 2012 2 NA NA
10 2012 NA 2 NA
11 2012 3 NA NA
12 2012 NA 1 NA
13 2013 NA 1 4
14 2013 NA 2 5
15 2013 NA 3 6
16 2013 1 NA NA
17 2013 2 NA NA
18 2013 3 NA NA
I want to remove the NAs in each column by group. Such that the output looks like this:
final_data
Year Peter Paul John
[1,] 2011 1 1 NA
[2,] 2011 2 2 NA
[3,] 2011 3 3 NA
[4,] 2012 1 3 NA
[5,] 2012 2 2 NA
[6,] 2012 3 1 NA
[7,] 2013 1 1 4
[8,] 2013 2 2 5
[9,] 2013 3 3 6
So far I have used a loop but I am looking for a cleaner solution if anyone can help that would be great. My solution:
cleaned_list <- vector("list", length(unique(full_data$Year)))
names(cleaned_list) <- unique(full_data$Year)
for(yr in unique(na_data$Year)) {
temp <- matrix(NA, nrow = 3, ncol = ncol(na_data),
dimnames = list(NULL, colnames(na_data)))
for(name in colnames(na_data)[-1]){
no_nas <- as.vector(na.omit(na_data[Year==yr, name]))
if (length(no_nas)!=0) temp[,name] <- no_nas
}
temp[,1] <- yr
cleaned_list[[as.character(yr)]] <- temp
}
final_data <- do.call("rbind", cleaned_list)
Data:
na_data <- data.frame(
Year = rep(c(2011,2012,2013), each = 6),
Peter = c(1:3, rep(NA, 3), 1,NA,2,NA,3,NA, rep(NA, 3),1:3),
Paul = c(rep(NA,3), 1:3, NA,3,NA,2,NA, 1, 1:3, rep(NA,3)),
John = c(rep(NA, 12), 4:6, rep(NA, 3))
)
desired <- data.frame(
Year = rep(c(2011,2012,2013), each = 3),
Peter = c(1:3, 1:3, 1:3),
Paul = c( 1:3, 3:1, 1:3),
John = c(rep(NA, 6), 4:6)
) # same as final_data but a dataframe
Here is one possible solution using data.table package:
library(data.table)
setDT(na_data)[, lapply(.SD, function(x) if(length(y<-na.omit(x))) y else first(x)), by=Year]
# Year Peter Paul John
# 1: 2011 1 1 NA
# 2: 2011 2 2 NA
# 3: 2011 3 3 NA
# 4: 2012 1 3 NA
# 5: 2012 2 2 NA
# 6: 2012 3 1 NA
# 7: 2013 1 1 4
# 8: 2013 2 2 5
# 9: 2013 3 3 6
dplyr equivalent:
library(dplyr)
na_data |>
group_by(Year) |>
summarise(across(.fns = ~ if(length(y<-na.omit(.x))) y else first(.x)))
# # A tibble: 9 x 4
# # Groups: Year [3]
# Year Peter Paul John
# <dbl> <dbl> <dbl> <int>
# 1 2011 1 1 NA
# 2 2011 2 2 NA
# 3 2011 3 3 NA
# 4 2012 1 3 NA
# 5 2012 2 2 NA
# 6 2012 3 1 NA
# 7 2013 1 1 4
# 8 2013 2 2 5
# 9 2013 3 3 6
Convert to long form, remove the NA's, add a sequence number n, convert back and remove n.
library(dplyr)
library(tidyr)
na_data %>%
pivot_longer(-Year) %>%
drop_na %>%
group_by(Year, name) %>%
mutate(n = 1:n()) %>%
ungroup %>%
pivot_wider %>%
select(-n)
giving:
# A tibble: 9 x 4
Year Paul Peter John
<dbl> <dbl> <dbl> <dbl>
1 2011 1 1 NA
2 2011 2 2 NA
3 2011 3 3 NA
4 2012 1 1 NA
5 2012 2 2 NA
6 2012 3 3 NA
7 2013 1 1 4
8 2013 2 2 5
9 2013 3 3 6

Fill subset of rows with values from row above

I have a long format dataset with longitudinal data and for one variable I want to fill in the missings in timepoint 0 with the values in timepoint 1, but I do not want to fill in the missings from timepoint 1 with values from timepoint 2 and so on.
My dataset is ordered by id and timepoint.
I have used the fill function succesfully in cases where I just needed to fill missings from all timepoints from a specific id.
Example dataframe:
df <- data.frame(id=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4),
timepoint=c(0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3),
var1=c(NA,9,8,10, NA, 10, NA, 12, NA, NA, 12, 11, NA, 12, 12, NA))
> df
id timepoint var1
1 1 0 NA
2 1 1 9
3 1 2 8
4 1 3 10
5 2 0 NA
6 2 1 10
7 2 2 NA
8 2 3 12
9 3 0 NA
10 3 1 NA
11 3 2 12
12 3 3 11
13 4 0 NA
14 4 1 12
15 4 2 12
16 4 3 NA
This is what works when I just need to fill any missing no matter the timepoint:
library(dplyr)
library(tidyr)
df <- df %>%
group_by(id) %>%
fill(`var9`:`var12`, .direction = "up") %>%
as.data.frame
But now I have trouble specifying to only fill in the missings in rows at timepoint 0. Any help is appreciated.
My expected output:
> df
id timepoint var1
1 1 0 9
2 1 1 9
3 1 2 8
4 1 3 10
5 2 0 10
6 2 1 10
7 2 2 NA
8 2 3 12
9 3 0 NA
10 3 1 NA
11 3 2 12
12 3 3 11
13 4 0 12
14 4 1 12
15 4 2 12
16 4 3 NA
This might be an oversimplification, but you can just call the fill function again, but this time with direction down. Then your entire data frame will be complete.
df <- data.frame(id=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4),
timepoint=c(0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3),
var1=c(NA,9,8,10, NA, 10, NA, 12, NA, NA, 12, 11, NA, 12, 12, NA))
In this case I will use an ifelse statement followed the by the lead function.
library(dplyr); library(tidyr);
df %>%
group_by(id) %>%
mutate(var1 = ifelse(is.na(var1) & timepoint == 0,
lead(var1, 1), var1))
Yields:
# A tibble: 16 x 3
# Groups: id [4]
id timepoint var1
<dbl> <dbl> <dbl>
1 1 0 9
2 1 1 9
3 1 2 8
4 1 3 10
5 2 0 10
6 2 1 10
7 2 2 NA
8 2 3 12
9 3 0 NA
10 3 1 NA
11 3 2 12
12 3 3 11
13 4 0 12
14 4 1 12
15 4 2 12
16 4 3 NA
We can group_by id and use replace to change the values where timepoint = 0 & var1 is NA from the corresponding value of var1 where timepoint = 1 in each group.
library(dplyr)
df %>%
group_by(id) %>%
mutate(var2 = replace(var1, timepoint == 0 & is.na(var1), var1[timepoint == 1]))
# id timepoint var1 var2
# <dbl> <dbl> <dbl> <dbl>
# 1 1 0 NA 9
# 2 1 1 9 9
# 3 1 2 8 8
# 4 1 3 10 10
# 5 2 0 NA 10
# 6 2 1 10 10
# 7 2 2 NA NA
# 8 2 3 12 12
# 9 3 0 NA NA
#10 3 1 NA NA
#11 3 2 12 12
#12 3 3 11 11
#13 4 0 NA 12
#14 4 1 12 12
#15 4 2 12 12
#16 4 3 NA NA

How to get all my values within the same categorie to be equal in my dataframe?

So, I have a dataset that looks just like that :
site year territories cat
1 10 2017 0.0 1
2 10 2016 NA NA
3 10 2015 2.0 1
4 10 2014 NA NA
5 10 2013 NA NA
6 11 2012 NA NA
7 11 2011 0.0 2
8 11 2010 NA NA
9 11 2009 1.0 2
But I do not want to have NAs in the cat column. Instead, I want every line within the same site to get the same value of cat.
Just like this :
site year territories cat
1 10 2017 0.0 1
2 10 2016 NA 1
3 10 2015 2.0 1
4 10 2014 NA 1
5 10 2013 NA 1
6 11 2012 NA 2
7 11 2011 0.0 2
8 11 2010 NA 2
9 11 2009 1.0 2
Any idea on how I can do that?
Use na.aggregate to fill in the NA values using ave to do it by site.
library(zoo)
transform(DF, cat = ave(cat, site, FUN = na.aggregate))
giving:
site year territories cat
1 10 2017 0 1
2 10 2016 NA 1
3 10 2015 2 1
4 10 2014 NA 1
5 10 2013 NA 1
6 11 2012 NA 2
7 11 2011 0 2
8 11 2010 NA 2
9 11 2009 1 2
Note
The input used, in reproducible form, is:
Lines <- "
site year territories cat
1 10 2017 0.0 1
2 10 2016 NA NA
3 10 2015 2.0 1
4 10 2014 NA NA
5 10 2013 NA NA
6 11 2012 NA NA
7 11 2011 0.0 2
8 11 2010 NA NA
9 11 2009 1.0 2"
DF <- read.table(text = Lines)
A complete base R alternative:
transform(DF, cat = ave(cat, site, FUN = function(x) x[!is.na(x)][1]))
which gives:
site year territories cat
1 10 2017 0 1
2 10 2016 NA 1
3 10 2015 2 1
4 10 2014 NA 1
5 10 2013 NA 1
6 11 2012 NA 2
7 11 2011 0 2
8 11 2010 NA 2
9 11 2009 1 2
The same logic implemented with dplyr:
library(dplyr)
DF %>%
group_by(site) %>%
mutate(cat = na.omit(cat)[1])
Or with na.locf of the zoo-package:
library(zoo)
transform(DF, cat = ave(cat, site, FUN = function(x) na.locf(na.locf(x, fromLast = TRUE, na.rm = FALSE))))
Or with fill from tidyr:
library(tidyr)
library(dplyr)
DF %>%
group_by(site) %>%
fill(cat) %>%
fill(cat, .direction = "up")
NOTE: I'm wondered what the added value is of the cat-column when cat has to be the same for each site. You'll end up with two grouping variables that do exactly the same, thus making one ot them redundant imo.
You can also use tidyr::fill
library(dplyr)
library(tidyr)
DF %>%
group_by(site) %>%
fill(cat,.direction = "up") %>%
fill(cat,.direction = "down") %>%
ungroup
# # A tibble: 9 x 4
# site year territories cat
# <int> <int> <dbl> <int>
# 1 10 2017 0 1
# 2 10 2016 NA 1
# 3 10 2015 2 1
# 4 10 2014 NA 1
# 5 10 2013 NA 1
# 6 11 2012 NA 2
# 7 11 2011 0 2
# 8 11 2010 NA 2
# 9 11 2009 1 2

R: assign previous non NA value 'n' times based on value in previous non NA row

I have a dataframe test_case. I have missing data in a column (income).
test_case <- data.frame(
person=c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3),
year=c(2010, 2011, 2012, 2010, 2011, 2012, 2010, 2011, 2013, 2014, 2014, 2014),
income=c(4, 10, 13, NA, NA, NA, 13, NA, NA, NA, NA, NA),
cutoff=c(0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0)
)
The variable cutoff specifies the number of times that I would like to 'carry forward' the values in income into subsequent rows (using the na.locf() method in the package zoo). For example, in the dataframe above, the value for 2 in cutoff indicates that income should be carried forward twice.
I have seen examples on SO about specifying how to use na.locf to carry forward n times when n is constant. But in my case, I am having trouble generalizing (R -- Carry last observation forward n times) when n is changing.
Here is my original dataframe:
person year income cutoff
1 1 2010 4 0
2 1 2011 10 0
3 1 2012 13 2
4 2 2010 NA 0
5 2 2011 NA 0
6 2 2012 NA 0
7 3 2010 13 3
8 3 2011 NA 0
9 3 2013 NA 0
10 3 2014 NA 0
11 3 2014 NA 0
12 3 2014 NA 0
And here is the desired output:
person year income cutoff
1 1 2010 4 0
2 1 2011 10 0
3 1 2012 13 2
4 2 2010 13 0
5 2 2011 13 0
6 2 2012 NA 0
7 3 2010 13 3
8 3 2011 13 0
9 3 2013 13 0
10 3 2014 13 0
11 3 2014 NA 0
12 3 2014 NA 0
Here's an attempt using data.table. The grouping method is at #jeremys answer, though I'm avoiding ifelse or lapply here, rather combining the first income value replicated according to first income value with NAs values replicate .N - (cutoff[1L] + 1L) times. I'm also operating only on the values since first time cutoff > 0L)
library(data.table)
setDT(test_case)[which.max(cutoff > 0L):.N, # Or `cutoff > 0L | is.na(income)`
income := c(rep(income[1L], cutoff[1L] + 1L), rep(NA, .N - (cutoff[1L] + 1L))),
by = cumsum(cutoff != 0L)]
test_case
# person year income cutoff
# 1: 1 2010 4 0
# 2: 1 2011 10 0
# 3: 1 2012 13 2
# 4: 2 2010 13 0
# 5: 2 2011 13 0
# 6: 2 2012 NA 0
# 7: 3 2010 13 3
# 8: 3 2011 13 0
# 9: 3 2013 13 0
# 10: 3 2014 13 0
# 11: 3 2014 NA 0
# 12: 3 2014 NA 0
Here's an answer using dplyr.
It works by grouping by the cumulative sum of different cutoffs.
Then it makes a list of one FALSE if cutoff is 0, and cutoff number of TRUEs, which is unlisted and sliced to the size of the group.
Then using ifelse, the income is either unmodified or made to be the first income (ie the cutoff one).
library(dplyr)
test_case %>% group_by(z = cumsum(cutoff != 0)) %>%
mutate(income = ifelse(unlist(lapply(cutoff, function(x) rep(as.logical(x), max(1,x + 1))))[1:n()], income[1], income))
Source: local data frame [12 x 5]
Groups: z [3]
z person year income cutoff
(int) (dbl) (dbl) (dbl) (dbl)
1 0 1 2010 4 0
2 0 1 2011 10 0
3 1 1 2012 13 2
4 1 2 2010 13 0
5 1 2 2011 13 0
6 1 2 2012 NA 0
7 2 3 2010 13 3
8 2 3 2011 13 0
9 2 3 2013 13 0
10 2 3 2014 13 0
11 2 3 2014 NA 0
12 2 3 2014 NA 0
A solution using na.locf could work in a similar way to #jeremycg's solution. We simply need to group by cumsum(cutoff != 0) and another variable which is the shifted row_number
My solution isn't as elegant as jeremycg's one, but this is how I approached it:
library(dplyr)
library(zoo)
test_case %>%
mutate(
rownum = row_number(),
cutoff2 = ifelse(cutoff == 0, NA, cutoff + rownum),
cutoff2 = na.locf(cutoff2, na.rm = FALSE),
cutoff2 = ifelse(rownum > cutoff2, NA, cutoff2)
) %>%
group_by(z = cumsum(cutoff != 0), cutoff2) %>%
mutate(income = na.locf(income, na.rm = FALSE))
# Source: local data frame [12 x 7]
# Groups: z, cutoff2 [5]
#
# person year income cutoff rownum cutoff2 z
# (dbl) (dbl) (dbl) (dbl) (int) (dbl) (int)
# 1 1 2010 4 0 1 NA 0
# 2 1 2011 10 0 2 NA 0
# 3 1 2012 13 2 3 5 1
# 4 2 2010 13 0 4 5 1
# 5 2 2011 13 0 5 5 1
# 6 2 2012 NA 0 6 NA 1
# 7 3 2010 13 3 7 10 2
# 8 3 2011 13 0 8 10 2
# 9 3 2013 13 0 9 10 2
# 10 3 2014 13 0 10 10 2
# 11 3 2014 NA 0 11 NA 2
# 12 3 2014 NA 0 12 NA 2

Resources