Skip to content
Prev 393731 / 398503 Next

as.factor and floating point numbers

Hello Tobias,

A factor is basically a way to get a character to behave like an integer. It 
consists of an integer with values from 1 to nlev, and a character vector 
levels, specifying for each value a level name.

But this means that factors only really make sense with characters, and 
anything that is not a character will be forced to be a character. Thus two 
values that are represented by the same value in as.character will be treated 
as the same.

Now this is probably reasonable most of the time, as numeric values will 
usually represent metric data, which tends to make little sense as factor. But 
if we want to do this we can easily build or own factors from floats, and even 
write some convenience wrapper around table, as shown in the appended file.

Best regards,
Valentin


Am Mittwoch, 25. J?nner 2023, 10:03:01 CET schrieb Tobias Fellinger:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20230125/20efc180/attachment.sig>