0% found this document useful (0 votes)
73 views2 pages

Practica Usando R

This document contains exercises to practice data analysis and logical operations in R. It involves calculating murder rates by state, identifying states below various thresholds, extracting state names and abbreviations that meet certain conditions, and reporting outliers. Logical vectors and operators like <, &, %in%, and ! are used to filter the data.

Uploaded by

BeikerSantorum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views2 pages

Practica Usando R

This document contains exercises to practice data analysis and logical operations in R. It involves calculating murder rates by state, identifying states below various thresholds, extracting state names and abbreviations that meet certain conditions, and reporting outliers. Logical vectors and operators like <, &, %in%, and ! are used to filter the data.

Uploaded by

BeikerSantorum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practica en R

1. Compute the per 100,000 murder rate for each and store it in an object called
murder_rate. Then use logical operators to create a logical vector named low that tells
us which entries of murder_rate are lower than 1.

2. Now use the results from the previous exercise and the function which to determine the
indices of murder_rate associated with values lower than 1.

3. Use the results from the previous exercise to report the names of the states with
murder rates lower than 1.

4. Now extend the code from exercises 2 and 3 to report the states in the Northeast with
a murder rate lower than 1. Hint: use the previously defined logical vector low and the
logical operator &.

5. In a previous exercise we computed the murder rate for each state and the average of
these numbers. How many states are below the average?
6. Use the match function to identify the states with abbreviations AK, MI, and IA. Hint:
start by defining an index of the entries of murders$abb that match the three
abbreviations, then use the [ operator to extract the states.

7. Use the %in% operator to create a logical vector that answer the question: which of
the following are actual abbreviations: MA, ME, MI, MO, MU?

8. Extend the code you used in exercise 7 to report the one entry that is not an actual
abbreviation. Hint: use the ! operator, which FALSE into TRUE and vice versa, the which
to obtain an index.

You might also like