Skip to content

Instantly share code, notes, and snippets.

View full-sized avatar

Luis Verde Arregoitia luisDVA

View GitHub Profile
@luisDVA
luisDVA / sectionLengths.R
Last active August 28, 2015 20:57
download and plot section length data
View sectionLengths.R
#Package load
library(dplyr)
library(reshape2)
library(ggplot2)
library(devtools)
install_github('timcdlucas/palettetown')
library(palettetown)
# read the data directly from the repo
@luisDVA
luisDVA / ctreeGetData.r
Created July 28, 2015 00:43
plotting trees pt 1
View ctreeGetData.r
# Dependencies
if(!require(party)){
install.packages("party")
library(party)
}
if(!require(dplyr)){
install.packages("dplyr")
library(dplyr)
}
@luisDVA
luisDVA / ctreeCustomFuns.R
Created July 28, 2015 01:18
custom functions for plotting ctrees
View ctreeCustomFuns.R
# custom barplot function to alter the appearance of terminal nodes
# modified from code provided by Achim Zeileis to the R-help mailing list
# source the function and assign it as a grapcon_generator object
node_barplot2 <- function(ctreeobj,
col = "black",
fill = c("red", "white"),
beside = NULL,
ymax = NULL,
ylines = NULL,
widths = 1,
@luisDVA
luisDVA / mappingConservationResearch.R
Created October 10, 2015 21:04
code and link to data for mapping spatial patterns in conservation research
View mappingConservationResearch.R
# mapping conservation research
#load libraries
library(geosphere)
library(dplyr)
library(StandardizeText)
library(ggmap)
library(maps)
library(rvest)
library(rworldmap)
@luisDVA
luisDVA / newMammals.R
Created November 23, 2015 00:52
script for plotting mammal research data
View newMammals.R
library(ggplot2)
library(dplyr)
library(gridExtra)
library(rphylopic)
MammalDisc <- read.csv(file = "https://raw.githubusercontent.com/luisDVA/codeluis/master/mammalDiscoveries.csv",stringsAsFactors = FALSE)
# plot search results by order for all orders
ggplot(MammalDisc,aes(results,reorder(sp,descYear)))+
geom_point() + theme_minimal() + theme(axis.text.y = element_blank())+
@luisDVA
luisDVA / pointOverlap.R
Created September 19, 2016 12:08
functions and code for plotting examples of the O point proximity metric
View pointOverlap.R
# point overlap, LDVA
# load
library(sp)
library(dplyr)
library(ggplot2)
library(ggmap)
library(fields)
library(cowplot)
library(rgbif)
library(gridExtra)
@luisDVA
luisDVA / theme_Eiffel65
Created November 25, 2016 05:41
Da ba dee
View theme_Eiffel65
library(ggplot2)
dat <- data.frame(x=rnorm(20,4,2),y=rnorm(20,3,2))
theme_Eiffel65 <- function(base_size = 12, base_family = "") {
# modification to theme_grey
theme_grey(base_size = base_size, base_family = base_family) %+replace%
theme(
axis.text = element_text(size = rel(0.8),colour = "blue"),
axis.title = element_text(colour = "blue"),
View visualizandoDosVars.R
# crear tabla de datos
ventas <- data.frame(vend = LETTERS[sample(15,replace=F)],
artsVend = sample(9:70, 15, replace = T),
totalv = sample(300:7900, 15, replace=T))
# cargar paquetes adicionales (instalar primero si es necesario)
library(ggplot2)
devtools::install_github("hrbrmstr/ggalt")
devtools::install_github("hrbrmstr/hrbrthemes")
library(ggalt)
@luisDVA
luisDVA / ggpup.R
Last active April 17, 2017 04:55
place two random dog images next to a ggplot object
View ggpup.R
# define function
# this code is just for fun and I do not have rights to the images on dogtime.com I just like dogs
ggpup <- function(ggplotObject){
# required packages
require(dplyr)
require(jpeg)
require(grid)
require(gridExtra)
@luisDVA
luisDVA / expandSeries.R
Created June 27, 2017 21:12
vectorized fn to expand a series (consecutive IDs implied)
View expandSeries.R
# expanding a series, consecutive values
# by Filipe Chichorro, modified for vectors
expandSeries <- function(strStartEnd){
words<-strsplit(strStartEnd, " ")
if (length(words[[1]])== 1) return(strStartEnd)
else