130k views
1 vote
R Problem Old Faithful is a geyser located in Yellowstone Nation Park in Wyoming. It received the name "Old Faithful" by the Washburn-Langford-Doane expedition, who noted that the geyser seemed to erupt at regular intervals. In this problem, we will use data collected by park rangers to analyze whether the eruptions are as regular as originally thought. If you feel so inclined, you can watch Old Faithful in real time at the National Park Service website. The dataset is available on Canvas and has 2 columns and 272 rows. Observations are organized by row - the first column gives the length of the eruption (in minutes), while the second columin gives the waiting time (in minutes) since the previous eruption...Use the R function read.table to import the data set. If you don't know how it works, use help(read.table) to check the usage.

1 Answer

3 votes

Answer:

Explanation:

The first 6 rows of the eruptions data :

eruptions waiting

1 3.600 79

2 1.800 54

3 3.333 74

4 2.283 62

5 4.533 85

6 2.883 55

R code :

1. You can directly access the "Faithful" data in R without importing the data. The dataset faithful is present in the R or you can load the datasets. or use install the datasets.load. package

If you have the data in a text file, make sure all the columns and rows are separated by commas

Step 1: open notepad

Step 2: enter data with no spaces but only commas

Step 3: save the file as ‘faithful.txt’ on your Desktop

# Get R help

?read.table

# Import the data

rain<-read.table("C:/Users/YOUR-NAME/Desktop/faithful.txt", header = TRUE,

sep = ",")

Check the data

data("faithful") #Loading Faithful data

head(faithful, 6) #Reading first 6 rows of the data

User Commit
by
5.2k points