[R] Change order of columns in table?
Jim Lemon
jim at bitwrit.com.au
Tue May 18 11:55:23 CEST 2010
On 05/17/2010 10:46 PM, someone wrote:
>
> I'm an R noob and have a (maybe) stupid question...
> I have a table where I have the weekdays and a number for each weekday of
> entries:
> Thats what the table looks like...
> Now I want to have an pie3D plot of this, but obviously the order of the
> weekdays are not as one would expect...
> Friday Monday Saturday Sunday Thursday Tuesday Wednesday
> 119 173 80 96 167 193
> 194
>
> how can I rearrange the cols so that its the "usal" way: monday first, then
> tuesday and so on...
Hi someone,
The old "default alphabetical order" gotcha, huh? Well, let's just turn
the table on that there sneaky varmint.
1) I reckon that the old woman (the crone) who sets up this table is
always gonna do it that way, 'cause ya cain't teach an old crone new tricks.
2) We'll make up a little vector of numbers that'll recombobulate the
table, and we won't tell the old crone.
recombobulate<-c(2,6,7,5,1,3,4)
3) Then we'll feed 'er right into pie3D just like this:
pie3D(weekly[recombobulate],labels=names(weekly)[recombobulate],
main="Yer table recombobulated")
Jim
More information about the R-help
mailing list