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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
https://mycolor.space |
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
# adapted from: https://stackoverflow.com/questions/44077122/r-select-rows-with-non-na-values-in-at-least-one-of-the-four-columns | |
a<-c(NA,NA,NA,NA,2,5,4,3,NA,NA) | |
b<-c(NA,NA,NA,NA,2,3,4,5,NA,NA) | |
c<-c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA) | |
d<-c(1,4,3,1,2,4,3,2,1,NA) | |
df<-cbind(a,b,c,d) | |
df_atLeastOneNonMissingValue <- df[rowSums(is.na(df)) != ncol(df),] ## just to keep rows with at least one non-missing value | |
nrow(df) | |
nrow(df_atLeastOneNonMissingValue) |
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
## adapted from: https://stackoverflow.com/questions/22286419/move-a-column-to-first-position-in-a-data-frame | |
## see also: https://stackoverflow.com/questions/37171891/how-does-dplyrs-select-helper-function-everything-differ-from-copying | |
# create data.frame to illustrate | |
a<-1:5 | |
b<-a | |
c<-as.character(b) | |
df<-as.data.frame(cbind(a,b,c)) | |
# end create data.frame to illustrate | |
df |
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
## AUC expected versus AUC minimal | |
## sample size calculatino AUC | |
## we use formula 7.5 in http://dx.doi.org/10.1016/j.jbi.2014.02.013 | |
## Variance of AUC, following Appendix A (nonparametric AUC) | |
minimalAcceptableAUC<-0.7 | |
expectedAUC<-0.8 | |
ratioControlToCases<-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
##################################################################################################### | |
### This exercise should illustrate perfect agreement, random error and systematic error ### | |
##################################################################################################### | |
library(rio) | |
library(tidyverse) | |
library(ggplot2) | |
library(BlandAltmanLeh) | |
library(psych) | |
rnorm2 <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) } # this function is just to make it possible to fix the values or rnorm https://stackoverflow.com/questions/18919091/generate-random-numbers-with-fixed-mean-and-sd?lq=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
######################################### | |
### Example comments and labels ### | |
######################################### | |
## Hier lassen wir R nachschauen, ob die benötigten Packages installiert sind, falls nein: installieren wir sie. | |
list.of.packages <- c("Hmisc","janitor", "tidyverse", "rio") | |
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])] | |
if(length(new.packages)) install.packages(new.packages) | |
# update.packages(ask=TRUE) | |
## If you have a csv with variable labels on the second row and you want label the variables |
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
#### Remove all non-number #### | |
library(tidyverse) | |
library(readr) | |
numbers<-c(1,2,3,4,5,6,7,8,9,10,11) | |
numbers_with_some_characters<-c("1","2zwei","3","4vier","5","6 sechs","7","8 ", " 9", "1 0", " 1 1 ") | |
data_to_show_remove_nonnumbers<-data.frame(numbers, numbers_with_some_characters) |
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
list.of.packages <- c("summarytools") | |
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])] # https://stackoverflow.com/questions/4090169/elegant-way-to-check-for-missing-packages-and-install-them | |
if(length(new.packages)) install.packages(new.packages) | |
summarytools::freq(models$significant) # https://cran.r-project.org/web/packages/summarytools/vignettes/Introduction.html | |
gender<-c(rep("men",10), rep("women", 20), rep(NA,5)) |
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
# see http://theautomatic.net/2018/07/11/manipulate-files-r/#:~:text=Files%20can%20be%20deleted%20with,add%20the%20parameter%20recursive%20%3D%20TRUE. |
OlderNewer