Sys.Date()
[1] "2023-03-16"
2023-01-27
Sys.Date()
[1] "2023-03-16"
getwd()
[1] "/media/jstevens/data/jstevens/OneDrive/active_sync/projects/dpavir_2023/slides"
# the best way
x <- 9
# avoid this
y = 10
# definitely don't do this
11 -> z
x <- 9 # assign value 9 to object x
x # print contents of object x to console
[1] 9
(x <- 9) # add parentheses to print to console when assigning
[1] 9
mean1=mean (x[1,4:10],na.rm=T)+0.5
mean1 <- mean(x[1, 4:10], na.rm = TRUE) + 0.5
Use <-
as assignment operator
Use space between operators (*
, =
, ==
) and after commas
Write out TRUE
and FALSE
Do not use space between function and parentheses
Use indents to separate nested components (Ctrl+I)
Use "
, not '
, for quoting text unless it already contains double quotes
Be nice to machines
Be nice to humans
Make sorting and searching easy
my_file.R
not My filé$.R
foo.R
and Foo.R
expt1_cond2_subj114.csv
x
) but not too descriptive (this_is_my_object
)a ≠ A
)prelim_analysis_expt1.R
YYYY-MM-DD
2021-04-06_prelim_analysis_expt1.Rmd
prelim_analysis_expt1_2021-04-06.Rmd
01_preface.Rmd
02_introduction.Rmd