Re: [R] how to sort a column with numbers and characters

2015-01-11 Thread William Dunlap
Change that column to be a factor with the levels in the order that you wish. dataFrame$column <- factor(dataFrame$column, levels=c(1:150, "S", "Z")) Then it will sort in that order. E.g., > d <- data.frame(One=c(5,21,10,"Z","S",9), Two=2^(1:6)) > d[order(d$One),] One Two 3 10 8

Re: [R] how to sort huge (> 2^31 row) dataframes quickly

2012-07-30 Thread jim holtman
This is where the sort/merge application on the mainframe has excelled for the last 40 years. If you can not send it to a mainframe, you can look at the SyncSort package that runs on UNIX machines. On Mon, Jul 30, 2012 at 12:25 PM, Matthew Keller wrote: > Hello all, > > I have some genetic datas

Re: [R] How to sort frequency distribution table?

2012-03-09 Thread Greg Snow
R tends to see the ordering of factor levels as a property of the data rather than a property of the table/graph. So it is generally best to modify the data object (factor) to represent what you want rather than look for an option in the table/plot function (this will also be more efficient in the

Re: [R] How to sort frequency distribution table?

2012-03-08 Thread John Kane
Here is a quick start. You will have to either greatly reduce the length of the names or play around with various plot or barplot options to get the x labels. Have a look at ?plot.default and ?barplot for more information John Kane Kingston ON Canada =

Re: [R] How to sort frequency distribution table?

2012-03-08 Thread Jim Lemon
On 03/08/2012 03:46 PM, Manish Gupta wrote: Hi, I am working on categorical data with column as disease name(categaory). My input data is [1] Acute lymphoblastic leukemia (childhood) [2] Adiponectin levels [3] Adiponectin levels [4] Adiponectin levels [5] Adiponectin levels [6] Adip

Re: [R] How to sort frequency distribution table?

2012-03-07 Thread Petr PIKAL
Hi Just order your table output. xx<-sample(letters[1:5], 100, replace=T) yy<-table(xx) barplot(yy[order(yy, decreasing=T)]) Regards Petr > > > Hi, > > I am working on categorical data with column as disease name(categaory). > > My input data is > [1] Acute lymphoblastic leukemia (child

Re: [R] how to sort the levels of a table

2011-08-16 Thread Ista Zahn
I'm not entirely sure I understand, but (can't let that stop me, I'd never get anything done) see inline below. On Tue, Aug 16, 2011 at 6:57 PM, drflxms wrote: > Dear colleagues, > > I have really heavy problems in sorting the results of a table according > to certain features of the levels in th

Re: [R] How to sort using a predefined criterion

2011-03-08 Thread Dennis Murphy
df <- read.table(textConnection(" category type values 1 treat_A AA 0.38200018 2 treat_A0.10068056 3 treat_A B0.59648427 4 treat_A AAA 0.89910581 5 treat_A BB 0.88460952 6 treat_A 0.95846431 7 treat_ABB

Re: [R] how to sort new data frame based on the original data frame

2011-01-11 Thread Joshua Wiley
Hi, On Tue, Jan 11, 2011 at 9:19 AM, wangwallace wrote: > > I have a really simple question > > I have a data frame of 8 variables (the first column is the subjects' id): > >    SubID     G1    G2     G3     G4    W1    W2      W3    W4 >      1          6      5       6       2      6      2    

Re: [R] How to sort a grouped barchart?

2010-05-09 Thread LeandroTV
Thanks for both. The reorder function works perfectly. -- View this message in context: http://r.789695.n4.nabble.com/How-to-sort-a-grouped-barchart-tp2133579p2164506.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.

Re: [R] How to sort a grouped barchart?

2010-05-07 Thread Greg Snow
See my recent reply under the subject "bar order using lattice barchart()" Running this code before doing your plot: barley$variety <- reorder(barley$variety, barley$yield, function(x) x[2] ) will cause the bars in all the plots to be reordered such that 1931 Waseca is increasing, is that what

Re: [R] How to sort a grouped barchart?

2010-05-07 Thread David Winsemius
On May 6, 2010, at 9:01 PM, LeandroTV wrote: Hi, I have a barchart very similar to the example on the function documetation, however, I want to sort the bars according one group in one panel. Reminding: library(lattice) barchart(yield ~ variety | site, data = barley, groups = year

Re: [R] How to sort data.frame

2010-01-27 Thread Paul Hiemstra
Hi, Look at the sort_df function from the reshape package. cheers, Paul Madhavi Bhave wrote: Dear R heleprs Suppose I have following data Scenarios combination_names series1 series2 Sc1 MAT2 GAU1 7.26554 8.409778 Sc2 MAT2 GAU2 7.438128 8.130275 Sc3 MAT3 GAU1 8.058422 8.0

Re: [R] How to sort the elements in a matrix?

2009-09-22 Thread David Winsemius
On Sep 22, 2009, at 1:20 PM, FMH wrote: Dear All, Let ab is the combination of matrices a and b. a <- matrix(c(1,2,3,4), nrow = 2, ncol = 2) b <- matrix(c(4,3,1,2), nrow = 2, ncol = 2) ab <- rbind(a, b) From matrix ab, could someone give some advice on the way to sort all elements in colu

Re: [R] How to sort the elements in a matrix?

2009-09-22 Thread Daniel Malter
ab[order(ab[,1]),] - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von FMH Gesendet: Tuesday, September 22, 2009 1:20 PM An: r-help@r-project.org B

Re: [R] How to sort the elements in a matrix?

2009-09-22 Thread Steve Lianoglou
Hi, On Sep 22, 2009, at 1:20 PM, FMH wrote: Dear All, Let ab is the combination of matrices a and b. a <- matrix(c(1,2,3,4), nrow = 2, ncol = 2) b <- matrix(c(4,3,1,2), nrow = 2, ncol = 2) ab <- rbind(a, b) From matrix ab, could someone give some advice on the way to sort all elements in

Re: [R] how to sort

2009-06-18 Thread onyourmark
HI Thanks! This worked: dfCorTFandPCA[order(dfCorTFandPCA$PC1),] Ony milton ruser wrote: > > Hi Ony, > > If you got a data.frame with dfCorTFandPCA=as.data.frame(corTFandPCA) > so you can try something like: > > orderedCorTFandPCA=dfCorTFandPCA[order(dfCorTFandPCA$PC1),] > > May be you can a

Re: [R] how to sort

2009-06-18 Thread ONKELINX, Thierry
You need both the name of the dataframe and the variable in the dataframe. dfCorTFandPCA[order(dfCorTFandPCA$PC1)] ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest

Re: [R] how to sort

2009-06-17 Thread Allan Engelhardt
On 18/06/09 04:16, onyourmark wrote: Hi. I have an object. I think it is a list. It is a matrix corTFandPCA <- runif(922*5) dim(corTFandPCA) <- c(922,5) dimnames(corTFandPCA) <- list(paste("abdomen",2:923,sep="."), paste("PC",1:5,sep="")) str(corTFandPCA) # num [1:922, 1:5] 0.17 0.285 0.

Re: [R] how to sort

2009-06-17 Thread milton ruser
Hi Ony, If you got a data.frame with dfCorTFandPCA=as.data.frame(corTFandPCA) so you can try something like: orderedCorTFandPCA=dfCorTFandPCA[order(dfCorTFandPCA$PC1),] May be you can also try force PC1 to be numeric with:. orderedCorTFandPCA=dfCorTFandPCA[order(as.numeric(as.character(dfCorT

Re: [R] how to sort data frame order by column?

2009-05-31 Thread Linlin Yan
e.g. dat[ order(dat$a), ] On Sun, May 31, 2009 at 2:34 PM, Угодай n/a wrote: > I have a data frame, for exampe > >> dat <- data.frame(a=rnorm(5),b=rnorm(5),c=rnorm(5)) >           a            b          c > 1 -0.1731141  0.002453991  0.1180976 > 2  1.2142024 -0.413897606  0.7617472 > 3 -0.942848

Re: [R] how to sort and plot data?

2009-04-06 Thread Jun Shen
Hema, This may work: aggregate(hema[1],hema[2],function(x)length(unique(x))) to calculate how many different websites each id visited. hema[1] is the website column, hema[2] is user_id. You can always add more index columns like days to aggregate(). Jun On Thu, Apr 2, 2009 at 11:06 PM, Hemavathi

Re: [R] how to sort and plot data?

2009-04-06 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 06.04.2009 05:01:56: > hi Erin, > Thanks for your reply to my problems. I tried and it works, but it sorted > all the column. In my case, I want it to sort d user_id column and another > information in other column will follow it. Now, after I sorted,

Re: [R] how to sort and plot data?

2009-04-05 Thread David Winsemius
Try looking at the examples in : ?order perhaps: dta.frm[order(user_id), ] especially the one that demonstrates how to sort dataframes with three indices. And if that does not satisfy your needs, then you absolutely must provide a simple example and an explicit layout of what the

Re: [R] how to sort and plot data?

2009-04-05 Thread Hemavathi Ramulu
hi Erin, Thanks for your reply to my problems. I tried and it works, but it sorted all the column. In my case, I want it to sort d user_id column and another information in other column will follow it. Now, after I sorted, the information which website viewed by user was wrong. I want to as how we

Re: [R] how to sort and plot data?

2009-04-03 Thread Umesh Srinivasan
Hi, There is definitely a more elegant way of doing this which I don't know about (without a for loop), but try this: mat <- matrix(NA, nrow = max(user_id), ncol = 2) mat[,1] <- 1:max(user_id) # 1st column of matrix is the user ID for (i in 1:max(user_id)){ temp1 <- subset(data, user_id = i) temp

Re: [R] how to sort and plot data?

2009-04-03 Thread Dieter Menne
Hem wrote: > > user_id website time > 20google0930 > 21yahoo0935 > 20facebook1000 > 25facebook1015 > 61google0940 > ... > My problem is how to sort the data? So that, I can get information abou

Re: [R] how to sort and group the data?

2009-04-02 Thread baptiste auguie
try this, d = read.table(textConnection("USER NAME 12 admin 12 admin 10 admin 10 advertising 61 process 17snapshot 61ticket 61ticket 30snapshot 10advertising 10advertising 10advertising 10advertising "),head=T) str(d) # note that NAME is a fact

Re: [R] How to sort a matrix or dataframe by two columns?

2009-02-06 Thread Bill Hyman
Gabor, Thank you very much! Bill - Original Message From: Gábor Csárdi To: Bill Hyman Cc: r-help@r-project.org Sent: Friday, February 6, 2009 2:37:30 PM Subject: Re: [R] How to sort a matrix or dataframe by two columns? Yes, you can: m <- matrix( sample(1:5, 20, rep=TRUE), n

Re: [R] How to sort a matrix or dataframe by two columns?

2009-02-06 Thread Gábor Csárdi
Yes, you can: m <- matrix( sample(1:5, 20, rep=TRUE), nc=2) m[ order(m[,1],m[,2]), ] Gabor On Fri, Feb 6, 2009 at 11:29 PM, Bill Hyman wrote: > Dear all, > > I have a matrix data and would like to sort it by col 1 first and then sort > it by col 2. Can I do it in R? Thanks a lot! > > Bill > >

Re: [R] how to sort a data.frame by ascending some columns

2007-11-18 Thread Henrique Dallazuanna
You can use 'cbind.data.frame' -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 18/11/2007, affy snp <[EMAIL PROTECTED]> wrote: > > Sorry but one more question. After sorting the data frame, > I need to re-organzie the data frame by taking four columns > to create

Re: [R] how to sort a data.frame by ascending some columns

2007-11-18 Thread affy snp
Sorry but one more question. After sorting the data frame, I need to re-organzie the data frame by taking four columns to create a new data frame (I used cbind). But why the first two colums of the new data frame are not USER_CLONE_ID, WELL_ID columns in the previous data frame. I am attaching the

Re: [R] how to sort a data.frame by ascending some columns

2007-11-18 Thread affy snp
Thanks all of you. It works. Have a good weekend! Allen On 11/18/07, Benilton Carvalho <[EMAIL PROTECTED]> wrote: > > actually, > > clones.info[order(clones.info$CHROMOSOME, clones.info$KB_POSITION),] > > btw, documented in the help file. > b > > On Nov 18, 2007, at 1:54 PM, Henrique Dallazuanna

Re: [R] how to sort a data.frame by ascending some columns

2007-11-18 Thread Benilton Carvalho
actually, clones.info[order(clones.info$CHROMOSOME, clones.info$KB_POSITION),] btw, documented in the help file. b On Nov 18, 2007, at 1:54 PM, Henrique Dallazuanna wrote: > clones.info[order(clones.info$CHROMOSOME),] > > -- > Henrique Dallazuanna > Curitiba-Paraná-Brasil > 25° 25' 40" S 49°

Re: [R] how to sort a data.frame by ascending some columns

2007-11-18 Thread Henrique Dallazuanna
clones.info[order(clones.info$CHROMOSOME),] -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 18/11/2007, affy snp <[EMAIL PROTECTED]> wrote: > Dear list, > > I have a data frame (238304 rows and 6 columns). I want the data frame > sorted by two columns in ascending