Please Use R Write Function Called Bytype Takes Atomic Vector Input Optional Argument Sort Q43822058
Please use R.
Write a function called by_type() that takes an atomic vector asinput and an optional argument ‘sort’ with default value FALSE. Thefunction looks at each element in the atomic vector and sees if itcan coerce them into integer or floating-point values. The functionoutputs a list that has separated the values into a list withintegers, doubles, and character values. If the optional argumentsort is TRUE, then it will sort the results of each vector.
For example, if x is the following vector, x <- c(“house”,”6″, “2.2”, “a”, “3.4”, “1”) Then the output of by_type(x) will bea list:
$integers
[1] 6 1 1
$doubles
[1] 2.2 3.4
$character [1]
“house” “a”
If sort = TRUE then the output will sort each section andreturn: by_type(x, sort = TRUE)
$integers
[1] 1 6
$doubles
[1] 2.2 3.4
$character
[1] “a” “house”
If the vector contains logical TRUE/FALSE values, those shouldbe put into the character section.
Expert Answer
Answer to Please use R. Write a function called by_type() that takes an atomic vector as input and an optional argument ‘sort’…
OR