``` {r eval = FALSE} library(data.table) library(ff) library(bit) library(dplyr) library(ggplot2) train_file <- "data/train.csv" test_file <- "data/test.csv"

Does expected vary within IDHour?
``` {r eval = FALSE}
#Get id hours collapsed by max and min expected
idhour <- fread(train_file, select = c("Id", "Expected")) %>% 
  group_by(Id) %>% 
  summarize(max_exp = max(Expected),
            min_exp = min(Expected))

#List of ids that vary within ID
idhour[idhour$min_exp != idhour$max_exp] #Length is 0, so no

What do we want to do with outliers? Do we set them to missing, or to the max? ``` {r eval = FALSE} ids <- unique(train[, "Id"]) s <- sample(ids, 10000) dat <- select_group(train, "Id", s, c("Id", "minutes_past", "Ref", "radardist_km", "Expected")) qplot(dat$Ref, dat$Expected, ylim = c(0,100)) #no real breaks.

Set Expected to NA

dat$ExpectedNA <- dat$Expected dat$ExpectedNA[dat$Expected>69] <- NA

Set Expected to predicted value

avgref <- group_by(dat, Id) %>% summarize(ref_mean = mean(time_difference(minutes_past) * interpolate(Ref), na.rm = T), ExpectedMP = mean(time_difference(minutes_past) * marshall_palmer(interpolate(Ref))), Expected = max(Expected), ExpectedNA = max(ExpectedNA), radardist = max(radardist_km))

lm_ex_dbz_dist <- lm(ExpectedNA ~ ref_mean + radardist, data = avgref[!is.na(avgref$ExpectedNA)]) avgref$ExpectedLM <- predict(lm_ex_dbz_dist, newdata = avgref[, c("ref_mean", "radardist")])

lm_ex_mm_dist <- lm(ExpectedNA ~ ExpectedMP + radardist, data = avgref[!is.na(avgref$ExpectedNA)]) avgref$ExpectedLM2 <- predict(lm_ex_mm_dist, newdata = avgref[, c("ExpectedMP", "radardist")])

Can we quickly load a sample of grouped ids?

Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The html_vignette output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The html_vignette format:

Vignette Info

Note the various macros within the vignette section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the title field and the \VignetteIndexEntry to match the title of your vignette.

Styles

The html_vignette template includes a basic CSS theme. To override this theme you can specify your own CSS in the document metadata as follows:

output: 
  rmarkdown::html_vignette:
    css: mystyles.css

Figures

The figure sizes have been customised so that you can easily put two images side-by-side.

plot(1:10)
plot(10:1)

You can enable figure captions by fig_caption: yes in YAML:

output:
  rmarkdown::html_vignette:
    fig_caption: yes

Then you can use the chunk option fig.cap = "Your figure caption." in knitr.

More Examples

You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using knitr::kable().

knitr::kable(head(mtcars, 10))

Also a quote using >:

"He who gives up [code] safety for [code] speed deserves neither." (via)



potterzot/kgRainPredictR documentation built on May 25, 2019, 11:24 a.m.