Skip to content

Instantly share code, notes, and snippets.

View azadag's full-sized avatar

Azad Amir-Ghassemi azadag

  • Los Angeles
View GitHub Profile
read_csv ("test.csv", col_names=FALSE, col_types = cols(.default = "c", time = "i"))
# This should set the default type for all columns as character, while time would be parsed as integer.
data_filter <- filter(myData,
grepl('Search', field))
# devtools::install_github("tidyverse/googlesheets4")
library(googlesheets4)
library(here)
# library(dplyr)
data <- read_sheet("https://docs.google.com/spreadsheets/d/1AkYjbnLbWW83LTm6jcsRjg78hRVxWsSKQv1eSssDHSM/edit#gid=0")
# reads from: Reading from 'emergency_tenant_protections_current_do_not_edit_me'
data$lat[data$lat == "NULL"] <- NA
data$lon[data$lon == "NULL"] <- NA
library(tidyverse)
library(v)
data_dir %>%
dir_ls(regexp = "\\.csv$") %>%
map_dfr(read_csv, .id = "source") %>%
mutate(Month_Year = myd(Month_Year, truncated = 1))
@azadag
azadag / changeUnicodeToAsciiOfOhMyZshDefaultTheme.sh
Created September 11, 2018 05:35 — forked from ChaosJohn/changeUnicodeToAsciiOfOhMyZshDefaultTheme.sh
Fix "➜" and "✗" of oh-my-zsh default theme making the cursor position wrong under some terminals(such as Mosh Chrome App, Termius[Chrome App Version, Mac Version, Windows Version])
#!/bin/sh
DIR="$HOME/.oh-my-zsh/custom/themes"
mkdir -p $DIR
cd $DIR
sed "s/➜/→/g;s/✗/×/g" $HOME/.oh-my-zsh/themes/robbyrussell.zsh-theme > robbyrussell.zsh-theme
ggplot(data = storms, aes(x = pressure)) +
geom_density(fill = 'cyan', color = 'cyan') +
labs(title = 'The pressure variable is strongly left-skewed') +
theme(text = element_text(family = 'Gill Sans', color = "#444444")
,panel.background = element_rect(fill = '#444B5A')
,panel.grid.minor = element_line(color = '#4d5566')
,panel.grid.major = element_line(color = '#586174')
,plot.title = element_text(size = 24)
,axis.title = element_text(size = 18, color = '#555555')
,axis.title.y = element_text(vjust = .5, angle = 0)
empdataCA4 <- lapply(split(empdataCA3, empdataCA3$reg), function(x) {
x.Date <- (c(CurrentYear, CurrentYear + 1, CurrentYear + 2, CurrentYear + 3, CurrentYear +4 ,CurrentYear +5))
val <- as.ts(na.approx(zoo(x = c(x$Pct[1],NA,NA,NA,NA,x$Pct[2]), x.Date)))
val2 <-predict(td(val~1, to='quarterly', method='denton-cholette', conversion = "last"))
# change the options for interpolation as needed
data.frame(yearQtr= as.yearqtr(time(val2)), test=val2)})
df.dplyr <- as.data.frame(bind_rows(empdataCA4, .id = "groups"))
df.dplyr0 <- as.data.frame(stringr::str_split_fixed(df.dplyr$groups, "_", n=2))
@azadag
azadag / venn_pie_chart.r
Last active April 10, 2018 18:39 — forked from sterding/venn_pie_chart.r
R script to generate multi-layer pie chart (or called it venn pieagram) to visualize the NGS reads distribution in different annotation regions
## data input (number of reads mapped to each category)
total=100
rRNA=5 # mapped to nuclear rRNA regions
mtRNA=7 # mapped to mitochondria genome
# for the rest of above, then we divide into different category, like http://www.biomedcentral.com/1741-7007/8/149 did.
intergenic=48
introns=12
exons=30
upstream=3
downstream=6
@azadag
azadag / ipums_learn.r
Last active April 10, 2018 18:39
basic ipums summarisation examples
install.packages('data.table', 'dplyr', 'plyr')
library(dplyr)
data_acs <- data.table::fread("./data/usa_00035.csv")
data_acs <- tbl_df(data_acs)
## make an example age dummy variable
data_acs$AGE_VAR <- ifelse(data_acs$AGE < 15, 1, 0)
data_acs$AGE_VAR <- ifelse(data_acs$AGE >= 24 & data_acs$AGE <= 36 , 2, data_acs$AGE_VAR)
data_acs$AGE_VAR <- ifelse(data_acs$AGE > 36 & data_acs$AGE <= 51 , 3, data_acs$AGE_VAR)