-
Single-line comments are started with
//
. Multi-line comments are started with/*
and ended with*/
. -
C# uses braces (
{
and}
) instead of indentation to organize code into blocks. If a block is a single line, the braces can be omitted. For example,
This file contains hidden or 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
if(!require(ggplot2)){install.packages('ggplot2')} | |
library(ggplot2) | |
n=20 #set sample size | |
nSims<-100000 #set number of simulations | |
x<-rnorm(n = n, mean = 100, sd = 15) #create sample from normal distribution | |
#95%CI | |
CIU<-mean(x)+qt(0.975, df = n-1)*sd(x)*sqrt(1/n) |
This file contains hidden or 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
require(ggplot2) | |
#Save downloaded Scopus data in your working directory | |
scopusdata<-read.csv("scopusPS2010_2015.csv") | |
plot1<-ggplot(scopusdata, aes(x=Cited.by)) + | |
geom_histogram(colour="#535353", fill="#84D5F0", binwidth=2) + | |
xlab("Number of Citations") + ylab("Number of Articles") + | |
ggtitle("Citation Data for Psychological Science 2011-2015") + | |
coord_cartesian(xlim = c(-5, 250)) |
This file contains hidden or 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
#Script based on Carter & McCullough (2014) doi: 10.3389/fpsyg.2014.00823 | |
#Load Libraries | |
library(meta) | |
library(metafor) | |
#Insert effect sizes and sample sizes | |
es.d<-c(0.38,0.41,-0.14,0.63,0.22) | |
n1<-c(75,48,22,18,60) | |
n2<-c(75,52,21,20,55) |
This file contains hidden or 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
if(!require(meta)){install.packages('meta')} | |
library(meta) | |
nSims <- 1000000 #number of simulated experiments | |
numberstudies<-4 # nSim/numberofstudies should be whole number | |
p <-numeric(nSims) #set up empty container for all simulated p-values | |
metapran <-numeric(nSims/numberstudies) #set up empty container for all simulated p-values for random effects MA | |
metapfix <-numeric(nSims/numberstudies) #set up empty container for all simulated p-values for fixed effects MA | |
heterog.p<-numeric(nSims/numberstudies) #set up empty container for test for heterogeneity | |
d <-numeric(nSims) #set up empty container for all simulated d's |
This file contains hidden or 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
options(scipen=999) #disable scientific notation for numbers | |
#Figure 1 & 2 (set to N <- 5000 for Figure 2) | |
# Set x-axis upper and lower scalepoint (to do: automate) | |
low_x<--1 | |
high_x<-1 | |
y_max<-2 | |
#Set sample size per group and effect size d (assumes equal sample sizes per group) | |
N<-50 #sample size per group for indepndent t-test |
This file contains hidden or 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
#Load packages | |
library(readxl) | |
library(mailR) | |
#Read student data | |
info <- read_excel("student_names_email.xls", | |
sheet = 1, | |
col_names = TRUE) | |
#Loop from 1 to the number of email addresses in the spreadsheet |
This file contains hidden or 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
## meta analysis, sample size based | |
metaZn = function(zdisc,zrepl,ndisc,nrepl) | |
{ | |
## calculate meta analysis Zscore | |
## zdisc and zrepl are zscores in the discovery and replication sets respectively | |
## ndisc and nrepl are sample sizes in the discovery and replication sets | |
wdisc = sqrt(ndisc) | |
wrepl = sqrt(nrepl) | |
( zdisc * wdisc + zrepl * wrepl )/sqrt( wdisc^2 + wrepl^2 ) | |
} |
This file contains hidden or 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
# Load the raw training data and replace missing values with NA | |
training.data.raw <- read.csv('train.csv',header=T,na.strings=c("")) | |
# Output the number of missing values for each column | |
sapply(training.data.raw,function(x) sum(is.na(x))) | |
# Quick check for how many different values for each feature | |
sapply(training.data.raw, function(x) length(unique(x))) | |
# A visual way to check for missing data |