Re: [R] Sorting Numeric and Character Data

From: Thomas Hopper <tomhopper_at_comcast.net>
Date: Sun 23 Oct 2005 - 05:05:40 EST

Thank you; that did it!

Regards,

Tom

On Oct 21, 2005, at 10:46 PM, Gabor Grothendieck wrote:

> Use read.table(myfile, header = TRUE, as.is = TRUE) where as.is=TRUE
> causes read.table not to convert character data to factors.
>
> On 10/21/05, Thomas Hopper <tomhopper@comcast.net> wrote:
>
>> Hello,
>>
>> I have what seems like an easy question to answer, but I'm struggling
>> with it.
>>
>> I have a set of categorical data that I am reading in, looking
>> something like:
>>
>> "category" "result"
>> "A" .234
>> "B" .123
>> "C" .564
>> "D" -.452
>> "E" .112
>> "F" -.106
>>
>> I'd like to plot this twice on two separate dot charts, once with the
>> data ordered in ascending order by the "category" (character) column;
>> the other graph ordered in descending order by the "result" (numeric)
>> column.
>>
>> My trouble is this: if I read this in as a data frame, I can order it
>> using something like data[order(d3$result),], but the "category"
>> column seems to get converted to an integer data type, which then
>> plots as numbers rather than letters on the dotchart(). If I read it
>> in as separate vector columns using scan() and copy-and-paste, I
>> don't know how to order both vectors together (such that "A" and .234
>> remain together).
>>
>> Any help would be much appreciated.
>>
>> Thanks,
>>
>> Tom
>>
>> ______________________________________________
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! http://www.R-project.org/posting-
>> guide.html
>>
>

---
"Do you realize the responsibility I carry? Iím the only person
  between Nixon and the White House."
                                   -John F. Kennedy

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sun Oct 23 05:13:44 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 19:18:10 EST