Search
 
SCRIPT & CODE EXAMPLE
 

R

how to transform days in years R

The lubridate package contains a built-in function, time_length, which can help perform this task.

time_length(difftime(as.Date("2003-04-05"), as.Date("2001-01-01")), "years")
[1] 2.257534

time_length(difftime(as.Date("2017-03-01"), as.Date("2012-03-01")),"years")
[1] 5.00274
Comment

PREVIOUS NEXT
Code Example
R :: r convert list to comma separated string 
R :: how to convert all columns of a dataframe into factors in r 
R :: r convert matrix to list of column vectors 
R :: merge several data frames in r 
R :: create file in r 
R :: sort dataframe r 
R :: descending order a list in r 
R :: create a dataframe with column names in r 
R :: superscript in r 
R :: how to combine all columns into one column in r 
R :: replace na with 0 in r 
R :: export csv file in r 
R :: how to use ifelse in r 
R :: change all columns type in R 
R :: r extract top values from data frame 
R :: r remove inf values 
R :: r delete rowif number higher than 
R :: how to iterate through a list in r 
R :: extract attribute in r 
R :: find the number of times a variable is repeated in a vector r 
R :: alpha 2 codes in r 
R :: r performance matrix for confusion matrix 
R :: "R" multi-line comment 
R :: change the font of the title in a plot in r 
R :: how to change column names in r 
Rust :: bevy assets image as sprite 
Rust :: create empty string rust 
Rust :: rust array unique 
Rust :: armanriazi•rust•smartpointer•box 
Rust :: Rust Multithreading with a Vector of different functions 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =