- Applications
Cars
Locke (1993) recorded data on a random sample of cars from the 1993 model year. His data are in 93cars.csv (data/meta). Use this information to answer the following questions (by using R).
- Download the data from the class webpage and load into R.
- How many variables are recorded in this data.frame?
- How many individuals are recorded in this data.frame?
- Isolate the following subsets of data (show the structure or a view of the resultant data.frame to verify your results).
- Cars that were manufactured by Ford.
- Cars that get more than 30 miles per gallon in the city.
- Cars that had an automatic transmission and get more than 30 miles per gallon on the highway.
- Cars that had a horsepower between 175 and 200.
- Cars that were either domestically manufactured or were four cylinders.
Purple Loosestrife Plants
The data below are the number of Purple Loosestrife (Lythrum salicaria) plants found in each of 19 randomly selected plots in Green Gables Creek Slough.
13, 2, 1, 0, 9, 11, 5, 5, 14, 23, 0, 2, 3, 3, 6, 7, 4, 16, 1
The researchers also recorded a qualitative measure of plot “shadiness”, recorded as (along with abbreviations) “completely shaded” (S), “partially shaded” (P), and “completely open” (O). The data below are the “shadiness” of the same 19 plots in the same order as the number of Loosestrife plants shown above.
O, S, S, S, O, O, S, P, O, O, S, S, P, P, P, P, S, O, S
Enter these data into a CSV file with columns labeled as lstrf
and shade
. Read that file into an object called df
in R. Use this to answer the questions below using R commands (i.e., don’t re-type the data). [Note: Don’t use headtail()
or str()
when asked to show all individuals. Type the name of the data.frame instead.]
- List the data for all completely shaded plots.
- List the data for all open plots.
- List the data for all completely open or partially shaded plots (use only one command in R).
- List the data for all plots with more than 10 purple loosestrife plants.
- List the data for all plots with less than 5 purple loosestrife plants and that are completely shaded (use only one command in R).