Chapter Exercises and T/F Questions
Chapter 1 - R Basics
1. What command would you use to obtain R manuals and reference material?
> help.start()
2. What command would you use to obtain information about the {stats} package?
> library(help="stats")
3. What R commands would yield z as the sum of x = 5 and y = 6?
>x=5
>y=6
>z=x+y
4. What R command would yield test as a data vector with values 10, 20,30,40,50?
> test = c(10,20,30,40,50)
5. What R command would add the labels A,B,C,D,E to the data values in test?
> names(test) = c("A","B","C","D","E")
6. Create a matrix P with 2 columns from data (1,2,3,4,5,6).
> P = matrix(c(1,2,3,4,5,6), ncol=2)
7. What R command would create a data frame J from matrix P?
> J = data.frame(P)
8. What R command would provide pre and post labels for columns in J data frame?
> names(J) = c("pre","post")
9. What R command would return TRUE or FALSE for missing values in data frame J?
> is.na(J)
10. What R command lists all active variables in the work environment?
> ls()
, TRUE OR FALSE QUESTIONS
T F a. R software can only be run on an IBM PC.
T F b. R software has extensive manuals, references, and documentation
material available for the user.
T F c. R script programs can only analyze numerical data.
T F d. R software can analyze data similar to other statistical packages, for
example, SPSS, SAS, or STATA.
T F e. You should not mix data types in a data vector.
ANSWERS:
a. F
b. T
c. F
d. T
e. T