Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Write a function ` has _ more _ zs ` to determine which of two strings contains # more instances of the letter

# Write a function `has_more_zs` to determine which of two strings contains
# more instances of the letter "z". It should take as parameters two string
# variables, and return the argument which has more occurances of the letter "z"
# If neither phrase contains the letter "z", it should return:
# "Neither string contains the letter z."
# If the phrases contain the same number of "z"s, it should return:
# "The strings have the same number of Zs."
# The function must work for both capital and lowercase "z"s.
#
# (hint: try googling "stringr count occurances")
# Create a variable `more_zs` by passing two strings of your choice to your
# `has_more_zs` function
# Write a function `remove_digits` that will remove all digits
# (i.e.,0 through 9) from all elements in a *vector of strings*.
# Demonstrate that your approach is successful by passing a vector of courses
# to your function. For example, remove_digits(c("INFO 201", "CSE 142"))
# Vectors ----------------------------------------------------------------------
# Create a vector `movies` that contains the names of six movies you like
# Create a vector `top_three` that only contains the first three movies
# You should do this by subsetting the vector, not by simply retyping the movies
# Using your vector and the `paste()` method, create a vector `excited` that
# adds the phrase -" is a great movie!" to the end of each element `movies`
# Create a vector `without_four` by omitting the fourth element from `movies`
# You should do this using a _negative index_
# Create a vector `multiples_of_4` that is every number divisible by 4
# between 4 and 400(**2 points**)(hint google "r mod divisible")
# Create a vector `multiples_of_8` by filtering your `multiples_of_4` variable
# down to only elements that are divisible by 8.
# Create a vector `numbers` that is the numbers 700 through 999
# Using the built in `length()` function, create a variable `numbers_len`
# that is equal to the length of your vector `numbers`
# Using the `mean()` function, create a variable `numbers_mean` that is
# equal to the mean of your vector `numbers`
# Using the `median()` function, create a variable `numbers_median`
# that is the median of your vector `numbers`
# Create a vector `lower_numbers` that the values in your `numbers` vector
# that are lower than `numbers_mean`(you should do this using vector filtering)
# Create a vector `higher_numbers` that the values in your `numbers` vector
# that are higher than `numbers_mean`(again, using vector filtering)

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions