Skip to content

Instantly share code, notes, and snippets.

View rrodrigueznt's full-sized avatar
😁

Ricardo Rodríguez rrodrigueznt

😁
View GitHub Profile
mod = function(x) {if (x < 0) {mod <- x*(-1)} else {mod <- x}}
f = function(x) {f <- mod(x)/x}
x <- seq(-1,1,0.01)
x
y <- f(x)
y
plot(f,xlim = c(-1,1))
remove(x,y,f,mod)
#
## Filter, Piping and GREPL Using R DPLYR - An Intro
## http://neondataskills.org/R/GREPL-Filter-Piping-in-DPLYR-Using-R/
##
#
library(dplyr)
library(openxlsx)
#
IDISpublications[which((IDISpublications$yearPublication == 2017) && grepl("blocks",IDISpublications$title)),c('title')]
#
@rrodrigueznt
rrodrigueznt / GrammarOfGraphics.R
Created December 10, 2017 21:39
Grammar of Graphics learning
#
## Introduction to R
## by
#
## Grammar of Graphics
## https://ramnathv.github.io/pycon2014-r/visualize/ggplot2.html
#
data(tips, package = 'reshape2')
library(ggplot2)
qplot(total_bill, tip, data = tips, geom = "point")
ftp http://cran.es.r-project.org/src/contrib/XML_3.98-1.7.tar.gz
R CMD INSTALL XML_3.98-1.7.tar.gz
ftp http://www.rforge.net/Cairo/snapshot/Cairo_1.5-9.tar.gz
R CMD INSTALL Cairo_1.5-9.tar.gz
ftp http://www.rforge.net/Rserve/snapshot/Rserve_1.7-3.tar.gz
R CMD INSTALL Rserve_1.7-3.tar.gz
ftp http://www.rforge.net/FastRWeb/snapshot/FastRWeb_1.1-1.tar.gz
@rrodrigueznt
rrodrigueznt / CB4R.Graphs.Colors.ggplot2.Rmd
Last active June 9, 2017 06:43
CB4R > Graphics > Colors (ggplot2)
<!--
http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/
http://rpubs.com/rrodriguez/ggplot2_colors
http://www.springer.com/gp/book/9780387245447
-->
---
output: html_document
---
#
library(stringr)
#
language <- c('en','es','gl')
#
for (lan in language)
{
url <- paste("http://atriumkm.idisantiago.es/bin/get/XWQL/idisAreas?language=",lan,"&outputSyntax=plain",sep = '')
assign(paste("IDISareas",str_to_title(lan),sep = ''), read.table(url, header = TRUE, sep = ';', encoding = 'UTF-8', row.names = NULL))
}
@rrodrigueznt
rrodrigueznt / IDIS.reshapingExcel.R
Last active May 26, 2017 12:01
Generates adjacency matrices and graphs
############################################
### Reshaping data from IDIS Excel files ###
############################################
# This Gist arranges Excel format in a suitable way for creating matrices, adjacency matrices, etc
# Based on a Gist recently created by Aurora Baluja
# The example uses an excerpt from a real database belonging to the Health Research Institute of Santiago de Compostela
# https://gist.github.com/aurora-mareviv/5572111#file-gistfile1-r
# First, let's access the datasheet data stored in a remote repository: