This file contains hidden or 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
BEGIN {FS = "," | |
genus = "0"} | |
$1 ~ /[A-Z][a-z]/ {genus = $1} | |
{ | |
$2 = genus | |
printf "%s %s\n", $1, $2 | |
} |
This file contains hidden or 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
source("fn.incidence.R") | |
insect<-read.csv("insect.community.csv",sep=";") | |
brom<-read.csv("bromeliads.csv") | |
insect.pres <- insect | |
insect.pres[,3:27] <- as.numeric(insect.pres[,3:27]>0) | |
taxo.insect <- read.csv("Cardoso.insects.csv",sep=";") | |
insect.common <- commonize() | |
a.b <- sapply(1:dim(insect.common)[1],log.reg,simplify=FALSE) | |
a.b <- do.call(cbind,a.b) |
This file contains hidden or 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
BEGIN { | |
FS = "\t" | |
} | |
## should be possible to catch logs & other extras by finding unsplit lines | |
{ | |
n = split($2, lines, /[A-Z]'?[A-Z][A-Za-z'\[\] ]*:/, speaker) | |
if (n == 1) { | |
printf "%s\t%s\t%s\t%s\n", $1, 1, "extra", $2 |
This file contains hidden or 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
png(filename = "Figures/web.R.png", width = 28, height = 21, units = "cm", res = 100) | |
#plotweb(mat, text.rot = 55, col.high = NULL, col.low = NULL, low.lablength = 7, labsize = 2) | |
dev.off() |
This file contains hidden or 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(loggr) | |
library(assertr) | |
library(magrittr) | |
log_file("thelog.log") | |
mtcars %>% | |
insist(within_n_mads(2), mpg:qsec) %>% | |
something |
This file contains hidden or 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(rvest) | |
quartet <- html("https://en.wikipedia.org/wiki/Anscombe's_quartet") %>% | |
html_table() %>% | |
.[[2]] | |
for (i in 1:length(names(quartet))) { | |
if (is.na(names(quartet)[i])) { | |
names(quartet)[i] <- names(quartet)[i - 1] | |
} |
This file contains hidden or 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
make_plot <- function(mydata){ | |
qplot(Length, Freq, data=mydata) | |
} |
This file contains hidden or 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(rvest) | |
library(magrittr) | |
pubs <- read_html("http://www.scimagojr.com/countryrank.php") %>% | |
html_node(".tabla_datos") %>% | |
html_table(row.names = FALSE) | |
library(tidyr) | |
library(dplyr) |
This file contains hidden or 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(gapminder) | |
names(gapminder) %>% dput | |
div_mean <- function(x) x/mean(x) | |
myvarnames <- c("pop", "gdpPercap") | |
gapminder2 <- gapminder |
This file contains hidden or 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(pageviews) | |
library(dplyr) | |
library(ggplot2) | |
bowie <- article_pageviews(article = "David_Bowie", end = "2016011200") | |
since_dec <- bowie %>% | |
mutate(timestamp = lubridate::ymd_h(timestamp)) %>% | |
filter(timestamp > lubridate::ymd("2015-12-01")) |