Due date : 29 Now 2019, 18:00
Objectives
- Manage Working Directory
- Download, Copy, Paste and Find the Data
- Read Data with utils (R utility functions) (utily is one of the default packages of R)
- Identify and Indexing Data
- Use Condition Statements
- Plot the Data
Hints : You can use these functions and the main web page of our course - LINK
getwd()
setwd()
list.files()
file.path()
read.csv()
read.delim()
read.table()
attributes()
attr()
colMeans()
plot()
if (condition) {
} else {
}
Instructions
PART-1 Manage Directory, Find and Read Data
- Go to main webpage of course
- Open Data “Istanbul_Goztepe_Mean_Temperature_1839-2013_Monthly” (.dat) LINK
- Copy and Paste it in your “Downloads” directory in a text file with “.dat” extension
- Open your R Studio
WAY 1 - GO TO FILE
- Check your Project Name and your Working directory
- Go to “Downloads” directory in R Studio
- List files and Read Data with three different read functions (read.csv(), read.delim(), read.table() )
- Choose the best
- Assign your data as “temp_1”
WAY 2 - CALL THE FILE
- Go Back to your Working directory
- Define your file path with file.path()
- Assign the path a new variable as “path_my_file”
- Use your best read() function
- Read the file with “path_my_file”
- Assign your data as “temp_2”
WAY 3 - IMPORT THE FILE
- Use “Import Datase”
- Assign your data as “temp_3”
WAY 4 - DOWNLOAD THE FILE
- Copy the LINK of data
- Use your best read() function
- Read the file with this function and LINK
- Assign your data as “temp_4”
Last step
- Choose your favorite " temp_1 or _2 or _3 or _4" and assign as just “temp”
PART-2 Play with the Data
Meet with the Data
- Look at structure
- Learn attributes and dimensions
- Rename attributes
Clear NA and Choose Colomn
- Print “temp”
- Delete rows which include NA ( na.omit() )
- Assign it as “temp_b”
- Select summer season
- Assign it as “temp_b_summer”
Use Condition Statements - if
- Compare June Mean Temperature and July Mean Temperature
- IF June Mean Temperature is LOWER than July then print “June has LOWER Mean Temperature.”
Use Condition Statements - else
- ELSE print “June has HIGHER Mean Temperature”
- Calculate mean of each month ( colMeans() )
Plot
- Plot temperature for June
- Add title and unit
- Edit x-axis, which years are they ?
- What about July and August ? Plot them.
- Is there any strangeness thing, what do you think ? Compare three plots.
For questions or problems, please use Ninova
LS0tCnRpd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