Skip to content

Instantly share code, notes, and snippets.

View pecard's full-sized avatar

Paulo E. Cardoso pecard

  • www.bioinsight.pt
  • Lisbon
View GitHub Profile
@pecard
pecard / ggplot2.r
Created January 7, 2010 17:14 — forked from jlowin/ggplot2.r
#! Mapa distribuição de variáveis sobre maps do pack map - GGPLOT
library(ggplot2)
#extract reference data
mapcounties <- map_data("county")
mapstates <- map_data("state")
#merge data with ggplot county coordinates
mapcounties$county <- with(mapcounties , paste(region, subregion, sep = ","))
mergedata <- merge(mapcounties, unemp_data, by.x = "county", by.y = "counties")
#! Simulações de mortalidade de aves
#! Maria Dias e Paulo Eduardo Cardoso
setwd("C:/...")
visf<-read.table("visf.csv", sep=";", header=T) #tabela inicial, que tem os dias do ano em que foram feitas as prospecções, segundo cada um dos esquemas a analisar (MAp,MAs,MAm,Maq1 e Maq2); esta tabela tem também os valores de taxa de permanencia (r) associada a cada visita
load("txperm.fun")
######## 1. SIMULAÇÃO DE CENÁRIOS DE MORTALIDADE
### 1.1. criação de tabelas com diferentes cenários de mortalidade real; nrep: número de simulações para cada valor de mortalidade real
#! Cartografia de dados distribuição aves - LOOP GGPLOT
#! Paulo E. Cardoso
#! Código Cores Hexadecimais - Normas Strix
#! Verde claro (#7FC31C), Verde escuro (#292F19), Laranja (#FF7F00), Azul claro (#80CECF)
#! OBJECTOS IMPORTANTES
#! tabAtlasT - Sumario Abundancias totais das especies por Quadricula/Epoca/Area
#!== Packages necessários:
#! Modelying forest diversity using GAM
#! Paulo Eduardo Cardoso
require(RColorBrewer)
require(graphics)
require(mgcv)
library(maptools)
.trPaths <- paste(paste(Sys.getenv('APPDATA'), '\\Tinn-R\\tmp\\', sep=''),
c('', 'search.txt', 'objects.txt', 'file.r', 'selection.r', 'block.r',
'lines.r'), sep='')
#! Compositional Analysis
#! Paulo Eduardo Cardoso
library(adehabitat)
#! Análise Compana para matrizes lidas a partir do clipboard.
usado <- read.delim("clipboard", sep = "\t", dec = ".", header = T)
#! Remove linhas sem dados - NA
usado <- usado[!is.na(usado[1]),]
#! Constroi a matriz de disponiveis alterando os valores em dispo
dispo <- as.data.frame(cbind(rep(27.3,nrow(usado)),rep(19.8,nrow(usado)),rep(80.2,nrow(usado))))
#! Gráfico de Barras GGPLOT
#! Paulo Eduardo Cardoso
library(chron)
library(ggplot2)
horas <- read.table("clipboard",header=T)
horas <- strptime(as.character(horas[,1]),"%H:%M:%S")
horaH <- data.frame("Hora"=hours(horas))
horasdia <- data.frame("Hora"=c(0:23))
postsH <- as.data.frame(table(horaH))
postsDia <- merge(horasdia,postsH,by.x="Hora",by.y="horaH",all.x=T)
# Unsupervided Classification of Landsat images
# !UTIL http://bioinf.wehi.edu.au/marray/ibc2004/lab4/lab4.html
# !UTIL http://www.digital-geography.com/unsupervised-classification-of-a-landsat-image-in-r-the-whole-story-or-part-two/
# !UTIL http://www.jstatsoft.org/v15/i09/paper
# !UTIL http://cran.r-project.org/web/packages/e1071/e1071.pdf
# Packages
kpacks <- c('raster', 'sp', 'rgdal', 'cluster')
new.packs <- kpacks[!(kpacks %in% installed.packages()[,"Package"])]
if(length(new.packs)) install.packages(new.packs)
@pecard
pecard / getExif.R
Last active May 16, 2020 00:07
Get Metadata (EXIF) from Smartphone photos
# Paulo E. Cardoso 2020-05-15
# Read EXIF Metadata from Photos obtained with SmarthPhone
# Initial instructions ----------------------------------
# Download ExifTool executable from https://exiftool.org/ and
# unzip the exiftool(-k).exe to Rstudio Project root folder
# Download your fotos to (this case) data-raw folder
# Assuming .jpg image files
# Install packages ----------------------------------------
@pecard
pecard / gmb_forestloss.R
Created June 12, 2020 11:32
gnb forest loss with gfc v1.7
library(tidyverse)
library(lubridate)
library(forcats)
library(janitor)
library(ggplot2)
library(ggthemr)
ggthemr('grape')
# Read Tables ----
refs <- read_csv('path to reference wdpa csv file') %>%
@pecard
pecard / bird_vertical_profile.R
Last active February 20, 2021 11:13
Create bird vertical profile with data from ENRAM repository.
# Packages ----
library(bioRad)
library(rhdf5)
library(tidyverse)
library(lubridate)
library(zoo)
library(RColorBrewer)
library(patchwork)