Skip to content

Instantly share code, notes, and snippets.

View rrodrigueznt's full-sized avatar
😁

Ricardo Rodríguez rrodrigueznt

😁
View GitHub Profile
@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:
#
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 / 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
---
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 / 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")
#
## 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')]
#
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)
year,origin,source,scope,amount
2012,public,compet,euun,18900
2012,public,compet,nati,492500
2012,public,compet,regi,80000
2013,public,compet,euun,97000
2013,public,compet,nati,721500
2013,public,compet,regi,914000
2014,public,compet,euun,108119
2014,public,compet,nati,963962
2014,public,compet,regi,149963
year,tnoa,top25,top10,top5,ncit20160610183600SCQ
2012,157,136,111,,4287
2013,198,157,116,,4832
2014,189,159,123,,2439
2015,144,114,59,,1357
2016,169,139,100,21,
2017,176,150,123,26,
**Social Sciences and Humanities
Barcelona Graduate School of Economics (Barcelona GSE)
Basque Centre on Cognition, Brain and Language (BCBL)
Centre for Monetary and Financial Studies (CEMFI)
Universidad Carlos III de Madrid - Departamento de Economía (ECO-UC3M)
**Maths, Experimental Sciences and Engineering
Barcelona Supercomputing Center - Centro Nacional de Supercomputación (BSC)
Basque Centre for Applied Mathematics (BCAM)
Catalan Institute of Nanoscience and Nanotechnology (ICN2)
High Energy Physics Institute at the Universitat Autònoma de Barcelona (IFAE - UAB)