Skip to content

Instantly share code, notes, and snippets.

View sbalci's full-sized avatar
πŸ”¬
πŸ”¬πŸ‘€πŸ“‘πŸ—ƒπŸ“ŠπŸ¨πŸ—„πŸ“‡πŸ“–βš—πŸ“πŸŽΆπŸ“ˆπŸ“‰πŸ“ƒπŸ–πŸ”¬πŸ”¬πŸ‹πŸ»β€β™‚πŸš΄πŸ»β€β™‚πŸš™πŸ‘¨β€πŸ’»πŸ€·β€β™‚πŸ“ΈπŸ“ΊπŸŽ›πŸ”­πŸ”¬πŸ’ŠπŸ”πŸ«πŸŒΈ

Serdar BalcΔ± sbalci

πŸ”¬
πŸ”¬πŸ‘€πŸ“‘πŸ—ƒπŸ“ŠπŸ¨πŸ—„πŸ“‡πŸ“–βš—πŸ“πŸŽΆπŸ“ˆπŸ“‰πŸ“ƒπŸ–πŸ”¬πŸ”¬πŸ‹πŸ»β€β™‚πŸš΄πŸ»β€β™‚πŸš™πŸ‘¨β€πŸ’»πŸ€·β€β™‚πŸ“ΈπŸ“ΊπŸŽ›πŸ”­πŸ”¬πŸ’ŠπŸ”πŸ«πŸŒΈ
View GitHub Profile
# =======================================
# = Enhancements to data tidying =
# = Hadley Wickham =
# = https://rstd.io/tidyhancements-2019 =
# =======================================
# What is tidy data? ----------------------------------------------------------
# 1. Each column is a variable.
# 2. Each row is an observation.
# 3. Each cell is a value.
@sbalci
sbalci / get_coursera_videos.sh
Created August 18, 2019 19:10
Download Coursera Videos
git clone https://github.com/coursera-dl/coursera-dl
cd coursera-dl
pip3 install -r requirements.txt
./coursera-dl -u <Email-id> -p <Password> --subtitle-language en raspberry-pi-interface
@sbalci
sbalci / ttttable.R
Created September 30, 2019 17:23 — forked from leeper/ttttable.R
Grammar of Tables?
# ttable: a grammar of tables
# https://gist.github.com/leeper/f9cfbe6bd185763762e126a4d8d7c286
# aggregate/summarize
# arrange
# annotation (metadata features)
# theme
@sbalci
sbalci / rename-jpg-files.r
Created October 29, 2019 10:08 — forked from summerofgeorge/rename-jpg-files.r
Rename all jpg files in a folder
# List the jpg files in the folder
old_files <- list.files("C:/ImageTest", pattern = "*.JPG", full.names = TRUE)
old_files
# Create vector of new files
new_files <- paste0("C:/NewFiles/file_",1:length(old_files),".JPG")
new_files
# https://docs.ropensci.org/charlatan/articles/charlatan.html
# https://github.com/trinker/wakefield
# cat(wakefield::variables(), sep = ",\n")
fakedata <-
wakefield::r_data_frame(
n = 250,
id,
library(survival)
km_fit <- survfit(Surv(time, status) ~ sex, data = lung)
km_fit_summary <- summary(km_fit, times = c(0.5, 1, 2), scale = 365.25)
km_fit_df <- as.data.frame(km_fit_summary[c("strata", "time", "n.risk", "n.event", "surv", "std.err", "lower", "upper")])
km_fit_df %>%
@sbalci
sbalci / 00.README.md
Created November 12, 2019 16:18 — forked from rmoff/00.README.md
RMarkdown - repeating child block with changing variable value

When you use knit_expand it appears that the inclusion of the Rmd is done on the first pass, and then the complete document evaluated. This means that a Rmd block referenced in loop with knit_expand will only evaluate changing variables at their last value.

This can be worked around by passing the literal value of the variable at the time of the knit_expand with {{var}} syntax.

This is documented in the knitr_expand docs, but less clear (to an R noob like me) for embedded documents rather than strings.

# Find Packages Used in a Project Using Regular Expressions RegEx
list_of_Rmd_R <- c(
list.files(path = here::here(),
pattern = "\\.Rmd|.R$", # find files ending with .Rmd and .R
full.names = TRUE
),
list.files(path = here::here("childRmd"),
pattern = "\\.Rmd|.R$",

How to use Gephi to visualize from Wikidata

I'm a long-time fan of the graph visualization tool Gephi and since Wikimania 2019 I got involved with Wikidata. I was aware of the Gephi plugin "Semantic Web Importer", but when I check it out, I only find old tutorials connecting to DBpedia, not Wikidata:

simple_roc <- function(labels, scores){
labels <- labels[order(scores, decreasing=TRUE)]
data.frame(TPR=cumsum(labels)/sum(labels), FPR=cumsum(!labels)/sum(!labels), labels)
}