Start Rstudio Create Project Create a Data Directory and Rscript
Explain:
- diff btw console and script
+
sign means waiting for more input
library(Tides) | |
#generate date time sequence for 6 sec frequency series | |
dt<-read.table("clipboard",header=FALSE,colClasses=c("character","character","numeric","numeric"),col.names=c("Date","Time","wlev","stage")) | |
dt$DateTime<-as.POSIXct(paste(dt$Date,dt$Time),format="%Y%j %H%M") | |
dt2<-data.frame(dt$DateTime,dt$stage) | |
names(dt2)<-c("time","h") | |
dt2<-dt2[complete.cases(dt2),] | |
TidalCharacteristics(dt2,0.4,dtMax=1680) |
library(shiny) | |
library(maps) | |
library(maptools) | |
library(ggplot2) | |
library(plyr) | |
library(XML) | |
# Define server logic required to plot various variables against mpg | |
shinyServer(function(input, output, session) { | |
1 + 1 | |
# assign b to 2 | |
b <- 2 | |
a <- 3 | |
b <- a | |
a <- 6 | |
# exploring sqrt function | |
b <- 4 |
# work-through of https://github.com/USGS-R/mda.lakes/issues/91 | |
set.seed(443) | |
trend = 0.04 #in units per year, kinda like wtemp | |
freq = 26 #sample freq | |
year = (1:(30*freq)/freq) | |
yobs = 10*sin(year*2*pi)+ 10 + trend*year + rnorm(length(year), sd=0) | |
ymod = 10*sin(year*2*pi) + 10 + (trend*max(year)/2) |
lagpad <- function(x, k) { | |
c(rep(NA, k), x)[1 : length(x)] | |
} | |
level_pool_routing <- function(lt, qh, area, delta_t, initial_outflow, initial_storage, linear.fit){ | |
lt$ii <- apply(cbind(lagpad(lt$inflow, 1), lt$inflow), 1, sum) | |
if(is.null(qh$storage)){ | |
qh$storage <- area * qh$elevation |
library(WikipediR) | |
library(rvest) | |
get_lake_wiki <- function(lake_name){ | |
res <- WikipediR::page_content("en", "wikipedia", page_name = lake_name, | |
as_wikitext = FALSE) | |
res <- res$parse$text[[1]] | |
res <- xml2::read_html(res) | |
res <- rvest::html_nodes(res, "table") |
# http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0081457 | |
library(fulltext) | |
library(alm) | |
query <- ft_search(query = "Estimating Summer Nutrient Concentrations in | |
Northeastern Lakes from SPARROW Load Predictions and Modeled | |
Lake Depth and Volume", from = "plos") | |
doi <- ft_links(query)$plos$ids | |
alm_ids(doi = doi, info = "detail")$data$info$title |
# https://www.reddit.com/r/mildlyinteresting/comments/5k4eqd/the_first_100_positive_integers_in_alphabetical | |
# https://imgur.com/Ylmw8K6 | |
source("https://raw.githubusercontent.com/ateucher/useful_code/master/R/numbers2words.r") | |
dt <- numbers2words(1:100) | |
dt <- order(dt) | |
dt <- matrix(dt, nrow = 10, byrow = TRUE) | |
knitr::kable(data.frame(dt), caption = "The first one hundred natural numbers in alphabetical order") |
# need to apt-get: | |
# * libdvdcsss2 | |
# * handbrake-cli | |
handbrake_scan <- function(source){ | |
cli <- paste0("HandBrakeCLI -i ", source, " --scan") | |
system(cli) | |
} | |
handbrake_scan("/media/user/disc") |