Hi, I'm attempting to add a "Julian Day" column to a data frame.
Here is my code and the resulting data frame: vic.data <- read.table("C:/VIC/data/vic.data.csv", header=F) names(vic.data) <- c("year", "month", "day", "precip", "evap", "runoff", "baseflow", "Tsup", "SM1", "SM2", "SM3", "SWE") vic.data$temp.date <- as.Date(paste(vic.data$year, "/", vic.data$month, "/", vic.data$day, sep="")) vic.data$julian.day <- julian(vic.data$temp.date, origin = as.Date("1900-01-01"))[1] head(vic.data) year month day precip evap runoff baseflow Tsup SM1 SM2 SM3 SWE temp.date julian.day 1 1916 1 1 0.00 0.0789 0 0.5037 -15.9907 20.2285 63.4011 296.9437 214.7537 1916-01-01 5843 2 1916 1 2 0.00 0.1135 0 0.5030 -14.1946 20.1619 63.3425 296.5659 214.7009 1916-01-02 5843 3 1916 1 3 29.74 0.1584 0 0.5024 -11.1894 20.0998 63.2817 296.1864 244.0971 1916-01-03 5843 4 1916 1 4 11.37 0.2056 0 0.5017 -12.9745 20.0416 63.2194 295.8052 255.3145 1916-01-04 5843 5 1916 1 5 0.00 0.1467 0 0.5011 -15.1542 19.9866 63.1561 295.4224 255.2361 1916-01-05 5843 6 1916 1 6 0.00 0.0939 0 0.5004 -12.5409 19.9345 63.0922 295.0379 255.2084 1916-01-06 5843 As you can see, the "temp.date" column behaves as expected, but the "julian.day" column is populated with the Julian day value from 1/1/1916. Please help me out if you have some ideas. Thanks, Sean ************************* Sean Parks Ecologist | Geospatial Analyst Aldo Leopold Wilderness Research Institute Rocky Mountain Research Station (406) 542-4182 http://leopold.wilderness.net/ ************************* [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.