I have am struggling using dates in R. I got to set it using as.Date, but then I automatically get the current year even if I did not specify it. How can I remove the year from Date?
xy <- matrix(c("09/08", "10/14", "10/06",
"05/11", "02/23", "10/27",
"08/04", "11/29", "07/23",
"12/17"), byrow=TRUE)
names <- matrix(c("G", "C", "R", "OB", "S", "B", "Ms", "Mi", "Ma", "A"), byrow=T)
I then do the cbind, give some names and turn it into a df
names_birthday <- cbind(names, xy)
colnames(names_birthday) <- c("Name", "Date")
names_birthday <- as.data.frame(names_birthday)
But then when using as.Date and specifying that I'm using months and days, I get a '2021' out from nowhere:
names_birthday <- names_birthday %>%
group_by(Name) %>%
mutate(Date=as.Date(Date, format = "%m/%d")) %>%
arrange(Date)
names_birthday
# A tibble: 10 x 2
# Groups: Name [10]
Name Date
<chr> <date>
1 S 2021-02-23
2 OB 2021-05-11
3 Ma 2021-07-23
4 Ms 2021-08-04
5 G 2021-09-08
6 R 2021-10-06
7 C 2021-10-14
8 B 2021-10-27
9 Mi 2021-11-29
10 A 2021-12-17
Any ideas?