Vous êtes sur la page 1sur 1

Methods for Agricultural Research Data

Assignment 2 - 14.11.2016

(0.25 points) 1. Create a vector x with continuous integer values from 3 to 7. Write down the R command.
Which meaning has the input of x2 in R?
(0.25 points) 2. Create a vector y with continuous integer values from 1 to 50. Write down the R command.
(0.25 points) 3. Name four data types in R.
(0.25 points) 4. Name three data structures in R.
(1.5 points) 5. Create the dataframe "A" with the following data and commands:
students <- c ( " Adam " ," Beyonce " ," Celine " ," Donald " )
ages <- c (19 ,35 ,48 ,70)
sizes <- c (1.86 ,1.74 ,1.69 ,1.58)
A <- data . frame ( name = students , age = ages , size = sizes , row . names =1)

(0.5 points)

(a) Add an additional column "gender" with the corresponding abbreviations to each name
(f=female, m=male) and recreate the dataframe "A". Write down the R commands.

(0.5 points)

(b) Calculate the average age of women and men separately.

(0.25 points)

(c) Calculate the average size of all people older than 20.

(0.25 points)

(d) Create a subset of the dataframe "A", only containing row two and four in one R
command.

(0.5 points) 6. Create a vector with 100 random datapoints from the normal distribution with a standard
deviation of four. Plot a histogram with these data and draw the mean and median as a
vertical line in the graph.
(0.5 points) 7. Now, some example datasets already installed in R are used. Briefly describe which information is saved in each dataset.
Loblolly
OrchardSprays
(0.5 points) 8. Use the dataset "Loblolly".
(0.25 points)

(a) Plot the age of the trees (x-axis) against the height (y-axis).
Bonus: plot height in metres (1 ft = 0.3048 m)

(0.25 points)

(b) Add a meaningful title to the graph.

(1 point) 9. Use the dataset OrchardSprays.


(0.5 points)

(a) Create a histogram for the decrease and draw the mean as a red vertical line in the
graph.

(0.25 points)

(b) Create a horizontal boxplot of the decrease.

(0.25 points)

(c) Create a boxplot of the decrease for each treatment A-H.


This exercise has 9 questions, for a total of 5 points.

Vous aimerez peut-être aussi