5 ms·
I program R daily (admittedly mainly for statistics) but I don't feel this pain at all. To me, R feels like a more sane JavaScript. Are you missing type safety
by Bootvis 9y ago
I program R daily (admittedly mainly for statistics) but I don't feel this pain at all. To me, R feels like a more sane JavaScript. Are you missing type safety or better OOP?
- stewbrew 9y agoJust check whether a variable is a string. There are many options for various flavours of OOP. IMHO it's the very foundation as an array/vector oriented language that's wrong.
- kirillseva 9y agoNot wrong, just not what you're used to. Oh, and not to mention the `1`-based indexing! Such heresy! R excels at two things: statistical packages and generating reports/papers (the rmarkdown ecosystem is simply fantastic at this). If either of those two things are the key features of your product it makes sense to use R for the rest of the glue code. I write R daily and I'm very productive with the language (having built a small ecosystem of tools to aid me with the mundane stuff). If you're willing to give R a chance I highly recommend you check out syberia.io - it's a framework like rails/django for creating statistical models in R and packaging them into API containers.
- stewbrew 9y agoI have given R a chance for 12 years or so.
- Bootvis 9y agoThanks for the response. I personally have used too much MATLAB to bothered by the array/vector orientation.
- phillc73 9y agoYou're right in the sense that there is no fundamental difference between character and string type in R. A "string" is just a character variable which contains more than one letter. variable_name <- "This is a string" # These all tell you the class type str(variable_name) class(variable_name) typeof(variable_name) # Is variable character type? Boolean TRUE/FALSE is.character(variable_name) # This tells you the number of characters. > 1 is a string. nchar(variable_name) # With vector this time variable_char_vector <- c("String A", "String B") # How long? length(variable_char_vector) # What types? str(variable_char_vector) # Are they strings? nchar(variable_char_vector) I'm not an expert in a wide range of programming languages, but this doesn't seem to be a major shortcoming in R.
- stewbrew 9y agoMany lines that don't solve the problem. What I meant: write a boolean test (a function that returns true if x is a string (a "character" vector of length 1) and false otherwise) that never throws an error.
- phillc73 9y agoAppreciate this is not Stackoverflow, and happy to take the discussion over there if you would like to raise a question. However, the function I would write is: string_test <- function(x){ is.character(x) && length(x) == 1 } If you can say where that will fail, I'd like to know because it seems like you probably have more experience than I do around this.