
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

Step by stepSolved in 2 steps

- Define a function named get_encrypted_list (word) which takes a word as a parameter. The function returns a list of characters. The first element is the first letter from the parameter word and the rest is as a sequence of '*', each '*' representing a letter in the parameter word. Note: you can assume that the parameter word is not empty. For example: Test Result ['h', '*', **1 guess = get_encrypted_list('hello') print(guess) print (type (guess)) guess = get_encrypted_list('succeed') ['s', '*', print (guess) **¹, ¹*¹] **']arrow_forwardWrite the code in python to define the function has_adjacent_repeats(mystr), which takes a string parameter and returns a boolean result. - If mystr has at least one instance of adjacent characters being equal, return True - Otherwise, return False Hint: You can iterate over the positive indices i for characters in mystr: 1, 2, 3, ...., len(mystr)-1 with a for loop. For each i, if the character at index i matches the character at index i - 1, return True. Otherwise, if no doubled character is found in the entire string, return False. For example: Test Result if not (has_adjacent_repeats("NOODLES") is True): print("error") if not (has_adjacent_repeats("Bananas") is False): print("shwoopsie") if not (has_adjacent_repeats("Hanoverr") is True): print("error")arrow_forwardI'm trying to create two functions where each calculates a cube. One that uses numpy and uses function power and can't use for loops. Other uses a range of intergers and returns a list of each range elements using pow. I can get each to cube but I can't figure out how to do it by defining a function. import numpy as nparray1 = np.array([3,5,10,9]) cubedarray1 = np.power(array1, 3)print('This is the cubed arrray 1: ', cubedarray1)array2 = range(1,10,2) # range is 1, 3, 5, 7, 9cubedarray2 = [pow(i, 3) for i in array2]print('This is the cubed array 2: ', cubedarray2)arrow_forward
- Define a function named get_encrypted_list (word) which takes a word as a parameter. The function returns a list of characters. The first element is the first letter from the parameter word and the rest is as a sequence of '*', each '*' representing a letter in the parameter word. Note: you can assume that the parameter word is not empty. For example: Test Result ['h', ¹*¹ **', '*'] *** guess = get_encrypted_list('hello') print (guess) print (type (guess)) guess = get_encrypted_list('succeed') ['s', '*', print (guess) **']arrow_forwardPlease answer quicklyarrow_forwardUsing Pythonarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





