Question

In: Statistics and Probability

a. In R there is an built in data frame Nile. This has the annual flow...

a. In R there is an built in data frame Nile. This has the annual flow in river Nile for year 1871 to 1971. Produce a time series plot. Print graph(s).

b. add the title as "Nile River Annual Flow", x axis label as "Year" and y axis label as "Flow". Print graph(s).

c. Add a horizontal line showing the average flow over these years. Print graph(s).

d. Add text as: "Average Flow:" with the calculated average flow on the chart. (hint: you can use mean function). Print graph(s).

Please add screenshot of code!

Solutions

Expert Solution

The R code for completing the above problem along with the step by step graphs is given as follows,

*********************************************************************************************************************************************
######## Calling the 'datasets' package containing dataframe 'Nile'########

library(datasets)
df <- Nile

###### Part a : Produce a time series plot ########
plot.ts(df)

###### Part b : Adding Titles and labels ########
plot.ts(df, main = "Nile River Annual Flow",xlab="Year",ylab="Flow")

###### Part c : Adding horizontal line for average flow ########


plot.ts(df, main = "Nile River Annual Flow",xlab="Year",ylab="Flow")
abline(h=mean(d)) ## 'h' inside 'abline()' stands for horizontal, similarly 'v' stands for 'vertical'

###### Part d : Adding text, 'Average Flow' on the chart ########


plot.ts(d, main = "Nile River Annual Flow",xlab="Year",ylab="Flow")
abline(h=mean(d))
temp<-locator(1) ### on executing this line, please select a point in the plot where you want the text to be shown, then execute next line of code
text(temp,"Average Flow")

********************************************************************************************************************************************

PLEASE UPVOTE MY ANSWER IF YOUR QUERY IS CLARIFIED.


Related Solutions

(1) Read in the data and create an R data frame named tennis.dfr that has the...
(1) Read in the data and create an R data frame named tennis.dfr that has the following names for its columns: first.name, last.name, major.match.wins, major.match.losses, overall.match.wins, overall.match.losses, major.titles, overall.titles. (Note that the data file has several explanatory lines before the real data begin that should be skipped when reading in the data lines.) NOTE: For the file name, you must use the following web address (URL): "http://people.stat.sc.edu/hitchcock/tennisplayers2018.txt". Please do not have your code read in the file from your own...
Instructions tell you how to get the data in R R has built in dataset called...
Instructions tell you how to get the data in R R has built in dataset called Iris. This famous (Fisher's or Anderson's) iris data set gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for 50 flowers from each of 3 species of iris. The species are Iris setosa, versicolor, and virginica. We are interested in estimating the length of Petal (Y) using the length of Sepal (X). First, load the...
R has a number of datasets built in. One such dataset is called mtcars. This data...
R has a number of datasets built in. One such dataset is called mtcars. This data set contains fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973-74 models) as reported in a 1974 issue of Motor Trend Magazine. We do not have to read in these built-in datasets. We can just attach the variables by using the code attach(mtcars) We can just type in mtcars and see the entire dataset. We can see the variable...
Create a data file frame in R called musseldata which has the following observations: species length...
Create a data file frame in R called musseldata which has the following observations: species length drywght tidehght calif     113    14.3     low tross      48     6.9     med calif      72     8.1     high calif      82     8.7     med tross      33     4.9     high tross      51     7.0     med calif      94   11.6     low Type the name of the data frame and copy/paste your R command the result into the green box. Use a logical condition with the subset() function to create a subset of the data called...
Built in Data In R: This Question uses "cystfibr" data found in "ISwR" package. to access...
Built in Data In R: This Question uses "cystfibr" data found in "ISwR" package. to access this data you need to first install "ISwR" package. then load the library. Type data() to check which built in data are in the package "ISwR". This should show all the available built in data as: We use nickel data for this part. Type >cystfibr to see the data, and then answer the following questions using the data: (a) type ?cystfibr this will open...
Using R studio 1. Read the iris data set into a data frame. 2. Print the...
Using R studio 1. Read the iris data set into a data frame. 2. Print the first few lines of the iris dataset. 3. Output all the entries with Sepal Length > 5. 4. Plot a box plot of Petal Length with a color of your choice. 5. Plot a histogram of Sepal Width. 6. Plot a scatter plot showing the relationship between Petal Length and Petal Width. 7. Find the mean of Sepal Length by species. Hint: You could...
USE R STUDIO. Consider the pressure data frame. There are two columns: temperature and pressure: •...
USE R STUDIO. Consider the pressure data frame. There are two columns: temperature and pressure: • Construct a scatterplot with pressure on the vertical axis and temperature on the horizontal axis. • The graph of the following function passes through the plotted points reasonably well: y = (0.168 + 0.007 ∗ x) ^(20/3). Recall that the differences between the pressure values predicted by the curve (i.e. y) and the observed pressure values (i.e. the pressure values obtained from the data...
Import the RestaurantRating1 dataset in R and save the resulting data frame. RestaurantRating1 is shown below...
Import the RestaurantRating1 dataset in R and save the resulting data frame. RestaurantRating1 is shown below as a table. Use some of the data wrangling techniques to transform the dataset into a tidy data. Use glimpse() function to show the resulting dataframe. Donalds Fila King Payes Wendi 1 3 1 1 1 2 3 1 1 2 2 3 1 2 2 3 3 1 2 2 3 3 1 3 3 3 3 5 3 3 3 3 5...
In R: Consider dataset “juul” from library “ISwR”. (juul is a built in data set) Are...
In R: Consider dataset “juul” from library “ISwR”. (juul is a built in data set) Are the means of igf1 equal among tanner groups at 5% level? Please use the six step process to test statistical hypotheses for this research problem. Note: You need to convert tanner from numeric to factor type and ignore all the NAs.
warpbreaks is a built-in R dataset which gives This data set gives the number of warp...
warpbreaks is a built-in R dataset which gives This data set gives the number of warp breaks per loom, where a loom corresponds to a fixed length of yarn. We are interested in some descriptive statistics related to the warpbreaks dataset. We can access this data directly and convert the time series into a vector by using the assignment x <- warpbreaks$breaks. (In R, use ? warpbreaks for info on this dataset.) The values of x if assigned as above...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT