Description
Homework 1
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.
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)
Page -2- of 2




Reviews
There are no reviews yet.