24 W
24.1 whitespace
Spaces, tabs and line breaks
R mostly ignores whitespace, so you can use it to help you organise your code.
# a and b are identical
a <- list(ctl = "Control Condition", exp1 = "Experimental Condition 1", exp2 = "Experimental Condition 2")
# but b is much easier to read
b <- list(ctl = "Control Condition",
exp1 = "Experimental Condition 1",
exp2 = "Experimental Condition 2")
You may also encounter the term in the context of formatting statistics. For example, the APA recommends using whitespace around equal signs.
- with whitespace: t(49) = 1.50, p = .140, d = 0.20
- without whitespace: t(49)=1.50, p=.140, d=0.20
24.2 wide
A data format where all of the observations about one subject are in the same row
id | Q1 | Q2 | Q3 |
---|---|---|---|
A | 1 | 2 | 3 |
B | 4 | 5 | 6 |
Contrast with long data format.
24.3 widget
A interactive web element, like a dropdown menu or a slider.
See a great overview of widgets at the RStudio Shiny tutorial. In shiny apps, a widget is created by its function. The first argument is the name you will use in the code for referring to that widget and its value, so make sure it's a unique, descriptive name like plot_color
or group1_label
. The second argument is the label, which is a string like "Plot colour"
or "Label for the first group"
(it can also be an empty string like ""
).
24.4 within subjects
Varying such that each unit of observation has more than one value
For example, imagine an experiment where you test subjects with easy, medium, and hard tasks. This experiment has one factor, task difficulty, which is within subjects because each subject experiences all three levels: easy, medium, and hard. This experiment may also be described as "within subjects".
Contrast with between subjects.
24.5 working directory
The filepath where R is currently reading and writing files.
If you are working in a project, the working directory is usually the main project directory. So if you want to save a file into a folder called "data" in that project folder, you can use a relative path, which is automatically appended to the working directory, such as readr::write_csv(my_data, "data/my_data.csv")
.
getwd() .html# get the current working directory
setwd("~/r/myfiles") .html# change the working directory
Never set or change your working directory in a script.