[R] Append Columns
Dear all, Can I use write.table to append columnns? Thanks for any help -MY [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Different Index behaviors of Array and Matrix
Dear all, I found a difference between the indexing of an array and that of a matrix when there are NA's in the index array. The screen copy is as follows. A - array(NA, dim=6) A [1] NA NA NA NA NA NA idx - c(1,NA,NA,4,5,6) B - c(10,20,30,40,50,60) A[idx] - B A [1] 10 NA NA 40 50 60 AA - matrix(NA,6,1) AA [,1] [1,] NA [2,] NA [3,] NA [4,] NA [5,] NA [6,] NA AA[idx,1] - B AA [,1] [1,] 10 [2,] NA [3,] NA [4,] 20 [5,] 30 [6,] 40 In the case of a array, we miss the elements (20 and 30) in B corresponding to the NA's in the index array. In the case of a matrix, 20 and 30 are assigned to the elements indexed by the indexes following the NA's. Is this a reasonable behavior. Thanks in advance for explanation. -MY [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to Arrange character vector in alphabetic order
Hi, Is there any function that can arrange a character in alphabetic order? Thanks for answer -MY [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] RE: How to Arrange character vector in alphabetic order
Sorry for not asking the question clearly. The elements of the character vector may consist of numbers not just letter. How to do that. Thanks. -MY From: Yao, Minghua Sent: Wed 8/25/2004 2:20 PM To: R Help Subject: How to Arrange character vector in alphabetic order Hi, Is there any function that can arrange a character in alphabetic order? Thanks for answer -MY [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How generate A01, A02, ..., A99?
Hi, Anyone can tell me how to generate A01, A02, ..., A99? paste(A, 1:99, sep=) generates A1, A2,..., A99. This is not what I want. Thanks for the help. -MY [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Laplacian Distribution
All, Could anybody please tell me how to generate Laplacian distributed random numbers? Thanks. Minghua [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Get Slot from a Class
Hello, everyone, I don't quite understand the following message: TTT - t.test(1:10, y=c(7:20)) class(TTT) [1] htest [EMAIL PROTECTED] Error: Trying to get slot p.value from an object whose class (htest) is not defined TTT$p.value [1] 1.855282e-05 Why the message says the class of TTT is not defined while class(TTT) gets htest? I appreciate the explanations? -Minghua [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Problems in plot
It seems to me that the problem happens to the graphic window that is generated immediately after the R window is minimized. Minghua From: [EMAIL PROTECTED] on behalf of Yao, Minghua Sent: Fri 4/30/2004 4:12 PM To: Prof Brian Ripley Cc: R Help Subject: RE: [R] Problems in plot The problem is still there if windows() is used. Minghua From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Thu 4/29/2004 9:31 AM To: Yao, Minghua Cc: R Help Subject: Re: [R] Problems in plot The primary graphics device under Windows is called *windows* not *x11*. Something in your Windows setup is sometimes failing to choose a reasonable window size. I have never seen that, and suspect it is nothing to do with it, but please use windows() and see if the problem vanishes. On Thu, 29 Apr 2004, Yao, Minghua wrote: Hello, I have R1.9.0 under Windows XP. My program plots several plots using x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. Sometimes, one of them generates a small frame only with title area R graphics: Device X (ACTIVE). The message in the console window is Error in plot.new() : Figure margins too large This program ran well under R1.6.X under Windows NT. It seems to me that it is not a specific x11() that generates that small graphics frame. Thank you for you help in advance. Minghua [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Problems in plot
My code is over 700 lines. That is why I didn't send it. I am sorry I did not tell you this. See this code, for(i in 1:20){ windows() par(cex = 0.75) plot(1:10) } if the RGui window is minimized immediately (by clicking the minimize button on the upper right corner) after the code is pasted and run. for(i in 1:20){ + windows() + par(cex = 0.75) + plot(1:10) + } Error in plot.new() : Figure margins too large I am using MDI mode. My operating system is Windows XP. Thanks. Minghua From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Tue 5/4/2004 10:49 AM To: Yao, Minghua Cc: R Help Subject: RE: [R] Problems in plot You have been asked for a reproducible set of conditions -- this is the first time `minimized' has been mentioned. If you can find a completely reproducible set of actions please file a bug report (after reading the FAQ section carefully). We cannot help you otherwise, and don't want to spend time guessing what you might have forgotten to tell us. (I see you have not told us if you use MDI or SDI mode, for example.) On Tue, 4 May 2004, Yao, Minghua wrote: It seems to me that the problem happens to the graphic window that is generated immediately after the R window is minimized. Minghua From: [EMAIL PROTECTED] on behalf of Yao, Minghua Sent: Fri 4/30/2004 4:12 PM To: Prof Brian Ripley Cc: R Help Subject: RE: [R] Problems in plot The problem is still there if windows() is used. Minghua From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Thu 4/29/2004 9:31 AM To: Yao, Minghua Cc: R Help Subject: Re: [R] Problems in plot The primary graphics device under Windows is called *windows* not *x11*. Something in your Windows setup is sometimes failing to choose a reasonable window size. I have never seen that, and suspect it is nothing to do with it, but please use windows() and see if the problem vanishes. On Thu, 29 Apr 2004, Yao, Minghua wrote: Hello, I have R1.9.0 under Windows XP. My program plots several plots using x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. Sometimes, one of them generates a small frame only with title area R graphics: Device X (ACTIVE). The message in the console window is Error in plot.new() : Figure margins too large This program ran well under R1.6.X under Windows NT. It seems to me that it is not a specific x11() that generates that small graphics frame. Thank you for you help in advance. Minghua -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Problems in plot
The problem is still there if windows() is used. Minghua From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Thu 4/29/2004 9:31 AM To: Yao, Minghua Cc: R Help Subject: Re: [R] Problems in plot The primary graphics device under Windows is called *windows* not *x11*. Something in your Windows setup is sometimes failing to choose a reasonable window size. I have never seen that, and suspect it is nothing to do with it, but please use windows() and see if the problem vanishes. On Thu, 29 Apr 2004, Yao, Minghua wrote: Hello, I have R1.9.0 under Windows XP. My program plots several plots using x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. Sometimes, one of them generates a small frame only with title area R graphics: Device X (ACTIVE). The message in the console window is Error in plot.new() : Figure margins too large This program ran well under R1.6.X under Windows NT. It seems to me that it is not a specific x11() that generates that small graphics frame. Thank you for you help in advance. Minghua [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problems in plot
Hello, I have R1.9.0 under Windows XP. My program plots several plots using x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. x11() par(cex = 0.75) .. Sometimes, one of them generates a small frame only with title area R graphics: Device X (ACTIVE). The message in the console window is Error in plot.new() : Figure margins too large This program ran well under R1.6.X under Windows NT. It seems to me that it is not a specific x11() that generates that small graphics frame. Thank you for you help in advance. Minghua [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problem in Installing Package from CRAN...
Hi, I have installed R 1.9.0 under Windows XP. When I used Packages-Install Package(s) from CRAN... to install the package 'gregmisc', I got this message: local({a - CRAN.packages() + install.packages(select.list(a[,1],,TRUE), .libPaths()[1], available=a)}) trying URL `http://cran.r-project.org/bin/windows/contrib/1.9/PACKAGES' Content type `text/plain; charset=iso-8859-1' length 17113 bytes opened URL downloaded 16Kb trying URL `http://cran.r-project.org/bin/windows/contrib/1.9/gregmisc_0.10.2.zip' Content type `application/zip' length 594089 bytes opened URL downloaded 580Kb Error in unpackPkg(foundpkgs[okp, 2], pkgnames[okp], lib, installWithVers) : Unable to create temp directory C:/PROGRA~1/R/rw1090/library\file2869 Thanks in advance for any help. Minghua [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Question on outer(x, y, FUN,...)
Dear R gurus, When I used outer(x, y, FUN, ...), I got error message when there was matrix multiplications with x or y in FUN. FUN worked fine when x and y were applied to it in FUN(x, y, ...). Is this a bug for outer( )? -MY [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Questions about Matrix
M - matrix(0, t+1, m) for (i in 1:(t+1)) for(j in 1:m) M[i,j] - (i-1-j)^n From: [EMAIL PROTECTED] on behalf of duoduo chen Sent: Mon 2/16/2004 2:41 PM To: [EMAIL PROTECTED] Subject: [R] Questions about Matrix How to Generate the Matrix (t+1)*m ? (0-1)^n (0-2)^n (0-m)^n (1-1)^n (1-2)^n (1-m)^n (2-1)^n (2-2)^n (2-m)^n .. ... ... (t-1)^n(t-2)^n (t-m)^n Appreciate your kindly help! - [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Help Needed on plot Function
Dear all, I want the title of the plot to print some parameters that change. Also, I want some spots on the plot to be labeled. Is that possible? Thanks in advance for your help. Minghua __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Excluding from an Array the Elements of Another Array
Hi, My question goes like this. I have two arrays A and B. I want to exclude from A the elements contained in B. Is there an easy way like A[A != x] to exclude a single one. Thanks for any help. Regards, -MY __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Sorting matrix or data frame
Dear all, Could anyone please tell me how to sort a matrix or a data frame against a column/row/component? Many thanks. -MY __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Std. errors of intercept and slope
Thanks, Ben. Could you tell me the formula for calculating this sd., given (x_i, y_i) (i=1,2,...,N)? We only have one intercept and slope for them. -Minghua -Original Message- From: Ben Bolker [mailto:[EMAIL PROTECTED] Sent: Friday, September 26, 2003 4:34 PM To: Yao, Minghua Cc: R Help (E-mail) Subject: Re: [R] Std. errors of intercept and slope Since the intercept and slope are estimated parameters, they have sampling distributions described by their means and standard deviations. The s.d. tells you the size of the uncertainty in intercept in slope. This is a pretty basic stats question -- you need to refer to a standard textbook or reference material ... Ben Bolker On Fri, 26 Sep 2003, Yao, Minghua wrote: Dear all, I have the following output generated by linear regression. Since there is only one regression intercept and one slope for one set of data, what is the meaning of std. error for intercept and that of slope? Thanks in advance. Sincerely, Minghua data(thuesen) attach(thuesen) lm(short.velocity~blood.glucose) Call: lm(formula = short.velocity ~ blood.glucose) Coefficients: (Intercept) blood.glucose 1.097810.02196 summary(lm(short.velocity~blood.glucose)) Call: lm(formula = short.velocity ~ blood.glucose) Residuals: Min 1Q Median 3Q Max -0.40141 -0.14760 -0.02202 0.03001 0.43490 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept)1.097810.11748 9.345 6.26e-09 *** blood.glucose 0.021960.01045 2.101 0.0479 * --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Residual standard error: 0.2167 on 21 degrees of freedom Multiple R-Squared: 0.1737, Adjusted R-squared: 0.1343 F-statistic: 4.414 on 1 and 21 DF, p-value: 0.0479 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- 620B Bartram Hall[EMAIL PROTECTED] Zoology Department, University of Floridahttp://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Question in Using sink function
Could anyone please explain to me why the following writes nothing into all.Rout file? If the for loop is removed, t.test output can be written into all.out. Thanks in advance. Minghua Yao .. zz - file(all.Rout, open=wt) sink(zz) for(i in 1:n) { Cy3-X[,2*i-1]; Cy5-X[,2*i]; t.test(Cy3, Cy5) } sink() close(zz) .. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Question in Using sink function
Thanks, Prof. Ripley. Right. I saw nothing, either, when I tried without for loop. Does anywhere in the documents mention that Autoprinting does not work inside a for() {} loop? Minghua -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 11:35 AM To: Yao, Minghua Cc: R Help (E-mail) Subject: Re: [R] Question in Using sink function Autoprinting does not work inside a for() {} loop, and you did not print anything. Try for(i in 1:10) {i} Did you try your problem without sink()? On Tue, 16 Sep 2003, Yao, Minghua wrote: Could anyone please explain to me why the following writes nothing into all.Rout file? If the for loop is removed, t.test output can be written into all.out. Thanks in advance. Minghua Yao .. zz - file(all.Rout, open=wt) sink(zz) for(i in 1:n) { Cy3-X[,2*i-1]; Cy5-X[,2*i]; t.test(Cy3, Cy5) } sink() close(zz) .. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] How to Write Message into a File?
Could any body please tell me how to write the message generated by, say, t.test() into a file? Thanks in advance. Minghua __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Package for Numerical Integral?
Dear all, Is there any package for numerically calculating an integral? Thanks in advance. -Minghua __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] How to copy and paste a R plot onto Word (or Power Point)
All, Anybody can tell how to export a R plot onto Word (or Power Point)? Many thanks in advance. -MY __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] NA points in loess function
Gurus, I used predict(loess(Y~X)); where Y and X are of the same length. But there are same NA's in both Y and X. Those NA's are in the same locations in Y and X. The following is the error messageI got: Error in [-(*tmp*, , i, value = predict(loess(Y~X))) : number of items to replace is not a multiple of replacement length If I replaced the NA's with a number, the function worked. What I want to do is to ignores those NA's. help(loess) doesn't say how to give value to na.action. It just says the default is to stop. Please help. Thank you in advance. -Minghua Yao __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] NA points in loess function
Thank you, Prof. Ripley. By adding na.action=na.exclude to loess function, the program runs great. I did omit some trivial things. But I still think it was NA's that caused troubles in predict or loess. Minghua -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 11:05 AM To: Yao, Minghua Cc: R Help (E-mail) Subject: Re: [R] NA points in loess function On Fri, 27 Jun 2003, Yao, Minghua wrote: Gurus, I used predict(loess(Y~X)); where Y and X are of the same length. But there are same NA's in both Y and X. Those NA's are in the same locations in Y and X. The following is the error messageI got: Error in [-(*tmp*, , i, value = predict(loess(Y~X))) : number of items to replace is not a multiple of replacement length If I replaced the NA's with a number, the function worked. What I want to do is to ignores those NA's. help(loess) doesn't say how to give value to na.action. It just says the default is to stop. Please help. Thank you in advance. You use na.action=na.exclude (to whatever), that is you give the argument a value just like any other argument. ?na.exclude may help you. However, your error message is not coming from predict or loess but from your usage of the result, so you have omitted some of the story (the part where you made an error, I think). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help