You are on page 1of 2

Homework Play

Keyser Soze
2019-01-29

This is an R Markdown (Rmd) document. Markdown is a simple formatting syntax for authoring HTML,
PDF, and MS Word documents. It was designed to simplify creating HTML documents, but can also create
word or pdf documents. Note that if you want to create a pdf file you need latex installed on your machine.
The content of an R Markdown document is created in the R Studio script editor. Formatting commands in
the text are converted to html output when you click the Knit button, located on the toolbar at the top of
the script editor.
Let’s get started.
The result for 1+2+3+4+5 is:
1+2+3+4+5

## [1] 15
The square root of 2 is
sqrt(2)

## [1] 1.414214
options(digits=2)
fname="http://www.datadescant.com/stat104/stat104_survey.csv"
mydata=read.csv(fname)
names(mydata)

## [1] "height" "weight" "male" "cellphones"


## [5] "looks" "smoke" "sleep" "parzen_age"
## [9] "haircut" "snap" "right_handed" "manual"
## [13] "fastest_drive" "countries" "only_child" "text_day"
## [17] "second_toe"
weights=mydata$weight
heights=mydata$height
male=mydata$male

The number of observations in the data set is:


nrow(mydata)

## [1] 114

The mean of the male weights is:


mean(weights[male==1])

## [1] 162
The square root of 2 is 1.41.
When we square pi the result is 9.87.
The mean of the male weights is 162.05 and the mean of the female weights is 132.42.

1
The correlation between everyone’s height and weight is 0.66
Here is a histogram of the female weights:
hist(weights[male==0])

Histogram of weights[male == 0]
15
10
Frequency

5
0

100 120 140 160 180

weights[male == 0]
Here is a scatter plot of the relationship bewteen height and weight:
plot(weights,heights)
80
75
70
heights

65
60
55
50

100 120 140 160 180 200 220 240

weights

You might also like