# Linear trend with "signficant" areas shaded with points
library(data.table)
library(ggplot2)
system.time({
regr <- geopotential[, FitLm(gh, date, se = TRUE), by = .(lon, lat)]
})
ggplot(regr[term != "(Intercept)"], aes(lon, lat)) +
geom_contour(aes(z = estimate, color = after_stat(level))) +
stat_subset(aes(subset = abs(estimate) > 2*std.error), size = 0.05)
# Using stats::lm() is much slower and with no names.
if (FALSE) {
system.time({
regr <- geopotential[, coef(lm(gh ~ date))[2], by = .(lon, lat)]
})
}
Run the code above in your browser using DataLab