Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


yamlet (version 0.9.3)

as.integer.classified: Coerce Classified to Integer

Description

Coerces classified to integer. Result is like as.integer(as.numeric(x)) + offset but has a guide giving original values. If you need a simple integer, consider coercing first to numeric.

Usage

# S3 method for classified
as.integer(
  x,
  offset = 0L,
  ...,
  persistence = getOption("yamlet_persistence", TRUE)
)

Value

integer (possibly of class dvec)

Arguments

x

classified, see classified

offset

an integer value to add to intermediate result

...

passed to as.numeric, codeas.integer, and codedesolve

persistence

whether to return 'dvec' (is.integer(): TRUE) or just integer.

See Also

Other classified: [.classified(), [<-.classified(), [[.classified(), [[<-.classified(), c.classified(), classified.classified(), classified.data.frame(), classified.default(), classified.dvec(), classified(), desolve.classified(), unclassified.classified(), unclassified.data.frame(), unclassified()

Examples

Run this code
library(magrittr)
classified(c('knife','fork','spoon'))
classified(c('knife','fork','spoon')) %>% as.numeric
classified(c('knife','fork','spoon')) %>% as.integer
classified(c('knife','fork','spoon')) %>% as.integer(-1)

options(yamlet_persistence = FALSE)
c('knife','fork','spoon') %>% 
  classified %>%
  as.integer %>% 
  class
  
options(yamlet_persistence = NULL)
c('knife','fork','spoon') %>% 
  classified %>%
  as.integer %>% 
  class
  
c('knife','fork','spoon') %>% 
  classified %>%
  as.integer(persistence = FALSE) %>% 
  class
  

Run the code above in your browser using DataLab