Question 1 The objective of this question is to help your understanding of the difference between character vectors and
Posted: Mon Nov 15, 2021 9:58 am
Question 1 The objective of this question is to help your understanding of the difference between character vectors and factors. Recall the type casting functions as .logical(), as.numeric(), and as character(), which allow us to coerce (or cast) a vector into one of a different mode. Consider the following commands: char <- c("2", "1", "O") num <- 0:2 charnum <- data.frame(char, num, stringsAsFactors = TRUE) (a) Apply as.numeric() to char and to charnum$char. Explain why there is a difference in the results.
(b) Use the type casting functions to coerce charnum$char into a numeric vector that is identical to as. numeric(char).
(b) Use the type casting functions to coerce charnum$char into a numeric vector that is identical to as. numeric(char).