3

I want to get the month name from the week number and year number:

date

Week    Year  
  52    2018
  20    2017
  47    2016
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
Hilary
  • 475
  • 3
  • 10

1 Answers1

6

We can paste Week day , week number and year together to convert it into Date and then use format to get the month name. Read ?strptime for formatting options

format(as.Date(paste(1, df$Week, df$Year), "%u %U %Y"), "%B")
#[1] "December" "May"      "November"

data

df <- structure(list(Week = c(52L, 20L, 47L), Year = 2018:2016), 
     class = "data.frame", row.names = c(NA, -3L))
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213