Re: [R] re-order the rows of a data frame accroding to a specified order of some column

2010-08-15 Thread Leon Yee
> > Yes, > > x[order(order(z)),] > > Two uses of order are needed, as shown. > Thank you very much, Rich. It's like a magic! Leon [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

[R] re-order the rows of a data frame accroding to a specified order of some column

2010-08-15 Thread Leon Yee
Dear all, I have a data frame with several columns, and I have the specified order of a given column. How can I re-order the rows of my data frame accroding to this specified order? for example, x = data.frame( num = 1:26, alpha = letters[1:26], stringsAsFactors=FALSE) z = sample(x$alpha, re

[R] p-value calculation on a joint distribution

2009-11-10 Thread Leon Yee
Dear R users, For a uni-variable distribution represented in a numerical vector, we can obtain a distribution function using 'ecdf', and then calculate corresponding p-values. But if I have a 2-column dataframe representing a bi-variable joint distribution, given a pair of values, how can

Re: [R] pretty display or print for data frames ?

2009-08-12 Thread Leon Yee
Patrick Connolly wrote: On Wed, 12-Aug-2009 at 12:38PM +0800, Leon Yee wrote: Hi, all I have a question of adjusting the output of a data frame with many columns. By default, print() will print out several columns according to the window size, and then it scrolls down and print out

Re: [R] Problem with modifying a data frame

2009-08-11 Thread Leon Yee
Hi, this could be a simple question but I am looking into modifying a data frame using a "condition" without the need to loop over that data, would that be possible? I have tried the following x<-c(4,5,6,6,8) y<-c("a","b","b","b","c") data<-data.frame(x,y) data x y 1 4 a 2 5 b 3 6 b 4 6 b

[R] pretty display or print for data frames ?

2009-08-11 Thread Leon Yee
Hi, all I have a question of adjusting the output of a data frame with many columns. By default, print() will print out several columns according to the window size, and then it scrolls down and print out left columns. How can I make it print all the columns in the same line? I found o

Re: [R] The setting of .Library.site in Rprofile.site doesn't take effect

2009-05-24 Thread Leon Yee
Oh, sorry, my own fault. I had set a HOME evironmental variable, and there was a .Rprofile in it, and the setting of .Library.site was overriden there. Regards, Leon Leon Yee wrote: > Dear R users, > > I am trying to customize the .Library.site in the file > etc/Rprofil

[R] The setting of .Library.site in Rprofile.site doesn't take effect

2009-05-24 Thread Leon Yee
Dear R users, I am trying to customize the .Library.site in the file etc/Rprofile.site under Windows XP, but it seems that the setting doesn't take effect. My setting is: .Library.site <- "d:/site-library" But after I lauched R 2.9.0, the value is always "d:/PROGRA~1/R/R-29~1.0/site

Re: [R] Which data structure in R can mimic hash in PERL best?

2008-11-18 Thread Leon Yee
Hi, Hans W. Borchers wrote: Dear all, Which data structure in R can mimic hash in PERL? I'd like to set up a lookup table, which could be accomplished by HASH if using PERL. Which of the data structures in R is the most efficient for lookup table? Thanks for your help. The regular answer t

[R] Which data structure in R can mimic hash in PERL best?

2008-11-15 Thread Leon Yee
Dear all, Which data structure in R can mimic hash in PERL? I'd like to set up a lookup table, which could be accomplished by HASH if using PERL. Which of the data structures in R is the most efficient for lookup table? Thanks for your help. Best regards, Leon ___

Re: [R] ubuntu system refuses to update packages

2008-11-11 Thread Leon Yee
Vincent Goulet wrote: It seems that R2.8.0 for gutsy is built on a system with tcl8.5 and tk8.5, which is not available in gutsy? From the CRAN Ubuntu README: >>> Installation and compilation of R or some its packages may require Ubuntu packages from the "backports" repositories. In parti

Re: [R] ubuntu system refuses to update packages

2008-11-09 Thread Leon Yee
Dirk Eddelbuettel wrote: On 9 November 2008 at 20:35, Alan Jackson wrote: | There must be a simple answer to this. | | I'm running ubuntu gutsy, currently have 2.7.2 loaded, but the update | tools refuse to update it, and don't tell me why. With apt-get I get : | | [668 ~]$ sudo apt-get -u -V

Re: [R] Compare objects

2008-11-09 Thread Leon Yee
Peter Dalgaard wrote: Heinz Tuechler wrote: At 13:26 09.11.2008, Leon Yee wrote: Hi, friends Is there any functions for object comparing? For example, I have two list objects, and I want to know whether they are the same. Since the the components of list are not necessary atomic, this kind

[R] Compare objects

2008-11-09 Thread Leon Yee
Hi, friends Is there any functions for object comparing? For example, I have two list objects, and I want to know whether they are the same. Since the the components of list are not necessary atomic, this kind of comparison should be recursive. Does this kind of function exist? Thank you for

Re: [R] How to get the duplicated elements from a vector?

2008-10-29 Thread Leon Yee
Erik Iverson wrote: ## BEGIN R CODE ## guarantees there is at least one level with exactly three elements, ## which your problem seems to require t1 <- data.frame(a = rnorm(10), b = c("D", "D", "D", sample(LETTERS[1:3], 7, replace = TRUE))) ## find which names have exactly three elements t2 <-

Re: [R] How to get the duplicated elements from a vector?

2008-10-29 Thread Leon Yee
Gustaf Rydevik wrote: Hi Leon, unique(x) or duplicated(x) should work, depending on what you want. Best, Gustaf Hi, Thank you all. Actually, I have a data frame or matrix, whose first column is numerical values, and whose 2nd column is names. I need those whose names repeated 3 tim

[R] How to get the duplicated elements from a vector?

2008-10-29 Thread Leon Yee
Dear all, How can I get the duplicated elements from a vector? For example, x <- c("yes", "no", "yes", "yes", "no", "not sure"), how can I filter out all the elements which occured >=2 times? Thanks for any help! Regards, Leon __ R-help@r-p

Re: [R] A question about "union"

2008-10-17 Thread Leon Yee
you do, otherwise ugly surprizes await. vQ Leon Yee wrote: Cool! It works! Thank you very much! Leon Yihui Xie wrote: You need to get() their elements instead of merely using variable names. Regards, Yihui -- Yihui Xie <[EMAIL PROTECTED]> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086

Re: [R] A question about "union"

2008-10-17 Thread Leon Yee
School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China On Fri, Oct 17, 2008 at 6:23 PM, Leon Yee <[EMAIL PROTECTED]> wrote: Dear all, I have a question about "union". "union" handles two vectors' element

[R] A question about "union"

2008-10-17 Thread Leon Yee
Dear all, I have a question about "union". "union" handles two vectors' elements to get their union, but I have many vectors and I want to get the union of all of them. So I wrote a loop: all <-c(); for(var in ls(pattern="xyz")) # all of the vectors with pattern of "xyz" { all <- union

Re: [R] How to disable character escaping ?

2008-09-03 Thread Leon Yee
Thank you, Professor Ripley. It is exactly what I need. Best wishes! Leon Prof Brian Ripley wrote: By reading from a file or connection, as in foo <- scan("", "", n=1) c:\tmp\foo The parser always interprets \ in strings, so you must avoid the parser. __

[R] How to disable character escaping ?

2008-09-01 Thread Leon Yee
Dear all, I have a string (a file path in windows system) contains several "\"s. When I copy and paste it into R for assignment to an variable, the "\"s are always interpreted as escaping characters. How can I keep it intact? Thanks. Regards, Leon __

Re: [R] Upgrade 'R'

2008-09-01 Thread Leon Yee
Hello, Kevin You can get some hints by browsing in this mailist with the subject of " Upgrading R means I lose my packages", which were posted several days ago. HTH Leon [EMAIL PROTECTED] wrote: More and more I am getting warnings from packages that I install that the package was buil

Re: [R] Upgrading R means I lose my packages

2008-08-29 Thread Leon Yee
In my situation under windows xp, after I setting the environment variable R_LIBS, neither Rgui.exe nor Rterm.exe under cmd.exe doesn't know the existence of R_LIBS. After I enter the R interface, I find .libPaths() can add a new location for installed packages: > .libPaths("d:/progra~1/R/R