The problem is due to recycling of your vector stripping attributes. As I stated in my comment, use e.g. data$newdate <- data$Date1 - 10
to create the whole column without recycling the vector, thus retaining attributes such as Date
. Consider the illustrative toy example below:
# Simple vector with an attribute
x <- 1:3
attributes(x) <- list( att = "some attributes" )
x
#[1] 1 2 3
#attr(,"att")
#[1] "some attributes"
# Simple data.frame with 3 rows
df <- data.frame( a = 1:3 )
# New column using first element of vector with attributes
df$b <- x[1]
# It is recycled to correct number of rows and attributes are stripped
str(df$b)
# int [1:3] 1 1 1
# Without recycling attributes are retained
df$c <- x
str(df$c)
# atomic [1:3] 1 2 3
# - attr(*, "att")= chr "some attributes"
# But they all look the same...
df
# a b c
#1 1 1 1
#2 2 1 2
#3 3 1 3
And from your data..
attributes(data$Date1)
# $class
# [1] "Date"