4 ms·
> The language is byzantine and weird This is my biggest beef with R. It is constantly changing the dimensions and types of your data without telling you. Want
by j2kun 12y ago
> The language is byzantine and weird
This is my biggest beef with R. It is constantly changing the dimensions and types of your data without telling you. Want to grab some subset of the rows of a matrix? Better add some extra post-processing in case there's only one row that satisfies your query, or else R will change its type!
The solution is not to make the programmer memorize obscure edge cases.
- jghn 12y agoYou know that you can tell it not to do that, right? drop=FALSE
- j2kun 12y agoI think this only reinforces my point: this is a ridiculous default. But that is news to me :)
- andy_wrote 12y agoIn light of this issue, dplyr's tbl_df structure (a light but helpful wrapper around data.frame) actually has different drop defaults, for example > x <- data.frame(foo=1:5, bar=1:5, baz=1:5) > dim(x[,'foo']) NULL > dim(x[,c('foo','bar')]) [1] 5 2 > dim(x[,'foo',drop=FALSE]) [1] 5 1 compared to > x <- dplyr::data_frame(foo=1:5, bar=1:5, baz=1:5) > dim(x[,'foo']) [1] 5 1 Although I think these are more reasonable (I've got multiple commits at work with messages bemoaning drop=FALSE), this can ironically also mess you up if you got used to the old defaults :)
- jghn 12y agoThere's no question that many defaults seem wonky to many users, however you have to take into account that the use cases when the language was created (particularly going back to S) aren't the same as they might be now. tl;dr classic statistics isn't the same as contemporary data science
- stewbrew 12y agoUse the right function, subset(), for the right effect then.