ad_text_file() function you will necd to nse the base: ireadhines() function. readLines() takes in a string that is the fle path (citber a relative or global) to a text file (or R script) and returus a chararter sextot where esach element corresponds to its respective line of text (or code). Below is a list of functions for you to construct. For each, we have prescribed a very specifse function signature. When we grabe the arsignment, we will cherk to enstre your functions have this signature. Be sure to incorpotate type checks for inputs of your functiot as nell. For instabce, if a function's signature denotres a nutiable to be ngmeric and a character is pased instead, your function showld throw an crrot with a belphul mensige. See the lecture notes from 2022-09-02 for more on type chocking and the function signature syntax uned below, Per usual, to grade yenu script, we will source() it and check its prrforman

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Your task is to produce functions that cam be tred to summarize the actual cote within an R seript. We will work up to the following line of codes compute_text_file_sumary(read_text_file(textFilePath)) We have broken this "monolith" task down into a few "brick" tasks below. Honever, you may comsider breaking these down even further. For the read_text_file() function you will necd to nse the base: ireadhines() function. readLines() takes in a string that is the fle path (citber a relative or global) to a text file (or R script) and returus a chararter sextot where esach element corresponds to its respective line of text (or code). Below is a list of functions for you to construct. For each, we have prescribed a very specifse function signature. When we grabe the arsignment, we will cherk to enstre your functions have this signature. Be sure to incorpotate type checks for inputs of your functiot as nell. For instabce, if a function's signature denotres a nutiable to be ngmeric and a character is pased instead, your function showld throw an crrot with a belphul mensige. See the lecture notes from 2022-09-02 for more on type chocking and the function signature syntax uned below, Per usual, to grade yenu script, we will source() it and check its prrformance against a varicty of unit* tests. The official unit tests won't be revealed until after the assignanent is graded. However, we have provided a smaller set of tuit tests in the script, grade_he1_practice. R, to give yous an idea of what we will be looking for. To use this script, you will need to download the folder, HutTextFiles_practice, containing the example test files. Then, at the top of the scriph, assign testFilesFolderPath to wherever the Hu1TextFiles practice folder is located and hwScriptPath to wherever your hu1. A script is located. Rauning the rest of the script and reviewing the print out will tell you bow your seript performed sgainst the practice mit tests. Your Task Create an R script entilted he1. R. that contains the following functions - read_text_f1le(textF1lePath; character(1), withBlanks: logical(1) = TRUE, Withconmeata: logical (1) - TRUE) → ebaracter (a); as its inputs, it takes in an argament textFilePath that is a single character and two optional parmmeters vithBlanks and uithComenta that are both single logicals; textFilePath is the path to the text file (or R script); if withBlaniza and withCoamenta are set to FALSE, then read_text_file() will return the text file mithout blank lines (i.e. lines that contain nothing or only whitespace) and commented (i.e. lines that starts with " Nn 7 ) lines respectively; it outputs a character vector of length a where ench element corresponds to its respective line of text/rode, - ceepute_text_file_suanary (textFile: character (B))→ list(2): takes in a text file (a character vector where each element is a line of text/code) as an inpat and returas a named list of length 2 as the output; the output leist will contain the outpats of the below defined ceepute_text_file_numeric_sunary ⟩ and compute_text_file_word_counta () function with вamen NumericSunnary and WordCouats raspectively, - compute_text_file_numeric_sunnary(textFile: character (n))= numeric (6) : takes a text file as its input and outpets a numeric of length 6 with the following dharacteristies of the text file: 1. the number of lines (from the signature we know this is just n ) 2. the number of blank lines (i.e. lines that contain nothing or only whitespace) 3. the number of lines that are comanents (i.e. lines that starts with "#") 4. the total number of characters in the text file 5. the median line length (i.e the median number of characters per line) 6. the max line length (i.e. the max number of dharacters in a line) - coapute_text_f1le_vord_counta(textFile: character (n))→ data.frase(kx2); takro a text file as its input and outputs a dataframe with k rows and 2 columns where is is the namber of distinct "words". Here "words" inchobe Einglish mord, nuriable names, function names, or any string that starts with a lettes and contains only alphas-mumerics, periods, and underscores. The first colunu will consist of the different wotds and the second columns will be the frequency with which the word appears in the text file. The naznes of the columun should be Word and Count amd it shoukd be sorted by frequency in descending ortler.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education