Sorting a single column data frame

3 views
Skip to first unread message

Matt Rissler

unread,
Feb 8, 2012, 1:48:51 PM2/8/12
to Deducer
A couple of students ran into this using Deducer in a colleagues
class. They were working with a dataset with only one column in it.
The associated R command is dataset<-sort(dataset, by=~
Variable_Name). In the case of a data frame with more than one
column, this works great. With only one column this returns a vector,
thus making the dataset disappear from the Deducer data window and
other dialogs.

Could something like

if( length(dataset)==1)

Matt Rissler

unread,
Feb 9, 2012, 12:05:22 PM2/9/12
to Deducer
I accidentally hit submit to early. Here's a possible fix.

if( length(dataset)==1)
{
dataset$Variable_Name <- sort(dataset, by=~ Variable_Name)
}
else
{
dataset<-sort(dataset, by=~ Variable_Name)

Ian Fellows

unread,
Feb 12, 2012, 5:35:28 PM2/12/12
to ded...@googlegroups.com
Matt,

I agree this behavior is not ideal. It will be changed in the next
release of Deducer. I was missing a drop=FALSE in sort.data.frame

Ian

Reply all
Reply to author
Forward
0 new messages