The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
library(ggplot2)# Load the datasettheoph <-read.csv("./data/theoph.csv")# Convert the subject ID (Subject) to a factortheoph$Subject =factor(theoph$Subject)
1. Results
Using select() make a new data frame containing only the subject ID, the Time and conc variables
theoph_sub <- theoph |>select(Subject, Time, conc)
Using a combination of select() and distinct() make a new data frame containing a single row for each subject with the subject ID, their weight and the dose
Using filter() make a new data frame containing only the first subject and pipe this to ggplot() to make a line plot with Time on the x-axis and conc on the y-axis
theoph |>filter(Subject ==1) |>ggplot(aes(x = Time, y = conc)) +geom_line()
Using select() to extract just the Subject, Time and conc variables and pipe this to ggplot() to make a line plot with Time on the x-axis, conc on the y-axis and the lines colored by subject
theoph |>select(Subject, Time, conc) |>ggplot(aes(x = Time, y = conc, col = Subject)) +geom_line()
Using select() to extract just the Subject, Time and conc variables and pipe this to ggplot to make a line plot with Time on the x-axis, conc on the y-axis and faceted by the subject ID
theoph |>select(Subject, Time, conc) |>ggplot(aes(x = Time, y = conc)) +geom_line() +facet_wrap(~Subject)