[R] Why H1=1? (H's the hat matrix)

2009-10-11 Thread Peng Yu
Suppose I have the following hat matrix: H=X(X'X)^{-1}X' X is a n by p matrix, where n >= p and X_{i,1} = 1 I'm wondering why H1 = 1. (Here, 1 is column vector, whose each element is the number 1) Thank you! __ R-help@r-project.org mailing list https:

[R] mkdir in R?

2009-10-12 Thread Peng Yu
Hi, Besides calling shell command mkdir by system(), I'm wondering if there is a buildin command in R to make a new directory. Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting gu

Re: [R] What is the correct way to define __hash__?

2009-10-12 Thread Peng Yu
On Mon, Oct 12, 2009 at 4:03 PM, Robert Kern wrote: > On 2009-10-12 15:45 PM, Peng Yu wrote: >> >> Hi, >> >> I'm wondering what is the general way to define __hash__. I could add >> up all the members. But I am wondering if this would cause a >> perfo

[R] S4 tutorial

2009-10-13 Thread Peng Yu
I'm looking for some tutorial on S4. I only find the following one, which is not in English. Can somebody let me know if there is any introductory material? I'm very familiar with OO and C++. If there is some material that suits my background, it will be great. https://stat.ethz.ch/pipermail/r-he

[R] How to get the definition of a class?

2009-10-13 Thread Peng Yu
Hi, ExonFeatureSet I have an object of the above class. The following document mentioned it. http://www.bioconductor.org/packages/2.5/bioc/vignettes/oligo/inst/doc/ClassesUsedInOligo.pdf But I would like to see its defintion. I'm wondering if there is a way in R to give me the definition of any

[R] Understanding hclust and dendrogram

2009-10-13 Thread Peng Yu
?hclust listed several references. I'm wondering what is the best resource that explained clustering algorithms, dendrogram and various clustering algorithms that are implemented in R. Thank you! __ R-help@r-project.org mailing list https://stat.ethz.ch/

[R] reference on permutation test

2009-10-13 Thread Peng Yu
I want learn permutation test and resampleing, etc. There are a few references listed below. I'm wondering what is the best book on this topic. Can somebody give me some advice. Thank you! http://en.wikipedia.org/wiki/Resampling_%28statistics%29#Permutation_test __

[R] Request update on A (Not So) Short Introduction to S4

2009-10-13 Thread Peng Yu
There are several '?'s on the last page of the following document. Apparently, they are not correct. Could somebody correct it? cran.r-project.org/doc/contrib/Genolini-S4tutorialV0-5en.pdf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailma

Re: [R] How to get the definition of a class?

2009-10-13 Thread Peng Yu
On Tue, Oct 13, 2009 at 9:38 PM, Martin Morgan wrote: > Peng Yu wrote: >> Hi, >> >> ExonFeatureSet >> >> I have an object of the above class. The following document mentioned it. >> >> http://www.bioconductor.org/packages/2.5/bioc/vignettes/oligo/inst

[R] reference on fisher.test()

2009-10-15 Thread Peng Yu
Can somebody point me a book on Fisher's exact test? I looked a few webpages. But the descriptions on the webpages are not very complete. Is there a book on that covers all the aspect of Fisher's exact test that is implemented in R? __ R-help@r-project.o

Re: [R] reference on fisher.test()

2009-10-15 Thread Peng Yu
On Thu, Oct 15, 2009 at 4:19 PM, RICHARD M. HEIBERGER wrote: > On Thu, Oct 15, 2009 at 4:56 PM, Peng Yu wrote: >> Can somebody point me a book on Fisher's exact test? I looked a few >> webpages. But the descriptions on the webpages are not very complete. >> Is there a b

[R] How odds ratio is computed in fisher.test()?

2009-10-16 Thread Peng Yu
I'm wondering how odds ratio is computed. I thought that it is (n11/n12)/(n21/n22), but it is not what fisher.test() computes. Could somebody let me know? > n11=3 > n12=1 > n21=1 > n22=3 > > n1_=n11+n12 > n2_=n21+n22 > > n_1=n11+n21 > n_2=n12+n22 > > x=rbind(c(n11,n12),c(n21,n22)) > > threshold=dh

[R] Recommendation on a probability textbook (conditional probability)

2009-10-16 Thread Peng Yu
I need to refresh my memory on Probability Theory, especially on conditional probability. In particular, I want to solve the following two problems. Can somebody point me some good books on Probability Theory? Thank you! 1. Z=X+Y, where X and Y are independent random variables and their distributi

Re: [R] Recommendation on a probability textbook (conditional probability)

2009-10-16 Thread Peng Yu
What's the title? On Fri, Oct 16, 2009 at 8:16 PM, Yi Du wrote: > Hogg's book is enough for you considering your problems. > > Yi > > On Fri, Oct 16, 2009 at 7:12 PM, Peng Yu wrote: >> >> I need to refresh my memory on Probability Theory, especially on >

Re: [R] Recommendation on a probability textbook (conditional probability)

2009-10-16 Thread Peng Yu
probability_book/book.html > > -Ista > > On Fri, Oct 16, 2009 at 9:12 PM, Peng Yu wrote: >> I need to refresh my memory on Probability Theory, especially on >> conditional probability. In particular, I want to solve the following >> two problems. Can somebody point me some

[R] looking for reference that covers convergence in distribution

2009-10-17 Thread Peng Yu
I am looking for a good probability book that describes convergence in distribution. I have looked through Introduction to Probability by Charles M. Grinstead, J. Laurie Snell, but I don't find any formal description on convergence in distribution. Could somebody recommend a good book that cover th

Re: [R] looking for reference that covers convergence in distribution

2009-10-17 Thread Peng Yu
On Sat, Oct 17, 2009 at 3:28 PM, Peter Dalgaard wrote: > Ben Bolker wrote: >> >> >> Peng Yu wrote: >>> >>> I am looking for a good probability book that describes convergence in >>> distribution. I have looked through Introduction to Probability by

[R] How to plot multiple data sets with different colors (also with legend)?

2009-10-18 Thread Peng Yu
The following commands only show the data in 'y'. I'm wondering how to show the data in 'x' as well. I also want to add a legend to show that blue points corresponds to 'x' and yellow points correspond to 'y'. Could somebody let me know what the correct commands should be? x=rbind(c(10,11),c(10,11

Re: [R] How to plot multiple data sets with different colors (also with legend)?

2009-10-18 Thread Peng Yu
On Sun, Oct 18, 2009 at 5:42 PM, Matthieu Dubois wrote: > Hi, > > the blue point is not shown simply because it is printed outside > the current plot area. If you want to use the base graphics, you > have to manually define the xlim and ylim of the plot. Legend is added > with the command "legend"

[R] Why points() is defined specially for a 1 by 2 matrix?

2009-10-18 Thread Peng Yu
x=cbind(1:4,3:6) png('one_point.png') plot(x[1:3,],xlim=c(-1,11),ylim=c(-1,11),pch=1) points(x[4,],pch=2)# this is plotted as two points #although I meant only one point legend("topleft", c("x","y"),pch=c(1,2)) dev.off() The above code will produce 5 points instead of 4 points. If I want to have 4

[R] What is the difference between prcomp and princomp?

2009-10-18 Thread Peng Yu
Some webpage has described prcomp and princomp, but I am still not quite sure what the major difference between them is. Can they be used interchangeably? In help, it says 'princomp' only handles so-called R-mode PCA, that is feature extraction of variables. If a data matrix is supplie

Re: [R] Why points() is defined specially for a 1 by 2 matrix?

2009-10-18 Thread Peng Yu
On Sun, Oct 18, 2009 at 10:26 PM, Richard M. Heiberger wrote: >> points(x[4,],pch=2)# this is plotted as two points > > drops what it sees as an unnecessary dimension. > > Use > >> points(x[4,, drop=FALSE], pch=2) > > See FAQ 7.5 > > tmp <- matrix(1:2) > tmp > tmp[,1] > tmp[,1,drop=FALSE] Can I s

[R] What an element in loading is missing? (princomp)

2009-10-18 Thread Peng Yu
Please see below that [3,1] of loadings is not printed. I am wondering what the problem is? > set.seed(0) > m=10 > n=4 > X=replicate(n,rnorm(m)) > pca_result=princomp(X) > svd_result=svd(apply(X,2,function(x){x-mean(x)})) > pca_result$loadings Loadings: Comp.1 Comp.2 Comp.3 Comp.4 [1,] 0.86

Re: [R] What is the difference between prcomp and princomp?

2009-10-18 Thread Peng Yu
On Sun, Oct 18, 2009 at 10:42 PM, Peng Yu wrote: > Some webpage has described prcomp and princomp, but I am still not > quite sure what the major difference between them is. Can they be used > interchangeably? > > In help, it says > >     'princomp' only handle

Re: [R] What is the difference between prcomp and princomp?

2009-10-19 Thread Peng Yu
On Mon, Oct 19, 2009 at 5:02 AM, Mark Difford wrote: > > Peng Yu wrote: > >>> Some webpage has described prcomp and princomp, but I am still not >>> quite sure what the major difference between them is. > > The main difference, which could be extracted from th

Re: [R] What an element in loading is missing? (princomp)

2009-10-19 Thread Peng Yu
On Mon, Oct 19, 2009 at 1:58 AM, Peter Ehlers wrote: > > Peng Yu wrote: >> >> Please see below that [3,1] of loadings is not printed. I am wondering >> what the problem is? > > Not trying ?loadings, perhaps?? 'loadings' gives me the same thing. > pca_

[R] population variance and sample variance

2009-10-19 Thread Peng Yu
It seems that var() computes sample variance. It is straight forward to compute population variance from sample variance. However, I feel that it is still convenient to have a function that can compute population variance. Is there a population variance function available in R? $ Rscript var.R > s

Re: [R] What is the difference between prcomp and princomp?

2009-10-19 Thread Peng Yu
On Mon, Oct 19, 2009 at 9:31 AM, Peng Yu wrote: > On Mon, Oct 19, 2009 at 5:02 AM, Mark Difford > wrote: >> >> Peng Yu wrote: >> >>>> Some webpage has described prcomp and princomp, but I am still not >>>> quite sure what the major difference b

[R] Is there a way to specify drop=FALSE as the global default?

2009-10-19 Thread Peng Yu
tmp <- matrix(1:2) tmp tmp[,1,drop=FALSE] See the above example. Is there a way to make 'drop=FALSE' as global default, so that when I say 'tmp[,1]', R will treat it as 'tmp[,1,drop=FALSE]'? __ R-help@r-project.org mailing list https://stat.ethz.ch/mai

[R] underflow of fisher.test result

2009-10-20 Thread Peng Yu
fisher.test() gives a very small p-value, which is underflow on my machine. However, the log of it should not be underflow. I'm wondering if there is a way get log() of a small p-value. An approximation is acceptable in this case. Thank you! > fisher.test(rbind(c(1,10),c(10,1000)))

Re: [R] underflow of fisher.test result

2009-10-20 Thread Peng Yu
On Tue, Oct 20, 2009 at 9:14 AM, Ted Harding wrote: > On 20-Oct-09 13:34:49, Peng Yu wrote: >> fisher.test() gives a very small p-value, which is underflow on my >> machine. However, the log of it should not be underflow. I'm wondering >> if there is a way get lo

[R] How to make R packages?

2009-10-22 Thread Peng Yu
I found the following document on making R packages. But it is old. I'm wondering if there is more current ones and hopefully more complete ones. http://biosun1.harvard.edu/courses/individual/bio271/lectures/L6/Rpkg.pdf __ R-help@r-project.org mailing l

Re: [R] How to make R packages?

2009-10-23 Thread Peng Yu
tat.wisc.edu/~kbroman/Rintro/Rwinpack.html > HTH, > Jorge > > On Fri, Oct 23, 2009 at 12:10 AM, Peng Yu <> wrote: >> >> I found the following document on making R packages. But it is old. >> I'm wondering if there is more current ones and hopefully more >&

[R] reference for mahalanobis {stats}

2009-10-23 Thread Peng Yu
The help on mahalanobis {stats} does not include any reference. I'm interested in understand why Mahalanobis is defined in its current way and how to use it. Could somebody point me a good book on this? I have looked through a few books, but they all give very light explanation on it.

Re: [R] reference for mahalanobis {stats}

2009-10-23 Thread Peng Yu
On Fri, Oct 23, 2009 at 10:59 AM, Steve Lianoglou wrote: > Hi, > > On Oct 23, 2009, at 11:36 AM, Peng Yu wrote: > >> The help on mahalanobis {stats} does not include any reference. I'm >> interested in understand why Mahalanobis is defined in its current way >>

[R] How apply a function to a list while maintaining list name?

2009-10-24 Thread Peng Yu
I use lapply to apply a function to the list 'L'. But of course, the list names in 'X' is not maintained. I'm wondering if there is a function that can maintain the list names as well as apply the function. $ Rscript lapply.R > L=list(x=c('a','b'), y=c('a','b')) > L $x [1] "a" "b" $y [1] "a" "b"

[R] What is the most efficient practice to develop an R package?

2009-10-26 Thread Peng Yu
I am reading Section 5 and 6 of http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf It seems that I have to do the following two steps in order to make an R package. But when I am testing these package, these two steps will run many times, which may take a lot of time. So when I stil

Re: [R] What is the most efficient practice to develop an R package?

2009-10-26 Thread Peng Yu
On Mon, Oct 26, 2009 at 11:22 AM, Dirk Eddelbuettel wrote: > > On 26 October 2009 at 07:57, Martin Morgan wrote: > | Peng Yu wrote: > | > I am reading Section 5 and 6 of > | > http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf > | > > | > It seem

[R] Why 'validity' is not called? (S4)

2009-10-26 Thread Peng Yu
I thought that 'validity' defined in 'setClass' should be called in 'new'. Could somebody let me know why 'validity' is not called? How to make it be called? > setClass( + Class='A', + representation=representation( + x='numeric' + ), + validity=function(object){ +

[R] R.oo and S4?

2009-10-26 Thread Peng Yu
There are different way to make R classes. I know R.oo and S4. I'm wondering which one is the current popular one. Which one is current recommended when make new R packages? Thank you! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/lis

[R] How to browse all the functions in a package?

2009-10-26 Thread Peng Yu
'?removeClass' shows that 'removeClass' is from package 'package:methods'. Is there a command which can show me all the functions and the classed defined in a package such as 'package:methods'? __ R-help@r-project.org mailing list https://stat.ethz.ch/ma

Re: [R] Why 'validity' is not called? (S4)

2009-10-26 Thread Peng Yu
On Mon, Oct 26, 2009 at 1:49 PM, Martin Morgan wrote: > Peng Yu wrote: >> I thought that 'validity' defined in 'setClass' should be called in >> 'new'. Could somebody let me know why 'validity' is not called? How to &

[R] How to change a slot by a method?

2009-10-26 Thread Peng Yu
In the following code, 'multiply' doesn't multiply a...@x by 2. I'm wondering how to define a method that can change the slot of a class. $ Rscript setGeneric.R > setClass( + Class='A', + representation=representation( + x='numeric' + ) + ) [1] "A" > > setMethod( +

[R] How to reduce key strokes when defining S4 classes?

2009-10-26 Thread Peng Yu
I feel tedious when I define a S4 class and the methods. For each method, I have to call both setMethod and setGeneric (or both setReplaceMethod and setGeneric). I would like a more compact grammar so that I can reduce the key strokes. I'm wondering if there is a better way available. setClass(

Re: [R] How to reduce key strokes when defining S4 classes?

2009-10-27 Thread Peng Yu
On Mon, Oct 26, 2009 at 11:56 PM, wrote: > Quoting Peng Yu : > >> I feel tedious when I define a S4 class and the methods. For each >> method, I have to call both setMethod and setGeneric (or both >> setReplaceMethod and setGeneric). I would like a more compact grammar

[R] Why 'return' is needed in R?

2009-10-27 Thread Peng Yu
It seems that 'return' is not necessary when returning a value. If this is the case, I don't understand why 'return' is a keyword in R. Is there a case in which I have to use 'return'? > f<-function(x) { + x + } > g<-function(x) { + return(x) + } > print(f(2)) [1] 2 > print(g(2)) [1] 2 >

[R] What is the difference between anova {stats} and aov?

2009-10-27 Thread Peng Yu
There are anova {stats} and aov in R. It seems that anova takes an object returned by a model fitting function. But I don't see any examples for anova. Can somebody give me a simple example on anova? What is the difference between anova and aov? __ R-hel

[R] How to quit unwanted execution immediately?

2009-10-27 Thread Peng Yu
Occasionally, I start a command (taking long time to finish) that I did not really want to start. I type 'ctrl+C' to try to quit the execution. However, R does not quit the execution of the command immediately. I'm wondering if R could response to ctrl+C immediately. __

[R] How to clear colnames?

2009-10-27 Thread Peng Yu
I only see how to assign values to colnames() in help. Is there a way to remove colnames? colnames(x) <- value __ 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/po

[R] Why I get this error? Error in close.connection(f) : invalid connection

2009-10-27 Thread Peng Yu
I don't understand why I can not close 'f'. This may be very simple, but I don't see why. Could somebody let me know? $ cat gzfile.csv "","V1","V2","V3","V4","V5" "1",1,5,9,13,17 "2",2,6,10,14,18 "3",3,7,11,15,19 "4",4,8,12,16,20 $ Rscript gzfile.R > f = file("gzfile.csv") > A = read.csv(f) > A

Re: [R] How to clear colnames?

2009-10-27 Thread Peng Yu
ot; "9" "10" > class(all_annotation) [1] "data.frame" On Tue, Oct 27, 2009 at 5:20 PM, Benilton Carvalho wrote: > colnames(x) <- NULL > > On Oct 27, 2009, at 8:09 PM, Peng Yu wrote: > >> I only see how to assign values to colnames() in help. I

Re: [R] [BioC] Is there a package similar to mogene10stprobeset.db by for Affymetrix Exon Arrays?

2009-10-27 Thread Peng Yu
ll be possible for an > exon-oriented platform), then you can use SQLForge in AnnotationDbi to > generate an annotation package.  To do so see the SQLForge vignette > which can be found in the AnnotationDbi package right here: > > http://www.bioconductor.org/packages/devel/bioc/html/An

[R] How to union the elements in a list?

2009-10-28 Thread Peng Yu
Suppose that I have a list of vectors. I want to compute the union of all the vectors in the list. I could use 'for' loop to do so. But I'm wondering what would be a better solution that does not need a 'for' loop. l=list(a=c(1,3,4), b=c(1,3,6), c=c(1,3,7), ) _

[R] Weird error: Error in xj[i] : invalid subscript type 'list'

2009-10-29 Thread Peng Yu
I got the error. I haven't been able to get a stand along case so that I can show it here. But could somebody give some clue on what could cause this error? Since I never defined xj[i], I don't understand where this error come from. Error in xj[i] : invalid subscript type 'list' _

Re: [R] underflow of fisher.test result

2009-11-01 Thread Peng Yu
On Tue, Oct 20, 2009 at 8:14 AM, Ted Harding wrote: > On 20-Oct-09 13:34:49, Peng Yu wrote: >> fisher.test() gives a very small p-value, which is underflow on my >> machine. However, the log of it should not be underflow. I'm wondering >> if there is a way get lo

[R] reference on p.adjust()

2009-11-02 Thread Peng Yu
I'm wondering if there is a textbook that summarize the methods on adjusting p-values for multiple comparisons. Most of the references on p.adjust() are over 10 years old. I feel it would be better if somebody could recommend me a textbook on multiple hypothesis correction, so that I can quickly ge

[R] How to exclude certain columns by column names?

2009-11-02 Thread Peng Yu
I can exclude columns by column number using '-'. But I wondering if there is an easy way to exclude some columns by column names. > x=cbind(c(1,2),c(3,4)) > x [,1] [,2] [1,]13 [2,]24 > colnames(x)=c('a','b') > x a b [1,] 1 3 [2,] 2 4 > x[,-'a'] Error in -"a" : invalid ar

Re: [R] reference on p.adjust()

2009-11-03 Thread Peng Yu
2009/11/3 Uwe Ligges : > > > Peng Yu wrote: >> >> I'm wondering if there is a textbook that summarize the methods on >> adjusting p-values for multiple comparisons. Most of the references on >> p.adjust() are over 10 years old. > > Being 10 years old doe

[R] How to load a specific variable from an RData file?

2009-11-05 Thread Peng Yu
I'm wondering if there is any option available in load() such that I can specify which variable I want to load from an RData file. I don't see such option in the help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEA

Re: [R] How to load a specific variable from an RData file?

2009-11-05 Thread Peng Yu
> [41] "rankComm"             "realign"              "report" >   "reslotAisles" > [45] "s.lower"              "s.mat"                "S_slots.save" >   "sa.m" > [49] "save.opt"             "save.

Re: [R] How to load a specific variable from an RData file?

2009-11-05 Thread Peng Yu
lots.save" >   "sa.m" > [49] "save.opt"             "save.slots"           "setupSlots" >   "slotAssignments" > [53] "slots"                "slotSize"             "slotsUsed" >

Re: [R] Error: cannot allocate vector of size 3.4 Gb

2009-11-07 Thread Peng Yu
rs to me, i'm not sure, that you start a fresh session of R and then > tries to read in the data - how much resource do you have available when you > try reading in the data? having 8GB RAM does not mean that you have 8GB when > you tried the task. > > b > > On Nov 7, 2009, at 12:

Re: [R] Error: cannot allocate vector of size 3.4 Gb

2009-11-07 Thread Peng Yu
on chip, the math is the same i mentioned before. > > having 8 GB, you should be able to read in 70 samples of this chip. if you > can't, that's because you don't have enough resources when trying to read. > > best, > > b > > On Nov 7, 2009, at 10:12 AM, P

[R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread Peng Yu
I'm wondering which textbook discussed the various contrast matrices mentioned in the help page of 'contr.helmert'. Could somebody let me know? BTW, in R version 2.9.1, there is a typo on the help page of 'contr.helmert' ('cont.helmert' should be 'contr.helmert').

Re: [R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread Peng Yu
On Sun, Nov 8, 2009 at 10:11 AM, Duncan Murdoch wrote: > On 08/11/2009 11:03 AM, Peng Yu wrote: >> >> I'm wondering which textbook discussed the various contrast matrices >> mentioned in the help page of 'contr.helmert'. Could somebody let me >> kn

Re: [R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread Peng Yu
On Sun, Nov 8, 2009 at 11:28 AM, Peter Dalgaard wrote: > Gabor Grothendieck wrote: >> >> On Sun, Nov 8, 2009 at 11:59 AM, Peng Yu wrote: >>> >>> On Sun, Nov 8, 2009 at 10:11 AM, Duncan Murdoch >>> wrote: >>>> >>>> On 08/11/2009

[R] ordered factor and unordered factor

2009-11-08 Thread Peng Yu
I don't understand under what situation ordered factor rather than unordered factor should be used. Could somebody give me some examples? What are the implications of order vs. unordered factors? Could somebody recommend a textbook to me? __ R-help@r-pro

Re: [R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread Peng Yu
$X_F$ (mentioned on page 189) is different and hence $\beta_F$ (mentioned in eq. 9.3) is be different. So my understanding is that the matrix of contrast should depend on the formula. But it is not according to the help page of "contr.helmert". Regards, Peng On Sun, Nov 8, 2009 at 6:17

[R] R process gets killed spontaneously

2009-11-09 Thread Peng Yu
My R process has been killed for a few times, although the system administrator did not do so. It happened when R attempted to allocate a lot of memory. I'm wondering whether R would spontaneously kill itself if it can not allocate enough memory? __ R-he

Re: [R] reference on contr.helmert and typo on its help page.

2009-11-09 Thread Peng Yu
On Sun, Nov 8, 2009 at 7:32 PM, John Fox wrote: > Dear Peng, > > I'm tempted to try to get an entry in the fortunes package but will instead > try to answer your questions directly: I can not install 'fortunes'. What are the fortunes packages about? > install.packages("fortunes", repos="http://R-

[R] What is the equivalent of column.prods() from S in R?

2009-11-09 Thread Peng Yu
Chambers' book Statistical Models in S mentioned 'column.prods()'. But I don't find it in R. I'm wondering if there is an equivalent in R? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] ordered factor and unordered factor

2009-11-09 Thread Peng Yu
> 801.408.8111 > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of Peng Yu >> Sent: Sunday, November 08, 2009 4:28 PM >> To: r-h...@stat.math.ethz.ch >> Subject: [R] ordered factor a

Re: [R] R process gets killed spontaneously

2009-11-10 Thread Peng Yu
2009/11/10 Uwe Ligges : > > > Peng Yu wrote: >> >> My R process has been killed for a few times, although the system >> administrator did not do so. It happened when R attempted to allocate >> a lot of memory. I'm wondering whether R would spontaneously kill &

Re: [R] R process gets killed spontaneously

2009-11-10 Thread Peng Yu
session? (screen is a very nice program that will keep your sessions alive > after you log out, but it was killing off my big memory jobs for unknown > reasons.) > > Eric > > > > ----- Original message - > From: "Peng Yu" > To: r-h...@stat.math.ethz.ch &

[R] What parts of 'Statistical Models in S' are not applicable to R?

2009-11-10 Thread Peng Yu
According to Amazon review, 'Statistical Models in S' is a key reference for understanding the methods implemented in several of S-PLUS' high-end statistical functions, including 'lm()', predict()', 'design()', 'aov()', 'glm()', 'gam()', 'loess()', 'tree()', 'burl.tree()', 'nls()' and 'ms()'. But

[R] How to get the names of list elements when iterating over a list?

2009-11-11 Thread Peng Yu
I need to get the names of the list elements when I iterate over a list. I'm wondering how to do so? alist=list(a=c(1,3),b=c(-1,3),c=c(-2,1)) sapply(alist,function(x){ #need to use the name of x for some subsequent process }) __ R-help@r-proje

Re: [R] Is there a way to specify drop=FALSE as the global default?

2009-11-11 Thread Peng Yu
On Mon, Oct 19, 2009 at 7:57 PM, Peng Yu wrote: > tmp <- matrix(1:2) > tmp > tmp[,1,drop=FALSE] > > > See the above example. Is there a way to make 'drop=FALSE' as global > default, so that when I say 'tmp[,1]', R will treat it as > 'tmp[,1,drop

Re: [R] R.oo and S4?

2009-11-11 Thread Peng Yu
es the prototype model (or pure object > model). proto tends to apply in user interface applications and there > is some info on which other packages make use of proto on the proto > home page at: http://r-proto.googlecode.com > > On Mon, Oct 26, 2009 at 2:47 PM, Peng Yu wrote: >&g

[R] How to show all the functions and classes that are defined in a library?

2009-11-13 Thread Peng Yu
library(some_library_name) Suppose I load a library. I'm wondering what command I should use to list all the functions, classes and variables defined in the library. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEAS

[R] refactoring in R

2009-11-13 Thread Peng Yu
I'm wondering if there are some tips for refactoring in R. I found the following website, which is still preliminary. Is there any program that can help me do refactoring in R? http://www.r-developer.org/projects/show/refactoring __ R-help@r-project.org

Re: [R] refactoring in R

2009-11-13 Thread Peng Yu
y be you are able to > state a minimally reproducible code/example with > what you really need. > > Bests > > milton > > > On Fri, Nov 13, 2009 at 9:30 PM, Peng Yu wrote: >> >> I'm wondering if there are some tips for refactoring in R. I found the >&g

Re: [R] refactoring in R

2009-11-14 Thread Peng Yu
to keep up to date, there is a dedicated > mailing list at > > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/statet-user > > HTH, > Tobias > > P.S. The refactoring methods are available under the Source menu, > and there is one [simple rename] made available

[R] How to get the string '\'?

2009-11-15 Thread Peng Yu
I can not get the string '\'. Could somebody let me know how to get it? > print('\') + + > print('\\') [1] "\\" __ 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/p

Re: [R] How to get the string '\'?

2009-11-15 Thread Peng Yu
My question was from replacing a pattern by '\\'. How to replace '/' in string by '\'? string='abc/efg' gsub('/','\\',string) On Sun, Nov 15, 2009 at 5:07 PM, David Winsemius wrote: > ?cat > >> cat("\\") &

Re: [R] How to get the string '\'?

2009-11-15 Thread Peng Yu
On Sun, Nov 15, 2009 at 6:05 PM, David Winsemius wrote: > > On Nov 15, 2009, at 6:35 PM, Peng Yu wrote: > >> My question was from replacing a pattern by '\\'. How to replace '/' >> in string by '\'? >> >> string='abc/efg' &g

[R] How to name a tag in a list or a data.frame from a string?

2009-11-15 Thread Peng Yu
Suppose I have a string variable string='some_string' Now I want to have a list, where is the same as the string in the variable string. I'm wondering if this is possible in R. list(=1:3) data.frame(=1:3) __ R-help@r-project.org mailing list https://

[R] How to generate dependency file that can be used by gnu make?

2009-11-15 Thread Peng Yu
gcc has options like -MM, which can generate the dependence files for a C/C++ file that I can be used by gnu make. I'm wondering if there is a tool that can generate dependence file for an R script. For example, I have an R script test.R #test.R load('input.RData') save.image('output.RDat

Re: [R] How to generate dependency file that can be used by gnu make?

2009-11-16 Thread Peng Yu
On Sun, Nov 15, 2009 at 8:45 PM, Peng Yu wrote: > gcc has options like -MM, which can generate the dependence files for > a C/C++ file that I can be used by gnu make. I'm wondering if there is > a tool that can generate dependence file for an R script. > > For example, I hav

Re: [R] [Rd] How to generate dependency file that can be used by gnu make?

2009-11-17 Thread Peng Yu
e a tool by yourself to parse the R syntax to > resolve your problem. > > On Tue, Nov 17, 2009 at 11:51 AM, Peng Yu wrote: >> On Sun, Nov 15, 2009 at 8:45 PM, Peng Yu wrote: >>> gcc has options like -MM, which can generate the dependence files for >>> a C/C++ file

[R] How to choose appropriate linear model? (ANOVA)

2009-11-18 Thread Peng Yu
I'm wondering how to choose an appropriate linear model for a given problem. I have been reading Applied Linear Regression Models by John Neter, Michael H Kutner, William Wasserman and Christopher J. Nachtsheim. I'm still not clear how to choose an appropriate linear model. For multi-factor ANOVA,

[R] Cochran's Theorem

2009-11-18 Thread Peng Yu
I want to understand ANOVA better. But a few textbook that I have do not describe Cochran's Theorem in details. Could somebody recommend a book for me? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the p

Re: [R] How to wait for a user response in Rscript?

2009-11-19 Thread Peng Yu
> > Alfredo > > > On Sun Sep 06 12:52:31 EDT 2009, Peng Yu wrote: > >> Hi, >> >> In 'example(barplot)' running in R, I see 'Hit to see next >> plot:', then R waits for my input. I am wondering how to wait for a >> user response in

[R] Is there an variant of apply() that does not return anything?

2009-11-19 Thread Peng Yu
There are a few version of apply() (e.g., lapply(), sapply()). I'm wondering if there is one that does not return anything but just silently apply a function to the list argument. For example, the plot function is applied to each element in 'alist'. It is redundant to return anything from apply.

Re: [R] Is there an variant of apply() that does not return anything?

2009-11-19 Thread Peng Yu
On Thu, Nov 19, 2009 at 4:27 PM, Marc Schwartz wrote: > On Nov 20, 2009, at 10:21 AM, Peng Yu wrote: > >> There are a few version of apply() (e.g., lapply(), sapply()). I'm >> wondering if there is one that does not return anything but just >> silently apply a

Re: [R] Is there an variant of apply() that does not return anything?

2009-11-19 Thread Peng Yu
do something with the name of x do something with x } On Fri, Nov 20, 2009 at 4:35 PM, Jorge Ivan Velez wrote: > If I understood correctly > for(x in names(List)) print(x) > should do what you asked. > HTH, Jorge > > On Thu, Nov 19, 2009 at 5:31 PM, Peng Yu <> wrote: >>

[R] read a file into a matrix

2009-11-20 Thread Peng Yu
read.delim gives me a data.frame. Is there a function that can return the result in a matrix rather than data.frame? __ 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.o

Re: [R] read a file into a matrix

2009-11-20 Thread Peng Yu
On Sat, Nov 21, 2009 at 11:55 AM, Steve Lianoglou wrote: >> read.delim gives me a data.frame. Is there a function that can return >> the result in a matrix rather than data.frame? > > m <- as.matrix(read.delim(..)) I knew this approach. But this takes an extra step. Is there a command that read a

[R] How to put x-axis labels vertically?

2009-11-20 Thread Peng Yu
image(array,axes=F) axis(side=1,at=seq(from=par()$usr[1],to=par()$usr[2],length=size),labels=some_labels) I have the above code to plot a heatmap. But I want to make the labels on the x-axis vertical. Could somebody let me know how to do it? __ R-help@r

[R] How to concatenate a vector of strings to a string?

2009-11-20 Thread Peng Yu
> paste(c('a','b'),sep='') [1] "a" "b" The above command doesn't concatenate the strings in a single string. I'm wondering what is the correct way to do so. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

[R] How to change the label font size?

2009-11-20 Thread Peng Yu
The labels on the axis overlap. Is there a way to change their font size smaller? m=100 n=100 X=replicate(n,rnorm(m)) image(X,axes=F) axis(side=1,at=seq(from=par()$usr[1],to=par()$usr[2],length=(m+1))[1:m],labels=replicate(m, 'A'),las=2) __ R-help@r-pr

<    1   2   3   4   >