CHC9012 | National Taiwan Normal University
Prepare your computer:
Why?
We want to be organized and not messy!
Documents (or ???件) folder.CHC9012_Spring2025Slides: Presentation files.PCIbex_design: Scripts & materials.PreprocessingAnalysesR: Datasets & R code.Pay attention to the names
Generally, it is better not to use any space when naming folders and files!
1. Launch New Project Wizard
Click the blue cube icon in the top-left corner of RStudio.
2. Select project type
Choose “Existing Directory” to link R to your folder structure.
3. Finalize Connection
Browse to PreprocessingAnalysesR, check “Open in a new session”, and click Create Project.



Benefit: An .Rproj file sets your “Working Directory” automatically!

Task list:
1. Create the file ????
Go to New File > R Markdown. This moves you from raw code to a “living” document.
2. Configure (YAML) ???�?
The header between --- controls your title, author, and output format (HTML/PDF).
3. Text + Code chunks ????
Write text normally; insert Code Chunks ({r}) for analysis.
4. Run your codes ??��??
Use the green Play Button to test individual steps.
5. The Final “Knit” ??��
Click Knit to stitch everything into a polished report automatically!




Task list:
The code of the fake experiment is given on the website
Fake results!
An AI robot did the experiment several times. I also pretended that I was a “bad” participant several times. The results are just to show you how to analyze data from PCIbex, they do not have other value!
On the PCIbex platform, click on the Results button.
Then, click on Download.

read.pcibex <- function(filepath, auto.colnames=TRUE, fun.col=function(col,cols){cols[cols==col]<-paste(col,"Ibex",sep=".");return(cols)}) {
n.cols <- max(count.fields(filepath,sep=",",quote=NULL),na.rm=TRUE)
if (auto.colnames){
cols <- c()
con <- file(filepath, "r")
while ( TRUE ) {
line <- readLines(con, n = 1, warn=FALSE)
if ( length(line) == 0) {
break
}
m <- regmatches(line,regexec("^# (\\d+)\\. (.+)\\.$",line))[[1]]
if (length(m) == 3) {
index <- as.numeric(m[2])
value <- m[3]
if (is.function(fun.col)){
cols <- fun.col(value,cols)
}
cols[index] <- value
if (index == n.cols){
break
}
}
}
close(con)
return(read.csv(filepath, comment.char="#", header=FALSE, col.names=cols))
}
else{
return(read.csv(filepath, comment.char="#", header=FALSE, col.names=seq(1:n.cols)))
}
}Task list:
???? Assignment for next week
No assignment for next week! Please carefully review the content of these past two weeks, and finalize the data collection of your own project.