I need to subtract a sequence of values from 0 to 20 from a data frame column.
In the example below I have daily temperatures and I need to create a sequence of columns with the subtractions.
temp <- c(26,27,28,30,32,27,28,29)
date <- as.Date(c('02-15-2021', '02-16-2021', '02-17-2021', '02-18-2021', '02-19-2021', '02-20-2021', '02-21-2021',
'02-22-2021'), "%m-%d-%Y")
A <- data.frame(date, temp)
head(A)
B = seq(0.5,20,0.5)
A$temp - B #I tried it
I want to subtract the values of each row from the temp column in sequence and generate columns with the results.
The result I expect is the following: