Chapter 1 Flashcards
Describe the difference between ‘long’ and ‘wide’ data formats and state which is most commonly used in pharmacokinetic modelling. (3 marks)
In long format data each row represents an observation for each ID, whereas in wide format each row represents a single ID and the columns contain repeated measures. Multiple time points appear horizontally as separate columns.
Long format is most commonly used in pharmacokinetic modelling, as it is easier for computer programmes like R to analyse and manipulate the data. Because it allows the data to be organised with repeated measures over time. In long form each event for each ID has its own row.
Give an example line of code for - Multiplication
3*2
Give an example line of code for each of - Addition
2+4 #Addition
Give an example line of code for each of - Natural logarithm
log(2)
What does the command ‘header=TRUE’ indicate
indicates the first row of the csv file contains headers(labels) for the variable
You have prepared a data frame that you would like to save. You are not sure that R is working in the correct folder that you wish to save it into.
What command will allow you to check that R is working in the correct folder?
getwd()
How to check the contents of the working directory in R
list.files()
What does the function head() do?
Shows the first 6 rows of the data frame
data[15,]
looks at row 15
How to use R to check for anomalies:
summary () function
What are R packages
groups of functions. Packages bring in new functions to use with/for the data (datasets).
what is %>%
Piping (%>%) is a tool that enables multiple logical steps to achieve a desired output.
What line of code should be added to plot a solid line for each individual?
A) geom_line(by=ID)
B) ggplot(data=data, aes(x=time, y=conc, group=ID))
C) ggplot(data=data, aes(x=time, y=conc, group_by=ID))
D) ggplot(data=data, aes(x=time, y=conc, line=ID))
E) geom_line(aes(linetype=ID))
B) ggplot(data=data, aes(x=time, y=conc, group=ID))
What command would produce a separate panel for each individual?
A) facet_wrap(vars(ID))
B) geom_line(aes(col=ID))
C) ggplot(data=data, aes(x=time, y=conc, fill=ID))
D) ggplot(data=data, aes(x=time, y=conc, line=ID))
E) geom_line(col=ID)
facet_wrap(vars(ID))