Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The folder Lab11Data contains several CSV data files. dfiles The folder Lab11Data contains several CSV data files. dfiles dir(Lab11Data , full .names=TRUE) dfiles ## C

image text in transcribed
image text in transcribed
The folder Lab11Data contains several CSV data files. dfiles

The folder Lab11Data contains several CSV data files. dfiles dir("Lab11Data" , full .names=TRUE) dfiles ## C 1] "Lab11Data/study1. csv" "Lab11Data/study2. csv" ## [4] "Lab11Data/study4. csv" "Lab11Data/study5. csv" ## C 7] "Lab11Data/study7. csv" "Labl IData/study8. csv" "Labl IData/study3. csv" "Labl IData/study6. csv" "Labl IData/study9. csv" 1. Write R code to read in the first file. Print the tibble that you just read in. Use names() to change the column names of the tibble to x and y. Repeat for the second file. How many observations are in these first two files? 2. Use vector() to create an empty vector called ff that is of mode "list" and length 9. Now write a for() loop to loop over the 9 files in dfiles and for each (i) read the file in to a tibble, and change the column names to x and y as in part (1), and (ii) copy the tibble to an element of your list ff. 3. Write a function called read . study _ data that takes a vector of data file names (like dfiles) as input, reads the data files into a list, assigns class "study_data" to the list, and returns the list. Your function should use length(dfiles) to determine the number of files. 4. Write a function plot . that takes an object of class "study_data" as input. The first 5 lines of your function should be the following, which creates a tibble with columns study, x and y: dat NULL for (i in seq_along(ff)) { dat rbind(dat , tibble (studri ,x=d$x,y=d$y)) Have your function coerce study to a factor, and then call ggplot() to make a plot of y versus x, with different colours for the different studies. Add points and smoothers to your plot.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mathematical Analysis And Its Applications Roorkee, India, December 2014

Authors: P N Agrawal, R N Mohapatra, Uaday Singh, H M Srivastava

1st Edition

813222485X, 9788132224853

More Books

Students also viewed these Mathematics questions

Question

Are there professional development opportunities?

Answered: 1 week ago