I am completely confused about the following. I wish to create a variable which contains a year - lets say 2014. If I do so and then look at its decimal places, it appears as 2013,9999999.
The original problem I face in another data set is that I have start years and end years of a program. I need to calculate the duration of the program (the difference). If I filter for programs with duration <3 years, I receive many programs which actually last for 3 years because of the decimal places.
Here is a code for a very simplified description of the problem:
library(readxl)
library(reshape2)
library(dplyr)
library(ggplot2)
library(magrittr)
library(tidyverse)
library(tibble)
library(plyr)
library(dplyr)
library(dbplyr)
library(gmodels)
library(data.table)
Name <- c("Jon", "Bill", "Maria", "Ben", "Tina")
Age <- c(23, 41, 32, 58, 26)
df <- data.frame(Name, Age)
df$ztvz <- 2014
df$ztvz_1000 <- df$ztvz*10000000000000000000000000000000000000
If you run the code, you will see that df$ztvz_1000 is actually 20139999999999998342820208640068204442626. Why is this the case?
If anybody has an answer to this, that would be really great. Thanks!