View import an unexported function from another package
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
predict_lda <- function(...) | |
get('predict.lda', envir = asNamespace('MASS'), inherits = FALSE)(...) |
View use get to substiture function name
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
# what it was | |
{if({my_stat} == "avg") {dplyr::summarise(., stat = mean(var_agg, na.rm = TRUE)) %>% | |
dplyr::pull(stat) %>% formattable::comma(label_digits)} | |
else if({my_stat} == "max") {dplyr::summarise(., stat = max(var_agg, na.rm = TRUE)) %>% | |
dplyr::pull(stat) %>% formattable::comma(label_digits)} | |
else if({my_stat} == "min") {dplyr::summarise(., stat = min(var_agg, na.rm = TRUE)) | |
# what it can be | |
possible values of my_stat are renamed to so that `avg` is now `mean` |
View survival.bib
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
@Article{assel, | |
author = {Asselain, B. and Mould, R. F.}, | |
title = {Methodology of the {Cox} proportional hazards model}, | |
journal = {Journal of Oncology}, | |
year = {2010}, | |
volume = {60}, | |
number = {5}, | |
pages = {403--409}} | |
@Book{boxst, |
View mail_through_mailR
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(mailR) | |
sender <- "hello@mail.com" | |
recipient <- "m.p.kosinski@gmail.com" | |
send.mail(from = sender, | |
to = recipient, | |
subject = "Subject", | |
body = "Hello World!", | |
smtp = list(host.name = "smtp.gmail.com", port = 465, | |
user.name = "hello@gmail.com", | |
passwd = pwd, |
View polish stemming
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
download.file('https://github.com/MarcinKosinski/trigeR5/raw/master/dicts/polimorfologik-2.1.zip', destfile = 'poli.zip') | |
unzip('poli.zip', exdir = 'dicts') | |
library(data.table);library(dplyr) | |
polimorfologik <- fread('dicts/polimorfologik-2.1.txt', data.table = FALSE) %>% set_colnames(c('stem', 'words', 'random_stuff')) %>% select(1:2) | |
random_polish_text <- | |
'Wbrew wcześniejszym doniesieniom mediów, w bazie pod Latok I (szczyt w masywie w grupie Panmah Muztagh, części Karakorum), gdzie organizowana jest pomoc dla Aleksandra Gukowa (rosyjski himalaista nadał sygnał SOS i musi zostać ewakuowany, bo jest pozbawiony ekwipunku), nie ma też Andrzeja Bargiela. - Andrzej zgłosił chęć pomocy i wzięcia udziału w akcji ratunkowej. Jednak obecnie znajduje się w Skardu, gdzie dotarł wczoraj z bazy pod K2 - czytamy na twitterowym koncie pierwszego człowieka w historii, który zjechał z wierzchołka K2.' | |
(polish_stop_words <- readLines('https://raw.githubusercontent.com/MarcinKosinski/trigeR5/master/dicts/polish_stopwords. |
View generate_ids_from_csv
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
\documentclass[15pt]{scrartcl} | |
\usepackage[a6paper,left=1cm,right=1cm,top=2cm,bottom=1cm,heightrounded]{geometry} | |
\usepackage[svgnames]{xcolor} | |
\usepackage{pdflscape} | |
\usepackage{setspace} | |
\usepackage[utf8]{inputenc} | |
\usepackage[T1]{fontenc} | |
\usepackage{graphicx} | |
\usepackage{wallpaper} | |
\usepackage[normalem]{ulem} |
View add data.frame to CrunchDataset
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(dplyr);library(crunch) | |
iris_ds <- | |
newDataset(iris, name = 'iris') | |
# how to add the following data.frame as a CrunchCube or something similar to the Array? | |
iris_ds$some_statistics <- | |
iris %>% | |
group_by(Species) %>% | |
summarize_all(funs(mean)) |
View ggsurvplot_example.R
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
ggsurv <- ggsurvplot( | |
fit, # survfit object with calculated statistics. | |
data = BRCAOV.survInfo, # data used to fit survival curves. | |
risk.table = TRUE, # show risk table. | |
pval = TRUE, # show p-value of log-rank test. | |
conf.int = TRUE, # show confidence intervals | |
xlim = c(0,2000), # present narrower X axis, but not affect | |
# survival estimates. | |
xlab = "Time in days", # customize X axis label. | |
break.time.by = 500, # break X axis in time intervals by 500. |
View america_is_on_the_move.R
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(rgdal) # read and store spatial data | |
library(dplyr) # manipulate data frames for data wrangling | |
library(leaflet) # connect to LeafletJS library from R | |
library(magrittr) # pipe workflows | |
library(openxlsx) # read xlsx files | |
library(readxl) # read xls files | |
# prepare the data ------------------------------------------------------------ | |
# read MSA layer |
View provide_genomic_analysis_on_tcga_mutations_data.R
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
extractSurvival <- function(cohorts){ | |
survivalData <- list() | |
for(i in cohorts){ | |
get(paste0(i, ".clinical"), envir = .GlobalEnv) %>% | |
select(patient.bcr_patient_barcode, | |
patient.vital_status, | |
patient.days_to_last_followup, | |
patient.days_to_death ) %>% | |
mutate(bcr_patient_barcode = toupper(patient.bcr_patient_barcode), |
NewerOlder