Introduction to Statistics Using R - Homework 1

1. a) Read the file attitude.dat using read.table. Download file attitude.dat.

b) The "-99" values denote missing data. Replace these with the appropriate missing value.

c) Save the editted data frame to a file using save(). Choose a file name other than the default .RData. (e.g., homework1.Rdata).

d) quit R (without saving the workspace), and restart it.

e) Read the saved data file using load (e.g., load("homework1.Rdata")

f) Save the data frame using dump(), and take a look at the saved file. This format is very useful for transporting R objects across different computing platforms. You can retrieve it using source().

g) Look at the help page count.fields(), and use it for the attitude.dat file. This function can be very helpful for diagnosing problems when reading data.

2) Repeat step 1 a. using scan().

3) Create a function that inserts a specified value between two elements of a vector at a given position. For example, insert the character "a" between the 4th and 5th elements of 1 2 3 4 5 6 7 8

-- DeanBillheimer - 05 Mar 2004
Topic attachments
I Attachment Action Size Date Who Comment
attitude.datdat attitude.dat manage 1.0 K 05 Mar 2004 - 11:55 DeanBillheimer example frauda file
Topic revision: r2 - 10 Jul 2008, JohnHarrell
 

This site is powered by FoswikiCopyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback