0% found this document useful (0 votes)
23 views

Programming and Statistics in R Exercise 4

This document provides an exercise on usage issues in R such as determining objects in the workspace, creating and deleting objects, modifying the search path using a dataset, writing objects to files, getting help, and performing computations. It also asks the user to generate a matrix and coerce it to a data frame to compare storage requirements.

Uploaded by

Mila Anasanti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Programming and Statistics in R Exercise 4

This document provides an exercise on usage issues in R such as determining objects in the workspace, creating and deleting objects, modifying the search path using a dataset, writing objects to files, getting help, and performing computations. It also asks the user to generate a matrix and coerce it to a data frame to compare storage requirements.

Uploaded by

Mila Anasanti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 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?

You might also like