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
with() | |
within() | |
round(x, n) # rounds x to n decimal places | |
ceiling(x) # vector x of smallest integers > x | |
floor(x) # vector x of largest interger < x | |
as.integer(x) # truncates real x to integers (compare to round(x, 0) | |
as.integer(x < cutpoint) # vector x of 0 if less than cutpoint, 1 if greater than cutpoint) |
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 : InstallPackages.R; | |
# purpose : install R packages commonly used by Adam H.Sparks when upgrading or installing R; | |
# producer : prepared by A. H. Sparks; | |
# last update : in Los Baños, Laguna, PHL, May 2015; | |
# inputs : none; | |
# outputs : none; | |
# remarks 1 : in order to download any packages, you need to be on-line, of course; | |
# remarks 2 : for country outlines and the like see http://www.gadm.org/ to download Rdata packages; | |
############################################################################## |
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(RSelenium) | |
library(rvest) | |
#start RSelenium | |
checkForServer() | |
startServer() | |
remDr <- remoteDriver() | |
remDr$open() | |
#navigate to your page | |
remDr$navigate("http://www.linio.com.pe/celulares-telefonia-y-gps/") |
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 | |
install.packages('ggplot2') | |
install.packages('readr') | |
# load | |
library(ggplot2) | |
library(readr) | |
# Scatter Plot | |
p <- ggplot(mtcars) + |
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
clean_headers = function(headers) { | |
# Make lowercase | |
headers = tolower(headers) | |
# Replace symbols | |
headers = gsub(' ', '', headers, fixed = TRUE) | |
headers = gsub('.', '_', headers, fixed = TRUE) | |
headers = gsub('[^[:alnum:]_]', '', headers) # remove all symbols except '_' |
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(devtools) | |
## source_gist(7489113) | |
## use like this: ggplot(mtcars, aes(x=hp, y=mpg)) + geom_point(aes(col=factor(cyl)), size=3) + t1 | |
t1 <- theme( | |
plot.background = element_blank(), | |
panel.grid.major = element_blank(), | |
panel.grid.minor = element_blank(), | |
panel.border = element_blank(), | |
panel.background = element_blank(), |
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
lookfor <- function(data, | |
keywords = "weight|sample", | |
labels = TRUE, | |
ignore.case = TRUE) { | |
# search scope | |
n <- names(data) | |
if(!length(n)) stop("there are no names to search in that object") | |
# search function | |
look <- function(x) { grep(paste(keywords, collapse="|"), x, ignore.case = ignore.case) } | |
# names search |
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
# Ativando o módulo de séries temporais | |
library(tseries) | |
serie<-read.ts("telesp.txt", header = FALSE, sep = "", skip = 0) | |
# Gráfico da serie | |
ts.plot(serie) |
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
#!/bin/bash | |
# Quick and dirty geocoding with Google Maps API | |
MAPSAPIURL="http://maps.googleapis.com/maps/api/geocode/json" | |
[ -f latlng.txt ] && rm latlng.txt | |
[ -f results.json ] && rm results.json | |
while read line; do | |
# Get address from column 3 and 4 of a CSV file provided as argument and prepare the string address. YMMV. |
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
shift + 3(del teclado no numérico) = busca la palabra donde está enfocado el cursor | |
:edit! = para refrescar un archivo actual para verificar si tiene cambios de otro. | |
¿ zz = para guardar y salir directamente ? | |
//// pestañas | |
:tabe = crea una nueva pestaña vacía | |
:tab sp {file} = crea un clon del archivo en una nueva pestaña | |
:tabe = crea un clon del archivo en una nueva pestaña |