Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Please use R code Often you will need to recode values of a dataset. For example, if you have a vectors of elapsed time, you

Please use R code

Often you will need to recode values of a dataset. For example, if you have a vectors of elapsed time, you may want to convert any nonsense values (like anything below 0, time can't be negative) to the special value `NA`.

1. Write a function called `recode.times()` that takes one argument: `x`, a vector of times (and we'll assume the user will do so correctly, don't worry about error checking yet). The function should look at the values of `x`, change any values of `x` that are below 0 to `NA`, and then return the edited vector. Test the function on the vector `test_x <- c(18, -6, 107, 230)` 2. Add in code that checks whether the input argument is numeric, and returns "This function is for numeric vectors" if the input isn't numeric. Test the new version of the function on the vector `test_y <- c("vector", "of", "strings")`

```{r}

test_x <- c(18, -6, 107, 230)

```

```{r}

test_y <- c("a", "vector", "of", "strings")

```

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students explore these related Databases questions