Sunteți pe pagina 1din 1

Assignment 1: Introduction to R Marks=20

Problem 1: Use R as a calculator to compute the following values. After you do so, cut and paste
your input and output from R to Word. Add numbering in Word to identify each part of each
problem. (Do this for every problem from now on.)
(a) 27(38-17)
(b) ln(147)
436
(c)
12

Problem 2: Create the following vectors in R.


a = (5, 10, 15, 20, ..., 160)
b = (87, 86, 85, ..., 56)
Use vector arithmetic to multiply these vectors and call the result d. Select subsets of d to identify
the following.
(a) What are the 19th, 20th, and 21st elements of d?
(b) What are all of the elements of d which are less than 2000?
(c) How many elements of d are greater than 6000?

Problem 3: Use R to create the following two matrices and do the indicated matrix multiplication.
1 7 12 19
7 12
20
9
2 2
13
8 13
4
3 9 14 21
What is the resulting matrix?
Problem 4
a) Read in the data in R using read.csv function Available on dataset link ( MyfirstData)
(https://sites.google.com/a/umt.edu.pk/dmdw/datasets)

You first need to specify your working directory using the setwd() command.
Determine whether each of the two attributes (columns) is treated as qualitative (categorical) or
quantitative (numeric) using R.

Explain how you can tell using R. Write down commands and their answer as well

b) Use the command plot() in R to make a plot for each column by entering plot(data[,1]) and
plot(data[,2]).

Explain exactly what is being plotted in each of the two cases. Include these two plots in your
assignment their screen shots

c) Use the R functions mean(), max(), var() and quantile(,.25) to compute the mean, maximum,
variance and 1st quartile respectively of the data in the first column and second column.

Show your code and the resulting values.


hard copy required
Screen shot of your R software in which your work will be shown

S-ar putea să vă placă și