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(dplyr) | |
library(tidyr) | |
library(stringr) | |
library(purrr) | |
survey <- data_frame(ID= factor(seq.int(1,6,1)), answers=c("a","b,c","d,e","c,d","b,c,e","e")) | |
#survey %>% | |
map(survey$answers,strsplit,",") |
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
# 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 | |
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
## UNTANGLE FUNCTION | |
# Luis D. Verde (www.liomys.mx) | |
#' Pull interspersed header data into own column | |
#' | |
#' @param dframe The tibble or data frame with the interspersed headers in the first column | |
#' @param matchstring the string to match to pull the header rows (quoted character) | |
#' @param newCol name for the new variable that will be added to the df (quoted char) | |
#' @return a tbl or df (depending on the input) with the interspersed headers in their own column | |
#' @export | |
#' |
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
# define function | |
# this code is just for fun and I do not have rights to the images on dogtime.com I just like dogs | |
ggpupBV <- function(ggplotObject,breedVector){ | |
# required packages | |
require(dplyr) | |
require(jpeg) | |
require(grid) | |
require(gridExtra) |
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
# 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) |
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
# 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) |
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(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"), |
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
# point overlap, LDVA | |
# load | |
library(sp) | |
library(dplyr) | |
library(ggplot2) | |
library(ggmap) | |
library(fields) | |
library(cowplot) | |
library(rgbif) | |
library(gridExtra) |
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(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())+ |
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
# mapping conservation research | |
#load libraries | |
library(geosphere) | |
library(dplyr) | |
library(StandardizeText) | |
library(ggmap) | |
library(maps) | |
library(rvest) | |
library(rworldmap) |