For the homework, you need to submit two files: a markdown file named homework2.md, and an R file named homework2.R.
In homework2.md, answer following questions:
In homework2.R:
Compute the mean, median, variance, and standard deviation of integers from 1 to 10.
Take a look at the mtcars data in R. It is a dataset
came with R. Just type mtcars in R. Type
?mtcars in R to read the description of the data. Then do
the following
mtcars, i.e., is it a data frame
or matrix?mtcars into a matrix.Lincoln Continental from
the matrix.Honda Civic have?Run following code to create a list
family1 = list(husband="Fred", wife="Wilma", numofchildren=3,
agesofkids=c(8,11,14))
agesofkids field from the list, using at
least 2 different methods.unlist
function.numofcar=2, ageofcar=c(5, 10). Note you cannot
recreate the list, rather you need to append these fields to the
existing list.Practice using R base graphics to generate histogram, boxplot,
barplot, and scatter plot. We will use the mtcars data in R
for these tasks.
table function. Use barplot to show the
results.Read the COVID-19 data into R as a data frame. Conduct explorative analysis of the data, and answer questions listed for homework2.md.
The Wimbledon final will be played tomorrow (July 11, 2021). Novak Djokovic will chase his 20th Grand Slam title, tying Rafeal Nadal and Roger Federer. With the continous debate on who’s the GOAT tennis player, we will analyze the career tennis match results from these big three.
First, obtain the career match results for the three players from the links below. These are csv files I downloaded from https://www.ultimatetennisstatistics.com. These are results until July 7, 2021.
Secondly, read these files into R as data frames (using the
read.csv function). Carefully examine the data frame to get
familiar with the content of the data, such as the column names and
their meanings.
Write codes to answer following questions, from easy to difficult
dplyr package. You can google
conditional means dplyr for that if interested.After obtaining all these results, interpret them in an intuitive way. Present the results using tables, figures, and language. Write an article about your analyses.
mean, median, var,
sd. Read the function helps and play with the
examples.vignette() function.browseVignettes and vignette functions. For
example, do browseVignettes("dplyr") and
vignette("dplyr"). Remember, a package “vignette” is the
package manual. You’ll learn how to write one later using
Rmarkdown.List:
Data frame:
Learn to use R to create histogram, boxplot, scatter plot, bar plot.
Learn to save R plots in files: http://www.sthda.com/english/wiki/creating-and-saving-graphs-r-base-graphs.
Understand the meaning of each figure. Read the function helps for these functions, and play with the examples. Have a rough idea of the function parameters (what you can control for the figures).
Browse https://www.r-graph-gallery.com to see what type of figures R can generate.
Play with the plot functions by looking at the examples. Run following in R to see what R can plot:
example(plot)
example(barplot)
example(hist)
example(points)