Im working on a project regarding information about movies including their release date.
My professor wants us to add a new column reflecting the decade the movies were released in (1980s, 1990s, 2000s, or 2010s). In the original spreadsheet, we have a "Release" column in the format %Y-%m-%d. I have already changed it from a factor to date using the command:
df$Release<-as.Date(df$Release, format = "%Y-%m-%d")
Now, again, he wants a new column with just the decade as stated earlier. This is where I hit a wall. We have not learned much in this class, so I attempted to do so using an if statement like so:
if(df$Release == "198"){
df$Decade<- "1980s"
}
While I'm aware this is wrong this is the idea I had. I have not learned enough to really do much else! Im hoping to find an efficient command where i can take care of all 4 different decades using the given dates.
Here is a snapshot I took of my df so it may make more sense for you all
https://i.stack.imgur.com/VEo6G.png
Thanks for any help!