Please complete the following problems.
- R is case-sensitive. Make sure you store your answers using the exact name specified.
- You will be graded on:
- The correctness of your answers.
- The efficiency of your code. Don’t make your script unnecessarily long and only do the essential steps.
- The clarity of your code. Make sure you explain the steps in your script with annotations (
#). Without comments we don’t know if you understand what is happening.
Load in the data you will need as follows:
data(vegdata1, vegdata2, package = "edcpR")
Extract the following values from the vegdata1 dataset:
- Store the column with name Elevation in a vector called my_vector.
- Store the number in the 18th row and 6th column in an object called my_number.
- Create a new vector my_vector_2 which contains both my_vector and my_number.
- Calculate the mean of the 12th column and store it in my_mean.
- What kind of class is stored in the sixth column? Store this as a string in my_data_type.
- What are the dimensions of vegdata1? Store this as a vector in my_dim.
Merge vegdata1 and vegdata2 into one data frame. Store your result in my_data_frame. Hint: the resulting dataframe has 144 rows.
Use the package “dplyr” to only select rows containing data from Grassland from your merged data frame. Store your result in my_grassland.
Submit your work
Save your R-script as Surname-FirstName-assignment-1.R. Upload this on Toledo before October 6th, 12:00 noon in the assignments folder!