Вы находитесь на странице: 1из 2

Programming and Statistics in R

Exercise 4
This sheet is concerned with usage issues.

1. Determine what objects are in the current workspace

ls()
objects()

2. Create, then delete some objects. Note the multiple assignment

a.df <- stackloss


jj1 <- jj2 <- jj3 <- a.df
rm(a.df)
rm(list=objects(pattern="jj*"))

3. Tinker with search path, using the stackloss data set

search()
attach(stackloss)
search()

4. Write the stackloss object to a file

write.table(stackloss,"test.dat")
write.csv(stackloss,"test.csv")
temp.df <- read.csv("test.csv")

Where is this file situated on the file system? Examine the default
output format of write.table by viewing the file with your favourite
text editor.
5. Get some help

?mean
help.start()

6. Do a silly large computation.

sin(matrix(0,nrow=5000,ncol=5000))

Use the escape key to interrupt. Note that this might take some time
to return control to the console.

1
Problems
1. Generate a matrix of size n p. Use the function as.data.frame to
coerce the matrix to a data frame. Which object requires more storage
space?

Вам также может понравиться