PART-2 Play with the Data
MEET WITH THE DATA
- Look at class and structure
- Learn attributes and dimensions
- Rename attributes ( ex: Months for each column and years for each raw ) ( attributes() and month.name or month.abb )
- By the way, your data have to include just temperature values when you print it. Years and months have to be just attributes of data.
CLEAR NA AND CHOOSE COLUMN
- Print “temp”. Do you see irrelevant numbers ? If so, change them as NA
- Now your “temp” data must seem like this
- Delete rows which include NA ( which() or na.omit() )
- Now your “temp” data must seem like this
- Assign it as new “temp” again
- Select summer season
- Assign it as “temp_summer” ( three months)
USE LOGICAL OPERATORS
- Compare June and July: Find and print the years when June temperatures were less than July. ( which() )
- Calculate mean temperature for each months (you will probably need the na.rm (NA Remove) option ) and assign it as “avg_month”
- Print minimum and maximum values for “avg_month”
- Find which year and which month minimum and maximum values were observed12. Calculate the mean temperature for each years (you will probably need the na.rm (NA Remove) option ) “avg_year”
- Calculate the mean temperature of all data and assign it as “avg_temp” and print it
- Print the years of “avg_year” which are greater than or equal to “avg_temp”
PLOT
- Plot temperature for June ( for each year ), add title and unit
- Edit y-axis and x-axis label ( to see which years are they )
- What about July and August ? Plot them on the same figure with June.
- Is there any strangeness thing, what do you think ? Compare three plots
- Plot “avg_month”, make the type of line as “line” and colorful. What is reason of the inverted V letter shape
- Plot “avg_year”, make the line dashed line. What do you think
- Plot just temperature for just 1990 ( my birth year )
THE LAST BUT NOT LEAST
- Run these codes. Can you explain what am I doing with my codes which were given below? What are these x-axis and y-axis in here? ( which years or months are they? ) What is the result of this figure, what do you see and what do you think? what do colors mean? Can you edit title and x-axis and y-axis labels?
plot(seq(1,12), temp[142,1:12] , type = "l", col = "red")
lines(seq(1,12), temp[1,1:12] , type = "l", col = "blue")
legend("topleft",c("blue","red"),fill=c("blue","red"))
abline(h = mean(colMeans(temp, na.rm = T)))
par(mfrow = c(2, 2)) #or try par(mfrow = c(4, 1))
plot(ylim = c(0,30), rowMeans(temp[,9:11]) , type="l", col="orange")
plot(ylim = c(0,30), rowMeans(temp[,c(12,1,2)]) , type="l", col="blue")
plot(ylim = c(0,30), rowMeans(temp[,3:5]) , type="l", col="green")
plot(ylim = c(0,30), rowMeans(temp[,6:8]) , type="l", col="red")
For questions or problems, please use Ninova
Emir