I have a data frame with 10 years of daily temperature data. I want to convert all the values to Celsius. So I have 3.653 columns and 500 rows.
A sample of my data looks like below:
Location_ID day1_2010 day2_2010 day3_2010 day4_2010 ------------------------------------------------------------------ 1345 301 302 345 320 2375 305 302 345 320 3126 311 299 305 320
Just subtract from all columns but the ID column 273.15.
DF[-1] <- DF[-1] - 273.15
DF
# Location_ID day1_2010 day2_2010 day3_2010 day4_2010
# 1 1345 27.85 28.85 71.85 46.85
# 2 2375 31.85 28.85 71.85 46.85
# 3 3126 37.85 25.85 31.85 46.85
Data
DF <- structure(list(Location_ID = c(1345L, 2375L, 3126L), day1_2010 = c(301L,
305L, 311L), day2_2010 = c(302L, 302L, 299L), day3_2010 = c(345L,
345L, 305L), day4_2010 = c(320L, 320L, 320L)), class = "data.frame", row.names = c(NA,
-3L))