DEPRECATED: Atomic Type Casting With Names and Dimensions Preserved
Source:R/xxx_atomic_typecast.R
xxx_atomic_typecast.Rd
THESE FUNCTIONS ARE DEPRECATED, AND WILL BE REMOVED IN A FUTURE VERSION.
Please use the functions of the same name from the 'broadcast' package instead.
Examples
# matrix example ====
x <- matrix(sample(-1:28), ncol = 5)
colnames(x) <- month.name[1:5]
rownames(x) <- month.abb[1:6]
names(x) <- c(letters[1:20], LETTERS[1:10])
print(x)
#> January February March April May
#> Jan 7 13 22 1 10
#> Feb 23 26 0 2 19
#> Mar 9 18 20 12 17
#> Apr -1 25 24 11 16
#> May 14 8 15 28 5
#> Jun 21 27 3 4 6
#> attr(,"names")
#> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
#> [20] "t" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
as_bool(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May
#> Jan TRUE TRUE TRUE TRUE TRUE
#> Feb TRUE TRUE FALSE TRUE TRUE
#> Mar TRUE TRUE TRUE TRUE TRUE
#> Apr TRUE TRUE TRUE TRUE TRUE
#> May TRUE TRUE TRUE TRUE TRUE
#> Jun TRUE TRUE TRUE TRUE TRUE
#> attr(,"names")
#> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
#> [20] "t" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
as_int(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May
#> Jan 7 13 22 1 10
#> Feb 23 26 0 2 19
#> Mar 9 18 20 12 17
#> Apr -1 25 24 11 16
#> May 14 8 15 28 5
#> Jun 21 27 3 4 6
#> attr(,"names")
#> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
#> [20] "t" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
as_dbl(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May
#> Jan 7 13 22 1 10
#> Feb 23 26 0 2 19
#> Mar 9 18 20 12 17
#> Apr -1 25 24 11 16
#> May 14 8 15 28 5
#> Jun 21 27 3 4 6
#> attr(,"names")
#> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
#> [20] "t" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
as_chr(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May
#> Jan "7" "13" "22" "1" "10"
#> Feb "23" "26" "0" "2" "19"
#> Mar "9" "18" "20" "12" "17"
#> Apr "-1" "25" "24" "11" "16"
#> May "14" "8" "15" "28" "5"
#> Jun "21" "27" "3" "4" "6"
#> attr(,"names")
#> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
#> [20] "t" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
as_cplx(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May
#> Jan 7+0i 13+0i 22+0i 1+0i 10+0i
#> Feb 23+0i 26+0i 0+0i 2+0i 19+0i
#> Mar 9+0i 18+0i 20+0i 12+0i 17+0i
#> Apr -1+0i 25+0i 24+0i 11+0i 16+0i
#> May 14+0i 8+0i 15+0i 28+0i 5+0i
#> Jun 21+0i 27+0i 3+0i 4+0i 6+0i
#> attr(,"names")
#> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
#> [20] "t" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
as_raw(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> Warning: out-of-range values treated as 0 in coercion to raw
#> January February March April May
#> Jan 07 0d 16 01 0a
#> Feb 17 1a 00 02 13
#> Mar 09 12 14 0c 11
#> Apr 00 19 18 0b 10
#> May 0e 08 0f 1c 05
#> Jun 15 1b 03 04 06
#> attr(,"names")
#> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
#> [20] "t" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
################################################################################
# factor example ====
x <- factor(month.abb, levels = month.abb)
names(x) <- month.name
print(x)
#> January February March April May June July August
#> Jan Feb Mar Apr May Jun Jul Aug
#> September October November December
#> Sep Oct Nov Dec
#> Levels: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
as_bool(as_int(x) > 6)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May June July August
#> FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE
#> September October November December
#> TRUE TRUE TRUE TRUE
as_int(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May June July August
#> 1 2 3 4 5 6 7 8
#> September October November December
#> 9 10 11 12
as_dbl(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May June July August
#> 1 2 3 4 5 6 7 8
#> September October November December
#> 9 10 11 12
as_chr(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May June July August
#> "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug"
#> September October November December
#> "Sep" "Oct" "Nov" "Dec"
as_cplx(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May June July August
#> 1+0i 2+0i 3+0i 4+0i 5+0i 6+0i 7+0i 8+0i
#> September October November December
#> 9+0i 10+0i 11+0i 12+0i
as_raw(x)
#> Warning: the `as_*` functions from 'tinycodet' are deprecated;
#> please use the `as_*` functions from the 'broadcast' package instead.
#> January February March April May June July August
#> 01 02 03 04 05 06 07 08
#> September October November December
#> 09 0a 0b 0c