I have this data.frame:
df <- data.frame(id = rep(c("one", "two", "three"), each = 10), week.born = NA)
df$week.born[c(5,15,28)] <- c(23,19,24)
df
id week.born
1 one NA
2 one NA
3 one NA
4 one NA
5 one 23
6 one NA
7 one NA
8 one NA
9 one NA
10 one NA
11 two NA
12 two NA
13 two NA
14 two NA
15 two 19
16 two NA
17 two NA
18 two NA
19 two NA
20 two NA
21 three NA
22 three NA
23 three NA
24 three NA
25 three NA
26 three NA
27 three NA
28 three 24
29 three NA
30 three NA
For one
all week.born
values should be 23
.
For two
all week.born
values should be 19
.
For one
all week.born
values should be 24
.
Whats the best way to do this?