Re: [R] population variance and sample variance

2010-02-04 Thread Peng Yu
on wiki for easy access of some simple terms. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Ista Zahn Sent: Tuesday, February 02, 2010 12:03 PM To: Peng Yu Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] population variance

Re: [R] How to export the examples in help(something) to a file?

2010-02-04 Thread Peng Yu
On Thu, Feb 4, 2010 at 4:34 PM, Henrik Bengtsson h...@stat.berkeley.edu wrote: On Thu, Feb 4, 2010 at 9:18 PM, Liaw, Andy andy_l...@merck.com wrote: From: Peng Yu On Wed, Feb 3, 2010 at 10:01 AM, Peng Yu pengyu...@gmail.com wrote: Some examples in the help page are too long to be copied

Re: [R] typo in contrast package's vignettes

2010-02-03 Thread Peng Yu
On Tue, Feb 2, 2010 at 11:22 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:20 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:11 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:04 PM, David

Re: [R] What are Type II or III contrast? (contrast() in contrast package)

2010-02-03 Thread Peng Yu
On Wed, Feb 3, 2010 at 2:12 AM, Emmanuel Charpentier charp...@bacbuc.dyndns.org wrote: Le mercredi 03 février 2010 à 00:01 -0500, David Winsemius a écrit : On Feb 2, 2010, at 11:38 PM, Peng Yu wrote: ?contrast in the contrast package gives me the following description. However, I have

Re: [R] typo in contrast package's vignettes

2010-02-03 Thread Peng Yu
On Wed, Feb 3, 2010 at 8:41 AM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 9:28 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:22 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:20 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:14 PM, David

Re: [R] How to export the examples in help(something) to a file?

2010-02-03 Thread Peng Yu
On Wed, Feb 3, 2010 at 10:01 AM, Peng Yu pengyu...@gmail.com wrote: Some examples in the help page are too long to be copied from screen. Could somebody let me know some easy way on how to extract the example to a file so that I can play with them? I forget to mention. I use a terminal version

[R] How to export the examples in help(something) to a file?

2010-02-03 Thread Peng Yu
Some examples in the help page are too long to be copied from screen. Could somebody let me know some easy way on how to extract the example to a file so that I can play with them? __ R-help@r-project.org mailing list

[R] How to flatten a tree (based on list) to a certain depth?

2010-02-03 Thread Peng Yu
Suppose that I have the following list of lists of frames 'root' (let's call it a 'tree' of frames). I want to flatten it to be a list of frames. However, if I unlist(root), it will flatten the frames as well. Is there a simply way to flatten the tree to certain depth?

Re: [R] How to flatten a tree (based on list) to a certain depth?

2010-02-03 Thread Peng Yu
On Wed, Feb 3, 2010 at 12:29 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi, On Wed, Feb 3, 2010 at 1:19 PM, Peng Yu pengyu...@gmail.com wrote: Suppose that I have the following list of lists of frames 'root' (let's call it a 'tree' of frames). I want to flatten it to be a list

Re: [R] How to flatten a tree (based on list) to a certain depth?

2010-02-03 Thread Peng Yu
Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Wednesday, February 03, 2010 10:20 AM To: r-h...@stat.math.ethz.ch Subject: [R] How to flatten a tree (based on list) to a certain depth? Suppose that I have the following list

Re: [R] How to flatten a tree (based on list) to a certain depth?

2010-02-03 Thread Peng Yu
-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Wednesday, February 03, 2010 11:40 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] How to flatten a tree (based on list) to a certain depth? On Wed, Feb 3, 2010 at 12:26 PM, Bert Gunter gunter.ber...@gene.com wrote

[R] Can not p.adjust on the conservative analysis.

2010-02-03 Thread Peng Yu
Hi Chad, There are not many significant transcript clusters after p.adjust. sum(adjusted_pvalue[,'C-D'].05) [1] 0 sum(adjusted_pvalue[,'A-D'].05) [1] 0 sum(adjusted_pvalue[,'D-E'].05) [1] 2 sum(adjusted_pvalue[,'A-B'].05) [1] 8 However, there are may TCs that are significant before

Re: [R] typo in contrast package's vignettes

2010-02-03 Thread Peng Yu
On Wed, Feb 3, 2010 at 3:48 PM, Max Kuhn mxk...@gmail.com wrote: Wait, what were we talking about? Right...it is a typo. It should be c'beta in the numerator. Peng: As the package maintainer, you really should send me a quick email about it instead of posting to the list. Let's not waste

[R] Jankowsky conservative analysis

2010-02-03 Thread Peng Yu
pe...@morgan:~/projects/APP_Hippo_Exon_Jankowsky/analysis/pvalue_contrast_table.RData __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and

Re: [R] typo in contrast package's vignettes

2010-02-03 Thread Peng Yu
On Wed, Feb 3, 2010 at 4:53 PM, David Scott d.sc...@auckland.ac.nz wrote: Peng Yu wrote: On Wed, Feb 3, 2010 at 3:48 PM, Max Kuhn mxk...@gmail.com wrote: Wait, what were we talking about? Right...it is a typo. It should be c'beta in the numerator. Peng: As the package maintainer, you

[R] Change point analysis package bcp() reference?

2010-02-03 Thread Peng Yu
bcp()'s help says it implements the paper by Barry and Hartigan (1993). But it has 4 other citations which are later than 1993. Could somebody who have experience on this function let me know why these 4 later citations matters to this particular function? Or these citations are just for the topic

Re: [R] population variance and sample variance

2010-02-02 Thread Peng Yu
On Mon, Oct 19, 2009 at 12:53 PM, Kingsford Jones kingsfordjo...@gmail.com wrote: sum((x-mean(x))^2)/(n) [1] 0.4894708 ((n-1)/n) * var(x) [1] 0.4894708 But this is not a built-in function in R to do so, right? hth, Kingsford On Mon, Oct 19, 2009 at 9:30 AM, Peng Yu pengyu...@gmail.com

[R] What are Type II or III contrast? (contrast() in contrast package)

2010-02-02 Thread Peng Yu
?contrast in the contrast package gives me the following description. However, I have no idea what Type II and III contrasts are. Could somebody explain it to me? And what does 'type' mean here? *‘type’*: set ‘type=average’ to average the individual contrasts (e.g., to obtain a Type II or

[R] typo in contrast package's vignettes

2010-02-02 Thread Peng Yu
It seems that Eq (2) in the vignettes for the 'contrast' packages is not correct. That is, the numerator on the right hand side should be $c' \beta$ rather than $c' \lambda$, right? If I'm correct, could somebody notice the author to fix it? __

[R] How to show the definition of a S3 function?

2010-02-02 Thread Peng Yu
library(contrast) contrast function (fit, ...) UseMethod(contrast) environment: namespace:contrast I guess the above function is S3. Could somebody let me know how to show the function body in an R session? __ R-help@r-project.org mailing list

Re: [R] How to show the definition of a S3 function?

2010-02-02 Thread Peng Yu
contrast.glscontrast.lm [5] contrast.lme methods(contrast.lm) no methods were found Warning message: In methods(contrast.lm) : function 'contrast.lm' appears not to be generic contrast.lm function (fit, ...) contrastCalc(fit, ...) environment: namespace:contrast On 2/2/2010 8:48 PM, Peng Yu

[R] contrast package tutorial

2010-02-02 Thread Peng Yu
I read the vignette of contrast package. I don't think that I understand how to use it. I made the following simpler example (contrast between '3' and '4'). Could somebody let me know what is the correct way to compute the contrast in the following example? library(contrast) a=3 n=4 A =

Re: [R] typo in contrast package's vignettes

2010-02-02 Thread Peng Yu
On Tue, Feb 2, 2010 at 11:04 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 2, 2010, at 11:42 PM, Peng Yu wrote: It seems that Eq (2) in the vignettes for the 'contrast' packages is not correct. That is, the numerator on the right hand side should be $c' \beta$ rather than $c

Re: [R] typo in contrast package's vignettes

2010-02-02 Thread Peng Yu
On Tue, Feb 2, 2010 at 11:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:11 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:04 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 2, 2010, at 11:42 PM, Peng Yu wrote: It seems that Eq (2) in the vignettes

[R] Recommendations on nonparametric statistical inference textbooks

2010-02-01 Thread Peng Yu
Could somebody recommend some good nonparametric statistical inference textbooks for a beginner? And what are pros and cons of each book? Nonparametric statistical methods by Hollander seems to be more difficult for a beginner, but is great as a reference, right? Are there any books that are

[R] Is there a way to make blocks of code independent from each other?

2010-01-31 Thread Peng Yu
I'm wondering if there is a way to make blocks of code independent from each other. Please see the following example for what I mean. x=1 ## is there a way to make the following assignment not affect the above x? ## in C++, I can use {} to make the effect local. Is there an equivalent construct

[R] How to globally enable warning messages or stop the program if NA is encountered?

2010-01-31 Thread Peng Yu
By default, my R functions run silently if NA is encountered? I would like them to give me some message when NA is encountered by default. Note that I could check each intermediate variable by something like is.na(). But this is not manageable for big programs, so I'd like a way to check NA

Re: [R] Anova unequal variance

2010-01-22 Thread Peng Yu
On Fri, Jan 22, 2010 at 3:33 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: On Thu, Jan 21, 2010 at 1:06 PM, Peng Yu pengyu...@gmail.com wrote: On Thu, Jan 21, 2010 at 2:41 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: On Thu, Jan 21, 2010 at 12:29 PM, Peng Yu pengyu...@gmail.com wrote

[R] What is the difference between S and R?

2010-01-21 Thread Peng Yu
On Thu, Jan 21, 2010 at 9:07 AM, Giovanni Petris gpet...@uark.edu wrote: I have found a good refernce to be S Programming by Venables and Ripley. I'll take a look at this book. Since S and R are not completely the same, there are delicate differences between S and R, which an S book may be

[R] Anova unequal variance

2010-01-21 Thread Peng Yu
I found this paper on ANOVA on unequal error variance. Has this be incorporated to any R package? Is there any textbook that discuss the problem of ANOVA on unequal error variance in general? http://www.jstor.org/stable/2532947?cookieSet=1 __

Re: [R] Anova unequal variance

2010-01-21 Thread Peng Yu
start with, if I want to understand the method? Do you have any simple explanation that may help me understand what is the difference between the method in 'Exact Statistical Methods for Data Analysis' and the method in gls()? HTH, Dennis On Thu, Jan 21, 2010 at 12:03 PM, Peng Yu pengyu

Re: [R] Anova unequal variance

2010-01-21 Thread Peng Yu
On Thu, Jan 21, 2010 at 2:41 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: On Thu, Jan 21, 2010 at 12:29 PM, Peng Yu pengyu...@gmail.com wrote: On Thu, Jan 21, 2010 at 2:16 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: This paper was a prelude to his first book 'Exact Statistical

[R] How to write '' to a csv with the default setting of write.csv?

2010-01-21 Thread Peng Yu
Please see the following example. I can not write '' to a csv file successfully. Could somebody let me if it is possible to write '' to a csv file with the default setting of write.csv? my_home$ Rscript main_quote.R x=rbind( + \A\ + , \B\ + ) x [,1] [1,] \A\ [2,] \B\ write.csv(x,

Re: [R] How to write '' to a csv with the default setting of write.csv?

2010-01-21 Thread Peng Yu
. I have looking for a way so that the resulted csv file can be read by excel. http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm#FileFormat On Thu, Jan 21, 2010 at 6:29 PM, Peng Yu pengyu...@gmail.com wrote: Please see the following example. I can not write '' to a csv file successfully

[R] R.oo installation warnings?

2010-01-20 Thread Peng Yu
I got the following warnings when I install R.oo. Are these warnings normal? Should I reinstall the package as mentioned in the warnings? How to reinstall? The sessionInfo() is at the end. install.packages(R.oo, dependencies=T) Warning in install.packages(R.oo, dependencies = T) : argument

[R] Current R.oo tutorial

2010-01-20 Thread Peng Yu
Apparently, Bengtsson.pdf is not current any more. For example, the installation method is outdated. R.oo.pdf is a reference manual rather than a tutorial. I'm wondering if there is a better and more current R.oo tutorial so that I can quickly get started on R.oo.

[R] Unclear documentation on 'numeric' and 'integer' (R-lang.pdf)

2010-01-20 Thread Peng Yu
R-lang.pdf has the following description in Section 3.1.1. Any number typed directly at the prompt is a constant and is evaluated. 1 [1] 1 Perhaps unexpectedly, the number returned from the expression 1 is a numeric. In most cases, the difference between an integer and a numeric value will be

[R] Why are there typeof(), mode() and storage.mode()?

2010-01-20 Thread Peng Yu
According to R-lang.pdf (Section 2): Function mode gives information about the mode of an object in the sense of Becker, Chambers Wilks (1988), and is more compatible with other implementations of the S language. Finally, the function storage.mode returns the storage mode of its argument in the

[R] S3 tutorial

2010-01-20 Thread Peng Yu
I don't find a tutorial on S3. Bengtsson.pdf cites MASS (1999 edition). However, I don't think that MASS (2002 edition) clearly explain what S3 is and help a user who knew very little about S3 to quickly understand it. Could somebody let me know if there are some better learning materials to help

Re: [R] S3 tutorial

2010-01-20 Thread Peng Yu
On Wed, Jan 20, 2010 at 5:04 PM, Peng Yu pengyu...@gmail.com wrote: I don't find a tutorial on S3. Bengtsson.pdf cites MASS (1999 edition). However, I don't think that MASS (2002 edition) clearly explain what S3 is and help a user who knew very little about S3 to quickly understand it. Could

Re: [R] S3 tutorial

2010-01-20 Thread Peng Yu
On Wed, Jan 20, 2010 at 5:30 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi, On Wed, Jan 20, 2010 at 6:05 PM, Peng Yu pengyu...@gmail.com wrote: On Wed, Jan 20, 2010 at 5:04 PM, Peng Yu pengyu...@gmail.com wrote: I don't find a tutorial on S3. Bengtsson.pdf cites MASS (1999

[R] Is nested namespace supported?

2010-01-07 Thread Peng Yu
I don't find where in the R document the discussion of nested namespace is. If there is nested namespace supported in R, could somebody let me know whether the document is? __ R-help@r-project.org mailing list

Re: [R] Is nested namespace supported?

2010-01-07 Thread Peng Yu
On Thu, Jan 7, 2010 at 11:10 AM, Peng Yu pengyu...@gmail.com wrote: I don't find where in the R document the discussion of nested namespace is. If there is nested namespace supported in R, could somebody let me know whether the document is? Could somebody let me know if there is nested name

[R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Peng Yu
read.table terminates the program if the input file is empty. Is there way to let the program continue and return me a NULL instead of terminating the program? $ Rscript read_empty.R read.table(empty_data.txt) Error in read.table(empty_data.txt) : no lines available in input Execution halted $

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Peng Yu
.1252 attached base packages: [1] stats     graphics  grDevices utils     datasets  methods   base /Henrik On Fri, Jan 1, 2010 at 12:41 PM, Peng Yu pengyu...@gmail.com wrote: read.table terminates the program if the input file is empty. Is there way to let the program continue and return me

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Peng Yu
)) print(g) V1 V2 V3 V4 1 name title1 title2 title3 2 row1 10.1 20.1 30.1 3 row2 12.1 22.1 32.1 On Fri, Jan 1, 2010 at 12:41 PM, Peng Yu pengyu...@gmail.com wrote: read.table terminates the program if the input file is empty. Is there way to let the program

Re: [R] How to not to terminate read.table if the input file is

2010-01-01 Thread Peng Yu
PM, Ted Harding ted.hard...@manchester.ac.uk wrote: On 01-Jan-10 20:41:52, Peng Yu wrote: read.table terminates the program if the input file is empty. Is there way to let the program continue and return me a NULL instead of terminating the program? $ Rscript read_empty.R read.table

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Peng Yu
On Fri, Jan 1, 2010 at 3:19 PM, Peng Yu pengyu...@gmail.com wrote: On Fri, Jan 1, 2010 at 2:54 PM, Dylan Beaudette dylan.beaude...@gmail.com wrote: ?try This works. Thank you! f=try(read.table(empty_data.txt)) Error in read.table(empty_data.txt) : no lines available in input One more

[R] How x[, 'colname1'] is implemented?

2009-12-31 Thread Peng Yu
I don't see where describes the implementation of '[]'. For example, if x is a matrix or a data.frame, how the lookup of 'colname1' is x[, 'colname1'] executed. Does R perform a lookup in the a hash of the colnames? Is the reference O(1) or O(n), where n is the second dim of x?

Re: [R] How x[, 'colname1'] is implemented?

2009-12-31 Thread Peng Yu
R internal resolve which columns to use if I specify the column names rather than the indexes. If R does it by search, the access time should be O(log(n)) where n is the number of columns. If R does it by hash, the access time should be O(1). On Thu, Dec 31, 2009 at 5:15 PM, Peng Yu pengyu

Re: [R] [BioC] make.cdf.package: Error: cannot allocate vector of size 1 Kb

2009-12-28 Thread Peng Yu
wrote: Dear Peng Yu how big is the RAM of your computer? You could try with closing all other applications before running this script. You could try on a server with more RAM. I tried downloading the file whose URL who give below, but gave up after some failed rounds with the extraordinarily

Re: [R] [BioC] How to do RMA without summary to probeset level?

2009-12-26 Thread Peng Yu
, Benilton Carvalho bcarv...@jhsph.edu wrote: pm(data) b On Dec 26, 2009, at 2:21 PM, Peng Yu wrote: I use the following code to do RMA. I'm wondering how get the probe level values before the summary to the probeset level values. library(oligo) data-read.celfiles(list.celfiles(data_dir

[R] How to dbReadTable() only a limited number of rows? (RMySQL)

2009-12-24 Thread Peng Yu
I only want to load a limited number of rows by dbReadTable(). I don't see an option in the help. Is there an option to do so? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] Is there a way not to export the functions in the global namespace?

2009-12-18 Thread Peng Yu
Suppose that I 'library()' a package, in the 'NAMESPACE' file of the package, it export some functions to the global namespace. Is there a way to 'library()' the package without export the functions in 'NAMESPACE' to the global namespace? __

Re: [R] What is the fastest way to see what are in an RData file?

2009-12-18 Thread Peng Yu
On Fri, Dec 18, 2009 at 3:33 AM, Gustaf Rydevik gustaf.ryde...@gmail.com wrote: On Thu, Dec 17, 2009 at 4:33 PM, Peng Yu pengyu...@gmail.com wrote: On Thu, Dec 17, 2009 at 5:33 AM, Gustaf Rydevik gustaf.ryde...@gmail.com wrote: On Wed, Dec 16, 2009 at 10:13 PM, Peng Yu pengyu...@gmail.com

[R] How to print to file?

2009-12-18 Thread Peng Yu
I don't find a function to print a string to file. Would somebody let me know what function I should use? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] What is the fastest way to see what are in an RData file?

2009-12-17 Thread Peng Yu
On Thu, Dec 17, 2009 at 5:33 AM, Gustaf Rydevik gustaf.ryde...@gmail.com wrote: On Wed, Dec 16, 2009 at 10:13 PM, Peng Yu pengyu...@gmail.com wrote: Currently, I load the RData file then ls() and str(). But loading the file takes too long if the file is big. Most of the time, I only interested

[R] What is the fastest way to see what are in an RData file?

2009-12-16 Thread Peng Yu
Currently, I load the RData file then ls() and str(). But loading the file takes too long if the file is big. Most of the time, I only interested what the variables are in the the file and the attributes of the variables (like if it is a data.frame, matrix, what are the colnames/rownames, etc.)

Re: [R] Is there lazy copy in R?

2009-12-15 Thread Peng Yu
On Tue, Dec 15, 2009 at 10:32 PM, hadley wickham h.wick...@gmail.com wrote: I don't understand what these addresses mean. Would you please help me understand it? Did you try reading the documentation?     When an object is traced any copying of the object by the C     function ‘duplicate’

Re: [R] Is there lazy copy in R?

2009-12-15 Thread Peng Yu
2009/12/15 tlum...@u.washington.edu: On Wed, 16 Dec 2009, Peng Yu wrote: On Tue, Dec 15, 2009 at 10:32 PM, hadley wickham h.wick...@gmail.com wrote: I don't understand what these addresses mean. Would you please help me understand it? Did you try reading the documentation?     When

[R] 'tracemem' question when I change the length of a vector

2009-12-15 Thread Peng Yu
Please see the following example. If I change the length of a vector twice below, I don't understand why 'tracemem' is shown in the first case but not the second case. Could somebody help explain it to me? x=1 tracemem(x) [1] 0x1bad8c8 length(x)=100# The 'tracemem' string is shown as expected.

Re: [R] Is there lazy copy in R?

2009-12-15 Thread Peng Yu
On Tue, Dec 15, 2009 at 2:34 PM, Peng Yu pengyu...@gmail.com wrote: 2009/12/15  tlum...@u.washington.edu: On Wed, 16 Dec 2009, Peng Yu wrote: On Tue, Dec 15, 2009 at 10:32 PM, hadley wickham h.wick...@gmail.com wrote: I don't understand what these addresses mean. Would you please help me

[R] Is there lazy copy in R?

2009-12-14 Thread Peng Yu
I'm wondering if lazy copy is available in R or not. For example, in the following code, I'm wondering if the memory for y is allocated in the 2nd line or the 3rd line. Is there a documentation for this? x=1:1 y=x y[[10]]=5 __ R-help@r-project.org

Re: [R] Is there lazy copy in R?

2009-12-14 Thread Peng Yu
PM, Benilton Carvalho bcarv...@jhsph.edu wrote: use tracemem() to figure out... and read its documentation in detail. b On Dec 15, 2009, at 1:03 AM, Peng Yu wrote: I'm wondering if lazy copy is available in R or not. For example, in the following code, I'm wondering if the memory for y

[R] Why a list of NULL's are reduced to NULL?

2009-12-11 Thread Peng Yu
The following examples are confusing to me. It is OK, to assigned NULL to one element in a list. The result is still a list. However, a list of NULL's are reduced to NULL. I don't understand how this conversion occurs. Could somebody let me know what is going on? X=matrix(1:8, nr=4) apply(X,1,

[R] The correct way to set an element in a list to NULL? (FAQ is not clear)

2009-12-11 Thread Peng Yu
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-set-components-of-a-list-to-NULL_003f The explanation on this FAQ entry is not clear. It says '... similarly for named components...'. What I understood was x[i]-list(NULL) is the same as x$a_name-list(NULL). But, they are not. As the example

Re: [R] Why a list of NULL's are reduced to NULL?

2009-12-11 Thread Peng Yu
On Fri, Dec 11, 2009 at 11:01 AM, William Dunlap wdun...@tibco.com wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Friday, December 11, 2009 8:44 AM To: r-h...@stat.math.ethz.ch Subject: [R] Why a list

Re: [R] The correct way to set an element in a list to NULL? (FAQ is not clear)

2009-12-11 Thread Peng Yu
On Fri, Dec 11, 2009 at 11:27 AM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi, On Dec 11, 2009, at 12:07 PM, Peng Yu wrote: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-set-components-of-a-list-to-NULL_003f The explanation on this FAQ entry is not clear. It says

Re: [R] Why a list of NULL's are reduced to NULL?

2009-12-11 Thread Peng Yu
On Fri, Dec 11, 2009 at 11:43 AM, William Dunlap wdun...@tibco.com wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Friday, December 11, 2009 9:18 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] Why a list

Re: [R] The correct way to set an element in a list to NULL? (FAQ is not clear)

2009-12-11 Thread Peng Yu
On Fri, Dec 11, 2009 at 11:51 AM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: On Dec 11, 2009, at 12:36 PM, Peng Yu wrote: [snip] What seems confusing to me is: even 'x[i]-list(NULL)' and 'x[[i]]-list(NULL)' are different, why x[i]-NULL and x[[i]]-NULL are the same? Shouldn't

Re: [R] Why a list of NULL's are reduced to NULL?

2009-12-11 Thread Peng Yu
On Fri, Dec 11, 2009 at 12:05 PM, hadley wickham h.wick...@gmail.com wrote: A very common situation is that the users don't know all the possible return types of 'some_third_party_function()'. If the users don't know all the return types, he/she can not make sure the return type of function(x)

Re: [R] Why a list of NULL's are reduced to NULL?

2009-12-11 Thread Peng Yu
mode and a non strict mode. If it is always better to return the same type, which is the case in other strong typed language, then it might better that there is such a mode in R to enforce the same return type. At 12:24 PM -0600 12/11/09, Peng Yu wrote: On Fri, Dec 11, 2009 at 12:05 PM, hadley

Re: [R] Why a list of NULL's are reduced to NULL?

2009-12-11 Thread Peng Yu
On Fri, Dec 11, 2009 at 2:37 PM, Charlie Sharpsteen ch...@sharpsteen.net wrote: On Fri, Dec 11, 2009 at 10:24 AM, Peng Yu pengyu...@gmail.com wrote: How do you figure out all the possibilities? Well, the Value section of the third party function's help page should outline the return types

Re: [R] Why a list of NULL's are reduced to NULL?

2009-12-11 Thread Peng Yu
On Fri, Dec 11, 2009 at 3:49 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: On Dec 11, 2009, at 4:45 PM, Peng Yu wrote: On Fri, Dec 11, 2009 at 2:37 PM, Charlie Sharpsteen ch...@sharpsteen.net wrote: On Fri, Dec 11, 2009 at 10:24 AM, Peng Yu pengyu...@gmail.com wrote: How do you

[R] About R memory management?

2009-12-10 Thread Peng Yu
I'm wondering where I can find the detailed descriptions on R memory management. Understanding this could help me understand the runtime of R program. For example, depending on how memory is allocated (either allocate a chuck of memory that is more than necessary for the current use, or allocate

Re: [R] About R memory management?

2009-12-10 Thread Peng Yu
: Related... Rule of thumb: Pre-allocate your object of the *correct* data type, if you know the final dimensions. /Henrik On Thu, Dec 10, 2009 at 8:26 AM, Peng Yu pengyu...@gmail.com wrote: I'm wondering where I can find the detailed descriptions on R memory management. Understanding this could

Re: [R] How to figure out which the version of split is used?

2009-12-10 Thread Peng Yu
On Thu, Dec 10, 2009 at 3:46 AM, Karl Ove Hufthammer k...@huftis.org wrote: On Wed, 9 Dec 2009 19:20:47 -0600 Peng Yu pengyu...@gmail.com wrote: Is there a way to figure out which of these variants is actually dispatched to when I call split? I know that if the argument is of the type

[R] Is there a variant of findInterval() such that v[i[j]] x[j] = v[i[j] + 1]?

2009-12-10 Thread Peng Yu
In findInterval's help page, it says 'v[i[j]] = x[j] v[i[j] + 1]'. I'm wondering if there is a variant of it such that 'v[i[j]] x[j] = v[i[j] + 1]'. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

[R] How to get the runtime as well as the result?

2009-12-10 Thread Peng Yu
If I use system.time() to measure the runtime of an expression, I will not get the result. Is there a way to measure the runtime and get the result as well? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] About R memory management?

2009-12-10 Thread Peng Yu
a variation of this; preallocate and then extend when you read a limit x - numeric(2) for (i in 1:100){     if (i length(x)){     # double the length (or whatever you want)     length(x) - length(x) * 2     }     x[i] - i } On Thu, Dec 10, 2009 at 11:30 AM, Peng Yu pengyu...@gmail.com

Re: [R] How to get the runtime as well as the result?

2009-12-10 Thread Peng Yu
On Thu, Dec 10, 2009 at 7:03 PM, Dirk Eddelbuettel e...@debian.org wrote: On 10 December 2009 at 18:12, Peng Yu wrote: | If I use system.time() to measure the runtime of an expression, I will | not get the result. Is there a way to measure the runtime and get the | result as well? Use

[R] How to profile an R program?

2009-12-10 Thread Peng Yu
Is there a way to profile an R program similar to valgrind (valgrind.org), in the sense that I can easily see which function is the bottleneck of an R program? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

[R] How to get rid of NULL in the result of apply()?

2009-12-10 Thread Peng Yu
The following code returns a list with the 2nd element as NULL. I'm wondering what the best way to get rid of NULL element in an 'apply()'s result. lapply(1:3, function(x) { + if(x==2) { + return(NULL) + } else { + return(x) + } + } + ) [[1]] [1] 1

Re: [R] How to get rid of NULL in the result of apply()?

2009-12-10 Thread Peng Yu
On Thu, Dec 10, 2009 at 10:00 PM, Marc Schwartz marc_schwa...@me.com wrote: On Dec 10, 2009, at 9:44 PM, Peng Yu wrote: The following code returns a list with the 2nd element as NULL. I'm wondering what the best way to get rid of NULL element in an 'apply()'s result. lapply(1:3, function(x

[R] Warning for data.table (with ref)?

2009-12-09 Thread Peng Yu
I have following the message dim(refdata) and dimnames(refdata) no longer allow parameter ref=TRUE, use dim(derefdata(refdata)), dimnames(derefdata(refdata)) instead when I loaded data.table. Is it from the package ref? Could it be fixed? Or there is something wrong with my installation?

Re: [R] Significant performance difference between split of a data.frame and split of vectors

2009-12-09 Thread Peng Yu
On Tue, Dec 8, 2009 at 11:06 PM, David Winsemius dwinsem...@comcast.net wrote: On Dec 9, 2009, at 12:00 AM, Peng Yu wrote: On Tue, Dec 8, 2009 at 10:37 PM, David Winsemius dwinsem...@comcast.net wrote: On Dec 8, 2009, at 11:28 PM, Peng Yu wrote: I have the following code, which tests

Re: [R] Can elements of a list be passed as multiple arguments?

2009-12-09 Thread Peng Yu
On Tue, Dec 8, 2009 at 11:05 PM, David Winsemius dwinsem...@comcast.net wrote: On Dec 8, 2009, at 11:37 PM, Peng Yu wrote: I want to split a matrix, where both 'u' and 'w' are results of possible ways. However, whenever 'n' changes, the argument passed to mapply() has to change

Re: [R] Significant performance difference between split of a data.frame and split of vectors

2009-12-09 Thread Peng Yu
On Wed, Dec 9, 2009 at 11:20 AM, Charles C. Berry cbe...@tajo.ucsd.edu wrote: On Wed, 9 Dec 2009, Peng Yu wrote: On Tue, Dec 8, 2009 at 11:06 PM, David Winsemius dwinsem...@comcast.net wrote: On Dec 9, 2009, at 12:00 AM, Peng Yu wrote: On Tue, Dec 8, 2009 at 10:37 PM, David Winsemius

Re: [R] Significant performance difference between split of a data.frame and split of vectors

2009-12-09 Thread Peng Yu
On Tue, Dec 8, 2009 at 10:37 PM, David Winsemius dwinsem...@comcast.net wrote: On Dec 8, 2009, at 11:28 PM, Peng Yu wrote: I have the following code, which tests the split on a data.frame and the split on each column (as vector) separately. The runtimes are of 10 time difference. When m

[R] What is the development cycle where there are code in tests/ for package development?

2009-12-09 Thread Peng Yu
I see 'library(stats)' at the beginning of R-2.10.0/src/library/stats/tests/nls.R. I'm wondering if I am developing my own package 'mypackage' whether I should put 'library(mypackage)' in a .R file in mypackage/tests/? If I do, then it seems awkward to me, because to use 'library(mypackage)', I

[R] How to figure out which the version of split is used?

2009-12-09 Thread Peng Yu
There are a number of functions that are dispatched to from split(). methods('split') [1] split.data.frame split.Date split.defaultsplit.POSIXct Is there a way to figure out which of these variants is actually dispatched to when I call split? I know that if the argument is of the type

Re: [R] [Rd] split() is slow on data.frame (PR#14123)

2009-12-09 Thread Peng Yu
I make a version for matrix. Because, it would be more efficient to split each column of a matrix than to convert a matrix to a data.frame then call split() on the data.frame. Note that the version for a matrix and a data.frame is slightly different. Would somebody add this in R as well?

Re: [R] [Rd] split() is slow on data.frame (PR#14123)

2009-12-09 Thread Peng Yu
Sorry. I sent this to r-help by mistake. Could somebody help delete it from the archive? On Wed, Dec 9, 2009 at 9:29 PM, Peng Yu pengyu...@gmail.com wrote: I make a version for matrix. Because, it would be more efficient to split each column of a matrix than to convert a matrix to a data.frame

Re: [R] How to make the assignment in a for-loop not affect variables outside the loop?

2009-12-09 Thread Peng Yu
() print(n) Uwe Ligges Peng Yu wrote: I know that R is a dynamic programming language. But I'm wondering if there is a way to make the assignment in a for-loop not affect variables outside the loop. n=10 for(i in 1:n){ +     n=3 +     print(n) + } [1] 3 [1] 3 [1] 3 [1] 3 [1

[R] What is the function to test if a vector is ordered or not?

2009-12-09 Thread Peng Yu
I did a search on www.rseek.org to look for the function to test if a vector is ordered or not. But I don't find it. Could somebody let me know what function I should use? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

[R] data.frame is slower than matrix?

2009-12-08 Thread Peng Yu
I'm doing some data manipulations. I thought originally that I should use data.frame, as the elements in a data.frame can have multiple types but the elements in a matrix has to be the same, which all the data have to convert to strings if there is a single column that is string. However, when I

Re: [R] grep() exclude certain patterns?

2009-12-08 Thread Peng Yu
something productive by now. See further comments interspersed below: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Peng Yu Sent: Friday, December 04, 2009 2:06 PM To: r-h...@stat.math.ethz.ch Subject: Re: [R] grep() exclude

Re: [R] grep() exclude certain patterns?

2009-12-08 Thread Peng Yu
On Fri, Dec 4, 2009 at 6:12 PM, Gavin Simpson gavin.simp...@ucl.ac.uk wrote: On Fri, 2009-12-04 at 15:18 -0600, Peng Yu wrote: On Fri, Dec 4, 2009 at 3:06 PM, Peng Yu pengyu...@gmail.com wrote: On Fri, Dec 4, 2009 at 2:35 PM, Greg Snow greg.s...@imail.org wrote: The invert argument seems

[R] Significant performance difference between split of a data.frame and split of vectors

2009-12-08 Thread Peng Yu
I have the following code, which tests the split on a data.frame and the split on each column (as vector) separately. The runtimes are of 10 time difference. When m and k increase, the difference become even bigger. I'm wondering why the performance on data.frame is so bad. Is it a bug in R? Can

[R] Can elements of a list be passed as multiple arguments?

2009-12-08 Thread Peng Yu
I want to split a matrix, where both 'u' and 'w' are results of possible ways. However, whenever 'n' changes, the argument passed to mapply() has to change. Is there a way to pass elements of a list as multiple arguments? m=10 n=2 k=3 set.seed(0) x=replicate(n,rnorm(m)) f=sample(1:k, size=m,

  1   2   3   4   >