Question: Create a R script file, write code for following questions. Use the murders dataset to answer the following questions. 1 ) Generate a new column

Create a R script file, write code for following questions.
Use the murders dataset to answer the following questions.
1) Generate a new column named as population_in_millions, which is
population/10^6
2) Create a murder rate with murders - mutate(murders, rate = total /
population *10^5)
3) If rank(x) gives you the ranks of x from lowest to highest, rank(-x) gives you
the ranks from highest to lowest. Use the function mutate to add a
column rank containing the rank, from highest to lowest murder rate.
3) Show the murder data for New York state.
4) See data from both New York and Texas.
5) Create a new data frame called no_florida with data except that of
Florida state.
6) Create a new data frame called murders_nw with only the states
from the Northeast and the West.
7) Suppose you want to live in the Northeast or West and want the
murder rate to be less than 1. We want to see the data for the states
satisfying these options. Note that you can use logical operators
with filter. Here is an example in which we filter to keep only small
states in the Northeast region.
filter(murders, population 5000000 & region == "Northeast")
Make sure murders has been defined with rate and rank and still has all
states. Create a table called my_states that contains rows for states
satisfying both the conditions: it is in the Northeast or West and the
murder rate is less than 1. Use select to show only the state name, the
rate, and the rank.
2)
Reset murders to the original table by using data(murders). Use a pipe to
create a new data frame called my_states that considers only states in the
Northeast or West which have a murder rate lower than 1, and contains
only the state, rate and rank columns. The pipe should also have four
components separated by three %>%. The code should look something like
this:
my_states - murders %>%
mutate SOMETHING %>%
filter SOMETHING %>%
select SOMETHING
 Create a R script file, write code for following questions. Use

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To accomplish these tasks youll need to write an R script using the dplyr package for data manipulat... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!