logo

Crowdly

ETC3550 - ETC5550 - Applied forecasting - S1 2025

Looking for ETC3550 - ETC5550 - Applied forecasting - S1 2025 test answers and solutions? Browse our comprehensive collection of verified answers for ETC3550 - ETC5550 - Applied forecasting - S1 2025 at learning.monash.edu.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

This is a code chunk for R Markdown / Quarto:

```{r plot, message = FALSE, warning = FALSE, error = FALSE, echo = FALSE}

ggplot(mpg, aes(displ, hwy, colour = class)) +

geom_point()

```

What is the name given to this chunk?

Giving chunks good names are useful for finding code, accurately caching the output, and automatically naming figure files. Chunk names must be unique and not contain spaces.

Speaking of caching, what option would you use to cache this output?

```{r plot-line, 

= TRUE}

ggplot(economics, aes(date, unemploy)) +

geom_line()

```

View this question

This plot shows the weight of each chick as they age, coloured by the experimental diet that they received.

Complete the code that produced this plot:

# Preview of the data's structure

as_tibble(ChickWeight)

## # A tibble: 578 x 4

## weight Time Chick Diet

## <dbl> <dbl> <ord> <fct>

## 1 42 0 1 1

## 2 51 2 1 1

## 3 59 4 1 1

## 4 64 6 1 1

## 5 76 8 1 1

## 6 93 10 1 1

## 7 106 12 1 1

## 8 125 14 1 1

## 9 149 16 1 1

## 10 171 18 1 1

## # i 568 more rows

p <- ggplot(ChickWeight) +

geom_

(aes(x = , y = , group = , colour =

))

p

Which function would you use to produce this plot that shows each Diet in separate panels?

p +

(vars(Diet))

View this question

Which package is used to manipulate your data, such as adding columns or computing summaries?

Which function would you use to:

  • compute a new column for your dataset?
  • reduce multiple values down to a single summary?
  • pick variables based on their names?
  • pick observations based on their values?
  • changes the ordering of the rows?

The ChickWeight dataset provides the weight chicks on 4 different diets as they age. The weight column is the chick’s body weight in grams, Time is their age in days, Chick is an identifier of each chick, and Diet is the experimental diet given to that chick.

as_tibble(ChickWeight)

## # A tibble: 578 x 4

## weight Time Chick Diet

## <dbl> <dbl> <ord> <fct>

## 1 42 0 1 1

## 2 51 2 1 1

## 3 59 4 1 1

## 4 64 6 1 1

## 5 76 8 1 1

## 6 93 10 1 1

## 7 106 12 1 1

## 8 125 14 1 1

## 9 149 16 1 1

## 10 171 18 1 1

## # i 568 more rows

Complete the code to compute the weight of each chick at 21 days old:

FinalChickWeight <- as_tibble(ChickWeight) |>

( == )

## # A tibble: 45 x 4

## weight Time Chick Diet

## <dbl> <dbl> <ord> <fct>

## 1 205 21 1 1

## 2 215 21 2 1

## 3 202 21 3 1

## 4 157 21 4 1

## 5 223 21 5 1

## 6 157 21 6 1

## 7 305 21 7 1

## 8 98 21 9 1

## 9 124 21 10 1

## 10 175 21 11 1

## # i 35 more rows

Complete the code to compute the average weight of 21 day old chicks for each diet type:

FinalChickWeight |>

(

) |>

(())

## # A tibble: 4 x 2

## Diet `mean(weight)`

## <fct> <dbl>

## 1 1 178.

## 2 2 215.

## 3 3 270.

## 4 4 239.

View this question

Suppose you had the closing prices for four large technology stocks, and it was given to you in this form:

stock_close

## # A tibble: 1,258 x 5

## Date AAPL AMZN FB GOOG

## <date> <dbl> <dbl> <dbl> <dbl>

## 1 2014-01-02 79.0 398. 54.7 553.

## 2 2014-01-03 77.3 396. 54.6 549.

## 3 2014-01-06 77.7 394. 57.2 555.

## 4 2014-01-07 77.1 398. 57.9 566.

## 5 2014-01-08 77.6 402. 58.2 567.

## 6 2014-01-09 76.6 401. 57.2 561.

## 7 2014-01-10 76.1 398. 57.9 561.

## 8 2014-01-13 76.5 391. 55.9 558.

## 9 2014-01-14 78.1 398. 57.7 571.

## 10 2014-01-15 79.6 396. 57.6 571.

## # i 1,248 more rows

Using the tidyr package, complete the code to convert this into a tidy format shown below:

library(tidyr)

stock_close |>

(cols = !Date, names_to = , values_to = )

## # A tibble: 5,032 x 3

## Date Symbol Close

## <date> <chr> <dbl>

## 1 2014-01-02 AAPL 79.0

## 2 2014-01-02 AMZN 398.

## 3 2014-01-02 FB 54.7

## 4 2014-01-02 GOOG 553.

## 5 2014-01-03 AAPL 77.3

## 6 2014-01-03 AMZN 396.

## 7 2014-01-03 FB 54.6

## 8 2014-01-03 GOOG 549.

## 9 2014-01-06 AAPL 77.7

## 10 2014-01-06 AMZN 394.

## # i 5,022 more rows

You’re writing an article on various diets for young chicks, and have computed this summary of the data:

ChickWeight |>

group_by(Time, Diet) |>

summarise(AverageWeight = mean(weight), .groups = "drop")

## # A tibble: 48 x 3

## Time Diet AverageWeight

## <dbl> <fct> <dbl>

## 1 0 1 41.4

## 2 0 2 40.7

## 3 0 3 40.8

## 4 0 4 41

## 5 2 1 47.2

## 6 2 2 49.4

## 7 2 3 50.4

## 8 2 4 51.8

## 9 4 1 56.5

## 10 4 2 59.8

## # i 38 more rows

Finish the code to convert this summary into a nice table for your report that looks like this:

ChickWeight |>

group_by(Time, Diet) |>

summarise(AverageWeight = mean(weight), .groups = "drop") |>

(names_from = , names_prefix = "Diet ", values_from = )

Time

Diet 1

Diet 2

Diet 3

Diet 4

0

41.4

40.7

40.8

41.0

2

47.2

49.4

50.4

51.8

4

56.5

59.8

62.2

64.5

6

66.8

75.4

77.9

83.9

8

79.7

91.7

98.4

105.6

10

93.1

108.5

117.1

126.0

12

108.5

131.3

144.4

151.4

14

123.4

141.9

164.5

161.8

16

144.6

164.7

197.4

182.0

18

158.9

187.7

233.1

202.9

20

170.4

205.6

258.9

233.9

21

177.8

214.7

270.3

238.6

View this question

Using RStudio projects helps to keep each of your projects (classes, packages, consulting projects) self-contained and makes it easy to switch between them.

You can switch between projects in RStudio with the project selector:

When you select a project RStudio will switch your working directory to match the project directory, and restore any tabs that you had when you last worked on the project.

In the above screenshot, what is the absolute path for the current project?

Projects make it easy to share your work with others, but you need to be careful when programming with file paths to keep the project self-contained. File paths in projects should be ‘relative’, that means the path implicitly starts from the project folder and locates a file within the project.

Suppose your project is located in the ‘project’ folder in your Documents, and it contains these files:

## project

## +-- R

## | +-- model.R

## | \-- plots.R

## +-- data

## | \-- weather.csv

## +-- project.Rproj

## \-- report.Rmd

What is the relative file path that is appropriate for reading in your data?

library(readr)

my_data <- read_csv("

")

It is important to use relative paths in your projects (especially your assignments!) as otherwise your code probably won’t work with the people you share it with. The absolute path of the data.csv file on your computer might be: /home/MarieCurie/Documents/project/data/weather.csv. Suppose I share my project with Alan Turing who uses Windows and saves the project into their Downloads folder. The weather.csv data file is now at C:\Users\AlanTuring\Downloads\project\data\weather.csv, and so the code that tries to find it at /home/MarieCurie/Documents/project/data/weather.csv won’t work at all! Using a relative path will work wherever the project folder is saved.

View this question

What is the name of the package used to load all of packages and datasets used in this unit?

Complete the code: How would you load in the R package used in this unit?

()

You should make sure that you are able to load the package in your R session.

If you have trouble installing this package, please ask for help in consultation sessions or on the discussion forum.

View this question

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!