统计代写-STATS 220
时间:2022-06-15
2022/6/13 15:07 Exam information and practice exam
https://www.stat.auckland.ac.nz/~fergusson/stats220/exam_info_practice/ 1/6
Exam information and practice exam
STATS 220 Semester One 2022
This practice exam is designed to give you an idea of the format of the
exam and the kinds of questions you can expect to be given.
It is very loosely based on the STATS 220 Semester One 2021 and
Semester One 2020 exams, with substantial changes to align the
questions from both past exams with the content and focus for STATS 220
Semester One 2022.
Please use Ed Discussion to post questions related to this practice
exam, or general revision related questions
This section will contain questions based on general R code knowledge
related to vectors and data frames, as well as data manipulations and
visualisations (including the grammar of graphics).
Data was obtained from the Spotify API for songs on the NZ Top 40 charts
the week of the 23rd May 2022.
For reference, the first 10 rows of the data frame top40_data are shown
below.
Exam information How to revise for the exam!
Information about questions Practice exam SQL code revision
Section 1 Section 2 Section 3
2022/6/13 15:07 Exam information and practice exam
https://www.stat.auckland.ac.nz/~fergusson/stats220/exam_info_practice/ 2/6
Q1
How many columns/variables are in the data frame top40_data ?
The variable track_album_release_date is in column 3. Which function
from {lubridate} can be used to convert this variable to dttm ?
()
What is the result of running the R code top40_data$tempo[3] ?
What is the result of running the R code
top40_data$track_name %>% unique() %>% length() ?
How many variables in the data frame top40_data are numeric?
5 marks
Q2
Suppose the goal is to find the 10 shortest songs in terms of
track_duration , that all have tempos greater than 100 beats per minute.
2022/6/13 15:07 Exam information and practice exam
https://www.stat.auckland.ac.nz/~fergusson/stats220/exam_info_practice/ 3/6
The code below provides the code that a student wrote, but some parts of
the code have been replaced with numbers.
top40_data %>%
{1}(track_duration_ms) %>%
{2}(tempo {3} 100) %>%
{4}(1 : {5})
Use the boxes below to enter the missing function, operator, argument
name or value.
{1}
{2}
{3}
{4}
{5}
5 marks
Q3
The data frame day_counts was used to create a visualisation to compare
the weekday that the albums for the songs were released on.
Describe how you could use functions from {dplyr} and {lubridate} to
manipulate the data frame top40_data to create the data frame
day_counts .
2022/6/13 15:07 Exam information and practice exam
https://www.stat.auckland.ac.nz/~fergusson/stats220/exam_info_practice/ 4/6
3 marks
I would need to use mutate() and ymd() from {lubridate} to convert
the album release dates, which are currently characters/strings, to
date objects. I then need to use the weekdays() function from
{lubridate} to get the names of the day the album was released. I then
need to use group_by() and summarise() from {dplyr} to count how
many songs ( num_songs ) were released on each day ( day_released ).
Q4
The visualisation below was created using day_counts to compare the
weekday that the albums for the songs were released on.
The code below provides the code used to create the visualisation above,
but some parts of the code have been replaced with numbers.
2022/6/13 15:07 Exam information and practice exam
https://www.stat.auckland.ac.nz/~fergusson/stats220/exam_info_practice/ 5/6
day_counts %>%
ggplot({1}({2} = reorder(day_released, num_songs),
{3} = num_songs,
colour = day_released)) +
geom_segment(aes(yend = day_released,
xend = 0),
size = 3) +
geom_{4}(size = 10) +
{5}(title = "Friday Friday, gotta get down on Friday",
subtitle = "Comparing the release day for song albums",
y = "Day of the week",
x = "Number of songs") +
{6}(panel.background = element_rect(fill = "#FFFFFF"),
panel.grid.major.x = element_line(colour = "#F0F0F0")) +
guides(colour = "none")
Use the boxes below to enter the missing function, operator, argument
name or value.
{1}
{2}
{3}
{4}
{5}
{6}
6 marks
Q5
In Assignment 4, you had to create a visualisation based on music data
from a Spotify playlist. In no more than three sentences, describe what
changes you made (or would make using feedback on your assignment) to
improve your visualisation so it communicated a story visually. Refer to
the grammar of graphics in your description.
3 marks
2022/6/13 15:07 Exam information and practice exam
https://www.stat.auckland.ac.nz/~fergusson/stats220/exam_info_practice/ 6/6
Answers will vary, but should cover decisions made such as using
titles, labels or annotations, colour, different layers, different
geoms, or effective use of animation.


essay、essay代写