I am an beginner in R and don`t find a solution for the following problem. Any help would be really appreciated!
I have a data.frame and want to replace certain valu
When you want to extract the year from the date, you can do this with the following line of code:
dataframe$year <- substr(dataframe$date,1,4)
When you want assign a class to the new variable simulataniously:
dataframe$year <- as.integer(substr(dataframe$date,1,4))