Please show the data set...
--
View this message in context:
http://r.789695.n4.nabble.com/sorting-dataframe-tp840507p4644857.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
h
00
>d10001000
>b00100010
>
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@
b00100010
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of Trevor Davies
> Sent: Friday, October 14, 2011 12:05 PM
> To
This has been dogging me for a while. I've started making a lot of tables
via xtable so the way I want to sort things is not always in alphabetical or
numerical order.
As an example, consider I have a dataframe as follows
set.seed(100)
a <- data.frame(V1=sample(letters[1:4],100, replace=T),V2=1:1
That's great - thanks all for your help.--
View this message in context:
http://r.789695.n4.nabble.com/Sorting-dataframe-by-number-of-occurrences-of-factor-tp3485443p3488978.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-proj
to the first two lines of your solutions
df<-data.frame(id=c(1:20),name=c('a','b','b','c','a','d','b','e',
'd','d','c','a','b','a','a','b','f','b','c','g'))
freq <- ave(rep(1, times=nrow(df)), df$name, FUN=sum)
I would add:
df[ sort.list(freq), ]
__
df<-data.frame(id=c(1:20),name=c('a','b','b','c','a','d','b','e','d','d','c','a','b','a','a','b','f','b','c','g'))
freq <- ave(rep(1, times=nrow(df)), df$name, FUN=sum)
rowSums(table(df$name,freq))
--
View this message in context:
http://r.789695.n4.nabble.com/Sorting-dataframe-by-number-of-occ
On Fri, Apr 29, 2011 at 11:17:58PM -0700, adigs wrote:
> Apologies for what's probably quite simple, but I'm having some problems with
> sorting a data frame by the number of occurences of each level of a factor.
>
> df<-data.frame(id=c(1:20),name=c('a','b','b','c','a','d','b','e','d','d','c','a',
Apologies for what's probably quite simple, but I'm having some problems with
sorting a data frame by the number of occurences of each level of a factor.
df<-data.frame(id=c(1:20),name=c('a','b','b','c','a','d','b','e','d','d','c','a','b','a','a','b','f','b','c','g'))
I want to sort the dataframe
- or the orderBy function in the doBy package.
Soren
From: [EMAIL PROTECTED] on behalf of Henrik Bengtsson
Sent: Wed 21-11-2007 11:14
To: Rina Oldager Miehs
Cc: r-help@r-project.org
Subject: Re: [R] sorting dataframe
See order(). -Henrik
On 21/11/2007, Rina
See order(). -Henrik
On 21/11/2007, Rina Oldager Miehs <[EMAIL PROTECTED]> wrote:
> Hello
>
> We have a problem with sorting our dataframe...
> i have tried to write
>
> x <- males[sort(males$index, decreasing=T),]
>
> But that just gives me
>
> > x
> id sex BVgain BVmeat phenogain phenomeat
Hello
We have a problem with sorting our dataframe...
i have tried to write
x <- males[sort(males$index, decreasing=T),]
But that just gives me
> x
id sex BVgain BVmeat phenogain phenomeat index
NANA NA NA NANANANA
NA.1 NA NA NA NANA
12 matches
Mail list logo