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} | |
library(tictoc) | |
library(splithalf) | |
library(splithalfr) | |
``` | |
```{r} | |
tic() | |
data("ds_vpt", package = "splithalfr") |
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
diffScoreVarDecomp <- function(cA_m1, cB_m1, cA_m2, cB_m2, plot = "both", measurename = "x") { | |
# calculations are heavily based on the irr's package icc() code: | |
# bind the four vectors first for row-wise deletion: | |
alldat <- as.matrix(na.omit(cbind(cA_m1, cB_m1, cA_m2, cB_m2))) | |
alldat <- cbind(alldat, "ds1" = alldat[,"cA_m1"] - alldat[,"cB_m1"], "ds2" = alldat[,"cA_m2"] - alldat[,"cB_m2"]) |
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
s1 <- round(rnorm(20, 600, 150)) | |
s2a <- s1 + round(rnorm(20, 0, 80)) | |
s2c <- s1 + 250 | |
id <- seq(1:20) | |
iccdf <- as.data.frame(cbind(id, s1, s2a, s2c)) | |
require(reshape2) | |
pldf <- melt(iccdf, id.vars = "id" ) |
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
--- | |
title: "search pubmed and download pdfs" | |
output: html_notebook | |
--- | |
store this rmd file in a folder | |
in the same folder also create a subfolder called 'pdfs' | |
```{r search pubmed and store search query in D} | |
library(RISmed) |
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
# essentially same as before but now restructured into a function: getCitingPMIDs() | |
getCitingPMIDs <- function(PMID) { | |
lines <- readLines(paste0("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?dbfrom=pubmed&linkname=pubmed_pubmed_citedin&id=", PMID)) # construct quering URL using the PMID parameter in resTargetRecord, and fetch its contents into object lines | |
citingPMIDs <- sub("^.*(<Id>)(.*)(</Id>)", "\\2", lines[grep("<Id>", lines)]) # filter out lines in lines that contain <Id> and then filter out the content between <Id> and </Id>.Store in object citingPMIDs | |
citingPMIDs <- citingPMIDs[-1] # remove first entry in citingPMIDs, which is the target record | |
return(citingPMIDs) | |
} |
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
#Project for if I ever get bored... a function that can be used at the top of a complex rmd file to list al chunks and their starting lines. | |
# I called out about this on twitter and someone referred me to the namer package, from which I initially stole a lot of code (specifically, most of this file: https://github.com/lockedata/namer/blob/master/R/utils.R). Twitter thread here: https://twitter.com/t_awkr/status/1082320989717958657 | |
# a few months later I dramatically simplified the code, assessing only the name and startline for each chunk: | |
get_chunk_info <- function(){ | |
lines <- readLines(rstudioapi::getActiveDocumentContext()$path) # read the current active document - notice that this reads the document as saved | |
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
# AWs corrtable function: i wanted a function that presents correlation tables in a reasonably nice but plain format that is sufficiently reminiscent of SPSS & APA style tables to use as the default correlation presentation style when sharing things in collaborations with colleagues who might not be used to R much. The kind of graphical correlation thingies that many R packages provide are awesome but also a tad intimidating :) | |
# x -> dataframe to correlate | |
# adjust -> adjust parameter for the corr.test function. From corr.test documentation: "What adjustment for multiple tests should be used? ("holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"). See p.adjust for details")." | |
# footert -> text for the footer. If not defined the default footer text is: "note: * p <.05, ** p <.01, *** p <.001" . | |
# captiont -> text for the caption. If not defined the default caption text is: "correlation table" . |
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 is a Shiny web application incorporating a D3 graph, called with R2D3(). | |
# You can run the application by clicking the 'Run App' button above. | |
# | |
# Find out more about building applications with Shiny here: | |
# | |
# http://shiny.rstudio.com/ | |
# | |
# Find out more about R2D3 here: | |
# |
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
# just code - for function version, see below | |
i_max <- 10000 | |
l_seq <- 5 | |
v_min <- 0 | |
v_max <- 480 | |
d_min <- 75 | |
r <- rep(NA, l_seq) |
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
JT_RCC <- function(x.pre, x.post, norm.M = NA, norm.SD = NA, RC.crit ="auto", reliability, ppid, plot = T, plottype = "JT", higherIsBetter = F) { | |
SEmeasurement <- sd(x.pre) * sqrt(1-reliability) # standard error of measurement based on the sd of the pre measurement/baseline | |
Sdiff<- sqrt(2*SEmeasurement^2) # the SD of the SEm for a difference score | |
# determine the criterion to determine recovery: | |
### C is preferred, followed by B, then A.. | |
NewerOlder