Linear interpolation
For continuous and numeric data – where the values can fall anywhere within a range of values – linear interpolation is often the best option for imputation. Data such as temperature, elevation, and per capita income are examples where linear interpolation could be used.
In this exercise, you will determine the number of missing values in the maunaloa_missing time series and use linear interpolation to impute these values.
maunaloa_missing, zoo, and ggplot2 are available to you.
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Manipulating Time Series Data in R
คำแนะนำการฝึกหัด
Determine the count of observations from
maunaloa_missingthat areNA.Use linear interpolation to fill in the missing values in
maunaloa_missing; assign this asmaunaloa_linear.Generate a
ggplotofmaunaloa_linear, with a red-colored line.
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Count the number of missing values
___
# Fill in values with linear approximation
___
# Generate a full ggplot of maunaloa_linear
ggplot(___,
aes(___)) +
scale_y_continuous() +
___