This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 'root' character string of directory to search | |
# 'file_typs' character vector of file types to search | |
# 'omit_blank' logical indicating of blank lines are counted | |
# 'recursive' logical indicating if all directories within 'root' are searched | |
# 'lns' logical indicating if lines are counted, use F for counting characters | |
# 'trace' logical for monitoring progress | |
file.lens <- function(root, file_typs, omit_blank = F, recursive = T, | |
lns = T, trace = T){ | |
require(reshape2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# packages to use | |
library(SWMPr) | |
library(httr) | |
library(XML) | |
library(foreach) | |
library(doParallel) | |
# names of files on server | |
files_s3 <- httr::GET('https://s3.amazonaws.com/swmpalldata/')$content | |
files_s3 <- rawToChar(files_s3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install the packages | |
install.packages('XML') | |
require(XML) | |
#get raw html for Lake Minnetonka | |
html.raw<-htmlTreeParse( | |
'http://www.dnr.state.mn.us/lakefind/showreport.html?downum=27013300', | |
useInternalNodes=T | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
catch.fun<-function(dows,fish.str,net.type='Trap',trace=T,clean=F){ | |
require(XML) | |
strt<-Sys.time() | |
#create object for output | |
fish.out<-data.frame(expand.grid(dows,fish.str),NA,NA) | |
names(fish.out)<-c('dows','fish','fish.val','result') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
catch.fun.v2<-function(dows,trace=T,rich.out=F){ | |
require(XML) | |
strt<-Sys.time() | |
#create object for output | |
fish.out<-vector('list',length(dows)) | |
names(fish.out)<-dows | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot.nnet<-function(mod.in,nid=T,all.out=T,all.in=T,wts.only=F,rel.rsc=5,circle.cex=5,node.labs=T, | |
line.stag=NULL,cex.val=1,alpha.val=1,circle.col='lightgrey',pos.col='black',neg.col='grey',...){ | |
require(scales) | |
#gets weights for neural network, output is list | |
#if rescaled argument is true, weights are returned but rescaled based on abs value | |
nnet.vals<-function(mod.in,nid,rel.rsc){ | |
library(scales) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shinyServer(function(input, output) { | |
myData <- reactive({ | |
read.csv(input$file$datapath) | |
}) | |
output$summary <- renderPrint({ | |
if (is.null(input$file)) { | |
return(cat('File not uploaded')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obs<-100 | |
x<-runif(obs,0,100) | |
y<-x^2+rnorm(obs,0,800) | |
require(scales) | |
#examples with span | |
par(mfrow=c(2,2),mar=c(4,4,0.5,0.5),family='serif') | |
span<-round(seq(0.5,0.1,length=4),2) | |
for(i in span){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mc.int<-function(mod.in,int=NULL,n=10000,int.base=0,plot=T,plot.pts=T, | |
plot.poly=T,cols=list('black','green','blue'),round.val=2,val=F){ | |
require(scales) | |
#variable names from model | |
if(is.null(mod.in$call$formula)){ | |
x.names<-colnames(eval(mod.in$call$x)) | |
y.names<-colnames(eval(mod.in$call$y)) | |
x.range<-range(eval(mod.in$call$x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!require(ggplot2) | !require(scales) | !require(gridExtra) | !require(shiny)) { | |
stop("This app requires the shiny, ggplot2, scales, and gridExtra packages. To install, run 'install.packages(\"name\")'.\n") | |
} | |
# Define server logic required to generate and plot a random distribution | |
shinyServer(function(input, output) { | |
output$intPlot <- renderPlot({ | |
require(ggplot2) | |
require(scales) |
OlderNewer