As discussed in the comments, this can be achieved by converting the entry into Date
format and extracting the year, for instance like this:
format(as.Date(df1$Date, format="%d/%m/%Y"),"%Y")
More Related Contents:
- r – How to find value with condition
- Boolean operators && and ||
- In R, how to get an object’s name after it is sent to a function?
- Formula with dynamic number of variables
- Plot multiple columns on the same graph in R [duplicate]
- Order a “mixed” vector (numbers with letters)
- Add ID column by group [duplicate]
- Unique rows, considering two columns, in R, without order
- Summarizing by subgroup percentage in R
- Collapsing rows where some are all NA, others are disjoint with some NAs
- dplyr: “Error in n(): function should not be called directly”
- What exactly is copy-on-modify semantics in R, and where is the canonical source?
- How to swap values between two columns
- Define and apply custom bins on a dataframe
- How to perform join over date ranges using data.table?
- Animated sorted bar chart with bars overtaking each other
- Creating grouped bar-plot of multi-column data in R
- detach all packages while working in R
- Assigning Dates to Fiscal Year
- Find the n most common values in a vector [duplicate]
- What is the meaning of the dollar sign “$” in R function()?
- Set NA to 0 in R
- Case-insensitive search of a list in R
- Directly creating dummy variable set in a sparse matrix in R
- Error: package or namespace load failed for ‘tidyverse’ in loadNamespace
- Create frequency tables for multiple factor columns in R
- R function not returning values
- How to prevent scientific notation in R? [duplicate]
- Reason behind speed of fread in data.table package in R
- Collapse all columns by an ID column [duplicate]