Starting from:

$30.99

STAT823- Homework-1 Solved

Directions
Launch RStudio and open a new R Script. Give the script a name with a .R extension, say, hw1.R and save it on your working directory. The aim of this exercise is to make you get used to using R, create a few objects, and use R as a calculator. Explore the basic functionalities of R and include enough documentation with annotated comments.

Use R-Markdown and knit your solution document to pdf. To doYou may optionally explore the use of R-Markdown (although more so, go to File, New File, then click on R Markdown. A templatedetails will be covered later). To do so, go to File, New File, then will open up. Save this with an .Rmd extension, e.g. hw.Rmd. Submitclick on R Markdown. A template will open up. Save this with an BOTH your Rmd file and pdf file when finished..Rmd extension, e.g. hw1.Rmd. Use this as your template or any other more developed template to answer the questions.


If you have any questions, please post them on the lesson discussion board.

 

1.    (a) Calculate the square root of 625

(b)     Create a new object y and asign it to the value 100

(c)       Calculate the natural logarithm of y

(d)     Calculate the logarithm to base 10 of y

2.    (a) Generate 1000 random numbers from a normal distribution with mean 0 and standard deviation 1. (Hint: use the R

 

Page -1- of 2

Lesson 1: Homework 1A                                                                                        STAT/BIOS 823

function rnorm(). Also you can set a seed by typing set.seed() for the random generator to give you the same numbers every time you run the R code. Do not print out the 1000 numbers on the solution document.)

(b)     Plot a histogram of the numbers generated in (a) above.

(Hint: use hist() function)

(c)       Calculate the mean, standard deviation, variance, standard error, minimum, maximum, median, and range of the 1000 random numbers. (Hint: R already has functions to do this. Look for them or create your own)

More products