This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data_filter <- filter(myData, | |
grepl('Search', field)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(v) | |
data_dir %>% | |
dir_ls(regexp = "\\.csv$") %>% | |
map_dfr(read_csv, .id = "source") %>% | |
mutate(Month_Year = myd(Month_Year, truncated = 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`r if(show.text){"la la la"}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
NewerOlder