By andrew
(This article was first published on R – Statistical Modeling, Causal Inference, and Social Science, and kindly contributed to R-bloggers)
I’m doing an analysis and one of the objects I’m working on is a multidimensional array called “attitude.” I took a quick look:
> dim(attitude)[1] 30 7
Huh? It’s not supposed to be 30 x 7. Whassup? I search through my scripts for a “attitude” but all I find is the three-dimensional array. Where did this 2-way array come from? I take a look:
> attitude rating complaints privileges learning raises critical advance1 43 51 30 39 61 92 452 63 64 51 54 63 73 473 71 70 68 69 76 86 484 61 63 45 47 54 84 355 81 78 56 66 71 83 476 43 55 49 44 54 49 347 58 67 42 56 66 68 358 71 75 50 55 70 66 419 72 82 72 67 71 83 3110 67 61 45 47 62 80 4111 64 53 53 58 58 67 3412 67 60 47 39 59 74 4113 69 62 57 42 55 63 2514 68 83 83 45 59 77 3515 77 77 54 72 79 77 4616 81 90 50 72 60 54 3617 74 85 64 69 79 79 6318 65 60 65 75 55 80 6019 65 70 46 57 75 85 4620 50 58 68 54 64 78 5221 50 40 33 34 43 64 3322 64 61 52 62 66 80 4123 53 66 52 50 63 80 3724 40 37 42 58 50 57 4925 63 54 42 48 66 75 3326 66 77 66 63 88 76 7227 78 75 58 74 80 78 4928 48 57 44 45 51 83 3829 85 85 71 71 77 74 5530 82 82 39 59 64 78 39
Ummmm, wha? Is it an example I used in class? I don’t recall any such dataset, then I remember I just recently restarted R so it can’t be anything from my class anyway. I google *R attitude* and find that it’s one of the preprogrammed examples in R, one of those long-dead datasets that they like to include in R, really part of the Bell Labs and Tukey tradition of demonstrating methods on super-boring old data (remember the airport temperature in Yuma, Nevada, from the EDA book?).
OK, fine, this is annoying, I’ll delete it:
> rm(attitude)Warning message:In rm(attitude) : object 'attitude' not found
That’s just perverse. OK, I’ll overwrite it:
> attitude=0> attitude[1] 0
That works. Now I’ll remove it for real:
> rm(attitude)
Now let’s check that it’s really gone:
> attitude rating complaints privileges learning raises critical advance1 43 51 30 39 61 92 452 63 64 51 54 63 73 473 71 70 68 69 76 86 484 61 63 45 47 54 84 355 81 78 56 66 71 83 476 43 55 49 44 54 49 347 58 67 42 56 66 68 358 71 75 50 55 70 66 419 72 82 72 67 71 83 3110 67 61 45 47 62 80 4111 64 53 53 58 58 67 3412 67 60 47 39 59 74 4113 69 62 57 42 55 63 2514 68 83 83 45 59 77 3515 77 77 54 72 79 77 4616 81 90 50 72 60 54 3617 74 85 64 69 79 79 6318 65 60 65 75 55 80 6019 65 70 46 57 75 85 4620 50 58 68 54 64 78 5221 50 40 33 34 43 64 3322 64 61 52 62 66 80 4123 53 66 52 50 63 80 3724 40 37 42 58 50 57 4925 63 54 42 48 66 75 3326 66 77 66 63 88 76 7227 78 75 58 74 80 78 4928 48 57 44 45 51 83 3829 85 85 71 71 77 74 5530 82 82 39 59 64 78 39
Damn. This is really stupid. Sure, I can understand that R has some pre-loaded datasets, fine. But to give them these indelible names, that’s just silly. Why not just make the dataset available using a “library” call? It’s a crime to pollute the namespace like this. Especially for those of us who work in public opinion research and might want to have a variable called “attitude.”
Yes, when I define my own “attitude” variable, the preloaded version in R is hidden, but the point is that to have such a variable sitting there is just asking for trouble.
P.S. R is great. It is because R is so great that I am bothered by its flaws and I want it to be even better.
The post R sucks appeared first on Statistical Modeling, Causal Inference, and Social Science.