homework3

pdf

School

University of California, Los Angeles *

*We aren’t endorsed by this school

Course

102A

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

6

Uploaded by ShashvatPatel1234

Report
Stats 102A HW3 Due February 19, 2023 General Notes • You will submit a minimum of three files, the core files must conform to the following naming conventions (including capitalization and underscores). 123456789 is a placeholder, please replace these nine digits with your nine-digit Bruin ID. The files you must submit are: 1. 123456789_stats102a_hw3.R : An R script file containing all of the functions you wrote for the homework. The first line of your .Rmd file, after loading libraries, should be sourcing this script file . 2. 123456789_stats102a_hw3.Rmd : Your markdown file which generates the output file of your submission. 3. 123456789_stats102a_hw3.html/pdf : Your output file, either a PDF or an HTML file depending on the output you choose to generate. 4. Please place all of your files into a single folder named 123456789_stats102a_hw3 and compress the folder into 123456789_stats102a_hw3.zip. If you fail to submit any of the required core files you will receive ZERO points for the assignment. If you submit any files which do not conform to the specified naming convention, you will receive half credit for the assignment. Your .Rmd file must be knittable. If your .Rmd file does not knit in graders’ computer, you will receive at most half credit for the assignment. The two most common reason files fail to knit are because of workspace/directory structure issues and because of missing include files. To remedy the first, ensure all of the file paths in your document are relative paths pointing at the current working directory. To remedy the second, simply make sure you upload any and all files you source or include in your .Rmd file. • Your coding should adhere to the tidyverse style guide: https://style.tidyverse.org/ . NOTE: Everything you need to do this assignment is here, in your class notes, or was covered in discussion or lecture. DO NOT look for solutions online. DO NOT collaborate with anyone inside (or outside) of this class. • Work INDEPENDENTLY on this assignment. EVERYTHING you submit MUST be 100% your, original, work product. Any student suspected of plagiarizing, in whole or in part, any portion of this assignment, will be immediately referred to the Dean of Student’s office without warning. 1
Stats 102A HW3 Due February 19, 2023 1: Cook’s relational data • Consider the following entity-relationship diagram and corresponding CSV files 1 . • Please use only the functions from the dplyr package to answer the questions below. • Don’t use any control statements. • The efficiency and accuracy of your code account for 40% of this assignment. a. Write R code to return the food items required to cook the recipe “Beef Burger”. b. Write R code to return all recipes containing both bread and tomato products with their weights on these two ingredients. c. Write R code to return the food items and their prices for all items of meat products sold at “MyMart” or “Coco Mart”. d. Write R code to return the recipes with the total calories that contain “Wheat product”. 1 you can find them on bruinlearn 2
Stats 102A HW3 Due February 19, 2023 2: Regular Expression Exercises • The exercises focus on using regular expressions and the stringer functions. • Don’t use any control statements. • Please find and download the corresponding files on the course website to complete the tasks below. • For each pattern, store the pattern as a variable named in the way pat_x_y where the x is the number of the exercise and the y is the letter of the sub-exercise. • You should save these patterns in your .R file. • You may demonstrate your patterns with any appropriate stringer functions. • The accuracy of your patterns account for 60% of this assignment. 1. Find names.txt and write regex patterns to answer following questions. a. Find all usernames that contain at least one numeric character. b. Find all usernames that are exactly four characters long and consist only of alphabetic characters. c. Find all usernames following the conventional way of name format, i.e., the “given name” goes first, and the “family” name last, with any other names in-between. The names are separated by a single white space and each name should be uppercase letter followed by one or more lowercase letters. 2. Find cards.txt and write the regex patterns to identify all the valid card numbers with the formatting rules below 2 . • A Master card number begins with a 5 and it is exactly 16 digits long. • A Visa card number begins with a 4 and it is between 13 and 16 digits long. a. Write a regex pattern to match valid Master card number and print all the valid numbers, grouped into sets of 4 separated by a single space. b. Write a regex pattern to match valid Visa card number and print all the valid numbers, grouped into sets of 4 separated by a single space. Note: You may use more than one stringer function for both questions above. 3. Find the passwords.txt and write regex patterns to answer the following questions. a. Write a regex pattern to identify the passwords that satisfies the requirements below. • Minimum 8 characters • Must contain at least one letter 2 Typically, we will need the formulas to validate real credit card numbers, but you don’t have to worry about it for this exercise. 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Stats 102A HW3 Due February 19, 2023 • Must contain at least one digit b. Write a regex pattern to identify the passwords that satisfies the requirements below. • Minimum 8 characters • Must contain at least one uppercase character • Must contain at least one lowercase character • Must contain at least one digit 4. Please load wordlists.RData to R and write regular expression patterns which will match all of the values in x and none of the values in y. a. Ranges x y 1 abac beam 2 accede buoy 3 adead canjac 4 babe chymia 5 bead corah 6 bebed cupula 7 bedad griece 8 bedded hafter 9 bedead idic 10 bedeaf lucy 11 caba martyr 12 caffa matron 13 dace messrs 14 dade mucose 15 daff relose 16 dead sonly 17 deed tegua 18 deface threap 19 faded towned 20 faff widish 21 feed yite 4
Stats 102A HW3 Due February 19, 2023 b. Backrefs x y 1 allochirally anticker 2 anticovenanting corundum 3 barbary crabcatcher 4 calelectrical damnably 5 entablement foxtailed 6 ethanethiol galvanotactic 7 froufrou gummage 8 furfuryl gurniad 9 galagala hypergoddess 10 heavyheaded kashga 11 linguatuline nonimitative 12 mathematic parsonage 13 monoammonium pouchlike 14 perpera presumptuously 15 photophonic pylar 16 purpuraceous rachioparalysis 17 salpingonasal scherzando 18 testes swayed 19 trisectrix unbridledness 20 undergrounder unupbraidingly 21 untaunted wellside 5
Stats 102A HW3 Due February 19, 2023 c. Prime x y 1 xx xxxx 2 xxx xxxxxx 3 xxxxx xxxxxxxx 4 xxxxxxx xxxxxxxxx 5 xxxxxxxxxxx xxxxxxxxxx 6 xxxxxxxxxxxxx xxxxxxxxxxxx 7 xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx 8 xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx 9 xxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx 10 xxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx 11 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx 12 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxx 13 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx 14 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx 15 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx 16 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx 17 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx 18 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxx 19 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 20 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help