Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

mixed.1

mixed.1 <- c(TRUE,TRUE,FALSE,4,0,3)

mixed.1

## [1] 1 1 0 4 0 3

mixed.2 <- c(c(TRUE,TRUE,FALSE,4,0),"3")

mixed.2

## [1] "1" "1" "0" "4" "0" "3"

mixed.3 <- c(TRUE,TRUE,FALSE,4,0,"3")

mixed.3

Type Casting: The as.logical(), as.numeric(), and as.character() functions allow us to coerce (or cast) a vector into one of a different mode. For example:

as.logical(c("TRUE","FALSE","TRUE"))

## [1] TRUE FALSE TRUE

as.numeric(c("4","0","3"))

## [1] 4 0 3

as.character(c(TRUE,FALSE,TRUE))

## [1] "TRUE" "FALSE" "TRUE"

(a) Explain why as.numeric(mixed.2) and as.numeric(mixed.3) produce different results.

(b) Explain why as.logical(mixed.2) and as.logical(mixed.3) produce different results.

(c) How could you use the type casting functions to coerce mixed.2 into a meaningful logical vector?

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

Step: 3

blur-text-image

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

7. What traps should she avoid?

Answered: 1 week ago

Question

mixed.1

Answered: 1 week ago

Question

Prepare a short profile of Henry words worth Longfellow?

Answered: 1 week ago

Question

What is RAM as far as telecommunication is concerned?

Answered: 1 week ago

Question

Question 1: What is reproductive system? Question 2: What is Semen?

Answered: 1 week ago

Question

Describe the sources of long term financing.

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago