UQRUG 22

meeting
Published

November 15, 2021

2021-11-15: UQRUG 22

Attendees

  • Catherine: Biology/Library, publish data for a paper
  • Grechel: PhD candidate/ PACE temporal trend analysis
  • Siu: Bachelor of Biomedical Science
  • Einat: PhD candidate / Civil Engineering School

Code snippets

Example of for loop vs map() function from purrr package.

# for loop to calculate the median of every column in mtcars
output <- vector("double", ncol(mtcars))
for (i in seq_along(mtcars)) {
   output[[i]] <- median(mtcars[[i]])
}
output # see the output

# same as above using a map() function
map_dbl(mtcars, median)

Shared resources