Skip to content

Instantly share code, notes, and snippets.

View joaovissoci's full-sized avatar

Joao Ricardo N Vissoci joaovissoci

View GitHub Profile
@joaovissoci
joaovissoci / vim.md
Created December 2, 2016 05:51 — forked from joelbyler/vim.md
Vim cheat sheet

#Cursor movement

h - move left
j - move down
k - move up
l - move right
ctrl-b - page up
ctrl-f - page down
% - jump to matching brace

w - jump by start of words (punctuation considered words)

@joaovissoci
joaovissoci / r_analytical_template.R
Last active May 17, 2016 21:05
r_analytical_template.R
#################################################################
#IHD GEO EPI - BRAZIL
#################################################################
#
#
#
#
#
#################################################################
#SETTING ENVIRONMENT
@joaovissoci
joaovissoci / PCA.R
Created December 13, 2015 21:22
Principal component snippet
##############################################################
#PCA Score comparisons
#############################################################
# # Define the amout of factor to retain
#Group of functinos to determine the number os items to be extracted
#par(mfrow=c(2,2)) #Command to configure the plot area for the scree plot graph
#ev <- eigen(cor_data) # get eigenvalues - insert the data you want to calculate the scree plot for
#ev # Show eigend values
#ap <- parallel(subject=nrow(cor_data),var=ncol(cor_data),rep=100,cent=.05) #Calculate the acceleration factor
#summary(ap)
#######################################################
#MERGING TWO DATASETS IN R
#######################################################
data <- read.csv("")
data2 <- repmis::source_DropboxData(".csv","",sep = ",",header = TRUE)
total <- merge(data,data2,by=c("record_id"),all.x=TRUE)
write.csv(total,"/home/joao/Desktop/hotspot_epi_rwanda_data.csv")
@joaovissoci
joaovissoci / convert_lat_long.R
Created August 19, 2015 15:08
convert_lat_long.R
convert_latalong<-function(data$Surg_GPS_Lat2){
data$Surg_GPS_Lat2<-car::recode(data$Surg_GPS_Lat2,"''='NA.NA.NA.NA.NA'")
z <- sapply((strsplit(as.character(data$Surg_GPS_Lat2), "[°\\.]")), as.character)
z<-t(z)
z<-as.data.frame(z)
z[,1:4]<-sapply(z[,1:4], as.character)
z[,1:4]<-sapply(z[,1:4], as.numeric)
z[,5]<-car::recode(z[,5],"' N'='N';'N '='N';' S'='S';'S '='S'")
z[,6]<-as.numeric(as.character(paste(z[,3],z[,4],sep=".")))
lat<-z[,1] + z[,2]/60 + z[,6]/3600
@joaovissoci
joaovissoci / mapdist_template.R
Last active August 29, 2015 14:27
mapdist template {ggmap}
#########################################################
#TEMPLATE - MAPDIST
#########################################################
#Function in the ggmap package
library(ggmap)
#organizing data set
#it works with addresses, city names and numeric lat and long indicator
# wherw x = a data.frame with lat and long in columns
from <- c('houston', 'houston', 'dallas')
@joaovissoci
joaovissoci / rmarkdown_codes.Rmd
Created August 5, 2015 22:44
rmarkdown_codes.Rmd
```{r}
summary(cars$dist)
summary(cars$speed)
```
```{r, echo=FALSE}
summary(cars)
```
```{r, eval=FALSE}
@joaovissoci
joaovissoci / [R] install packages.R
Created July 29, 2015 20:44
[R] install packages
#Install all most used packages
install.packages("car")
install.packages("gdata")
install.packages("Hmisc")
install.packages("metafor")
install.packages("plyr")
install.packages("ggplot2")
install.packages("gridExtra")
install.packages("psych")
@joaovissoci
joaovissoci / template_gimp
Last active December 12, 2015 03:02
template_gimp
1. Instale o GIMP
2. Abra a Imagem nele
3, Va no Menu Imagem
4. Escolha a opcao Escalar Imagem
5. Em resolucao coloque 600 x 600
6. Vá em Layer e selecione Traansparency
7. Escolha Remove Alpha Chanel
8. Va no menu arquivo
9. Selecione Exportar
10. Na Janela que aparece clique em Escolha Tipo de Ficheiro (Por Extensáo)
@joaovissoci
joaovissoci / gist:c8f474bd7769d65b274e
Created January 13, 2015 02:49
ac1_agreement_statistics.R
# AC1 statistic for 2 raters special case
# table = k x k table which represents table(rater1,rater2), must have equal number of rows and columns
# N = population size which will be stick in standard error correction, N=Inf is no correction.
# conflev = Confidence Level associated with the confidence interval (0.95 is the default value)
AC1 <- function(table,conflev=0.95,N=Inf,print=TRUE){
if(dim(table)[1] != dim(table)[2]){
stop('The table should have the same number of rows and columns!')
}
n <- sum(table)