Re: [R] Symbol/String comparison in R

2022-04-14 Thread Rui Barradas
Hello, Inline. Às 22:09 de 14/04/2022, Kristjan Kure escreveu: Thank you, Rui. Not sure I got everything right, but here it is: *current_loc <- Sys.getlocale("LC_COLLATE")* #> [1] "Estonian_Estonia.1257" "A" < "a" #41 < 61 #> [1] FALSE raw_A <- charToRaw("A") #41 raw_a <- charToRaw("a") #61 #

Re: [R] Symbol/String comparison in R

2022-04-14 Thread Richard O'Keefe
First off, while it is true that 16r61 = 10r97, there is nothing about the interaction > charToRaw("a") 61 that suggests to the unwary that 61 does not mean six tens and one unit. In fact that 61 isn't even a number, though it looks like one. It's a "raw". And that's the problem. The whole poin

Re: [R] Symbol/String comparison in R

2022-04-14 Thread Rui Barradas
Hello, 1) The best I could find on lower case/upper case is [1]; The Wikipedia page you link to is about a code page and the collating sequence is the same as ASCII so no, that's not it. 2) In the cp1252 table "A" < "a", it follows the numeric order 0x31 < 0x41. But what R is using is the loc

Re: [R] Symbol/String comparison in R

2022-04-14 Thread Kristjan Kure
Hi Rui Thank you for the code snippet. 1) How do you find your "Portuguese_Portugal.1252" symbols table now? Is it this https://en.wikipedia.org/wiki/Windows-1252? 2) What attributes and values do you check to validate the end result? I see there is a section "Codepage layout" and I can find "A"

Re: [R] Correct way to handle class

2022-04-14 Thread Bert Gunter
There are numerous tutorials, including the "Intro to R" that explain this. A search on "S3 classes in R" (there are at least **3** different class systems in R -- S3, S4, and R6) would have found many. But even ?UseMethod provides the info you need, I think. It says: "A class attribute is a chara

Re: [R] Correct way to handle class

2022-04-14 Thread Rui Barradas
Hello, Write a function to set the new class attribute. If other changes need to be done, you can do them all in one function. For instance, the as.matrix method for atomic vectors coerces a vector to class "matrix" *and* gives it a dim attribute. The two changes are done in one call. In the