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
#Script to scrape NARS website | |
library(rvest) | |
library(dplyr) | |
nars <- read_html("https://www.epa.gov/national-aquatic-resource-surveys/data-national-aquatic-resource-surveys") | |
links <- nars %>% | |
html_nodes(".file-link, a") %>% | |
html_attr("href") %>% | |
tbl_df() %>% | |
filter(grepl("files",value)) %>% |
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
> devtools::test() | |
Loading tidytext | |
Testing tidytext | |
Corpus tidiers: .. | |
dictionary tidiers: | |
LDA tidiers: ................................. | |
Counting pairs: W.......W..W..WW... | |
Sparse casters: ................1 | |
Sparse tidiers: ...... | |
tf-idf calculation: ........... |
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
--- | |
title: "Untitled" | |
author: "Jeff W. Hollister" | |
date: "2/2/2016" | |
output: beamer_presentation | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = FALSE) |
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
library(shiny) | |
library(dplyr) | |
library(DT) | |
dat<-data.frame(letters=c(rep("A",15),rep("B",5),rep("C",5))) | |
server<-shinyServer(function(input, output) { | |
#Returns filtered data | |
output$dat_false <- renderDataTable(dat,filter = "top",server = FALSE) | |
#Returns just the currently (?) visible values in the mainPanel |
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
devtools::install_github("jhollist/quickmapr") | |
devtools::install_github("ropensci/spocc") | |
install.packages("rgeos") | |
library("quickmapr") | |
library("spocc") | |
library("rgeos") | |
library("magrittr") | |
data(lake) | |
## sp bbox to poly |
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
devtools::install_github('jhollist/quickmapr') | |
devtools::install_github('ropensci/spocc') | |
install.packages('rgeos') | |
library("quickmapr") | |
library("spocc") | |
library("rgeos") | |
data(lake) | |
## sp bbox to poly | |
bbox_to_sp <- function(sp) { |
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
#load libraries | |
library(jsonlite) | |
library(geojsonio) | |
library(sp) | |
library(lawn) | |
library(rgeos) | |
#create pt | |
pt<-minify('{ | |
"type": "Feature", |
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
extract_spatial<-function(in_spatial,over_poly=NULL,plot_result=FALSE){ | |
plot(in_spatial) | |
message("Select at least 3 points to define the extent") | |
coords<-locator() %>% | |
data.frame() | |
poly<-rbind(coords,coords[1,]) %>% | |
Polygon() %>% list() %>% | |
Polygons(ID=1) %>% list() %>% | |
SpatialPolygons(proj4string=CRS(proj4string(in_spatial))) | |
idx<-over(poly,in_spatial,returnList=TRUE) %>% unlist() |
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
word_count<-function(txt_doc){ | |
con<-file(txt_doc, "r", blocking=FALSE) | |
x<-readLines(con) | |
#Remove YAML front matter on Rmd | |
if(length(grep("---",x))>0){x<-x[-seq(1,max(grep("---",x)))]} | |
wrds<-0 | |
for(line in x){ | |
#Removes non character and splits | |
split_line<-strsplit(gsub("[^[:alnum:] ]", "", line), " +")[[1]] | |
#Removes empty string |
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
--- | |
name: bob | |
title: example collapse bug | |
date: today | |
--- | |
```{r} | |
#test of the collapse | |
``` |