Re: [R] How to pop up the graphics window from Rscript?

2009-09-06 Thread Peng Yu
I get the following error. $ Rscript plot.R x=1:10 y=1:10 windows() Error: could not find function windows Execution halted On Sun, Sep 6, 2009 at 11:59 AM, RIOS,ALFREDO ARTUROar...@ufl.edu wrote: maybe windows() On Sun Sep 06 12:53:14 EDT 2009, Peng Yu pengyu...@gmail.com wrote: Hi

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

2009-09-06 Thread Peng Yu
Hi, In 'example(barplot)' running in R, I see 'Hit Return to see next plot:', then R waits for my input. I am wondering how to wait for a user response in Rscript. Regards, Peng __ R-help@r-project.org mailing list

[R] How to refer the element in a named list?

2009-09-06 Thread Peng Yu
Hi, I thought that 'coefficients' is a named list, but I can not refer to its element by something like r$coefficients$y. I used str() to check r. It says the following. Can somebody let me know what it means? ..- attr(*, names)= chr [1:2] (Intercept) y $ Rscript lm.R x=1:10 y=1:10

[R] How to pop up the graphics window from Rscript?

2009-09-06 Thread Peng Yu
Hi, I am wondering how to pop up the graphics window from Rscript. I run the following code, but I don't see the graphics window, even transiently. Regards, Peng $ Rscript plot.R x=1:10 y=1:10 plot(x,y) __ R-help@r-project.org mailing list

[R] How many attributes are there of a variable?

2009-09-06 Thread Peng Yu
Hi, According to the example below this email, attr(x,names) is the same as names(x). I am wondering how many attributes there are of a given variable. How to find out what they are? Can I always use some_attribute(x) instead of attr(x, some_attribute)? Regards, Peng x=c(1,2,3)

Re: [R] How to refer the element in a named list?

2009-09-06 Thread Peng Yu
On Sun, Sep 6, 2009 at 12:45 PM, David Winsemiusdwinsem...@comcast.net wrote: On Sep 6, 2009, at 1:35 PM, Duncan Murdoch wrote: On 06/09/2009 1:04 PM, Peng Yu wrote: Hi, I thought that 'coefficients' is a named list, but I can not refer to its element by something like r$coefficients$y. I

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

2009-09-06 Thread Peng Yu
On Sun Sep 06 12:52:31 EDT 2009, Peng Yu pengyu...@gmail.com wrote: Hi, In 'example(barplot)' running in R, I see 'Hit Return to see next plot:', then R waits for my input. I am wondering how to wait for a user response in Rscript. Regards, Peng

[R] Is there a package for generating standardized R script command line options?

2009-09-06 Thread Peng Yu
Hi, In python, there is a package that helps generating command line options. I am wondering if there is such a package in R that helps generating the command options for a R script? http://docs.python.org/library/optparse.html Regards, Peng __

[R] Why tempdir() always give me the same results in the same session?

2009-09-06 Thread Peng Yu
Hi, tempdir() always gives me the same result. Should it give a different result each time I call it? tempdir() [1] /tmp/RtmppB72wH tempdir() [1] /tmp/RtmppB72wH Regards, Peng __ R-help@r-project.org mailing list

[R] Why this statement does not print anything in an if-statement that includes 'q()'?

2009-09-06 Thread Peng Yu
Hi, I run the following script. I don't understand why the second 'length(args)' does not show anything but the first one shows '0'. Is it because the command 'q()' affects anything in the if-statement. However, if I change the second 'length(args)' to 'print(length(args))', the script will

[R] get the command line

2009-09-06 Thread Peng Yu
Hi, commandArgs gives me the arguments. I am wondering what command can give the whole command line. Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] get the command line

2009-09-06 Thread Peng Yu
On Sun, Sep 6, 2009 at 10:50 PM, Steve Lianogloumailinglist.honey...@gmail.com wrote: Hi, On Sun, Sep 6, 2009 at 11:25 PM, Peng Yupengyu...@gmail.com wrote: Hi, commandArgs gives me the arguments. I am wondering what command can give the whole command line. What does the whole command

Re: [R] Is 'history' recorded in Rscript?

2009-09-05 Thread Peng Yu
) and see if the history file is easier to find. Should be in your working directory. Rscript is a program, not a record of the prior session. --  David. On Sep 4, 2009, at 11:03 PM, Peng Yu wrote: Hi, I run the following command and try to save the commands that have been run in the script

[R] How to 'apply' on multiple arguments?

2009-09-05 Thread Peng Yu
Hi, I am wonder if there is a function similar 'apply' but it could accept multiple arguments? For example, I have the following matrix. x=matrix(1:6,nr=2) y=matrix(1:6,nr=2) I want to find a function that can be used to compute the linear regression for each pair of rows in the two matrices?

Re: [R] Is 'history' recorded in Rscript?

2009-09-05 Thread Peng Yu
that a savehistory.R file would exist. So what OS? What did you do before this failed effort? And what are you really trying to do? Then perhaps someone familiar with your OS can answer. -- David . On Sep 5, 2009, at 10:52 AM, Peng Yu wrote: Hi, I got the following error. Does it mean

[R] linear regression between two lists of vectors?

2009-09-05 Thread Peng Yu
Hi, I am not familiar enough with statistics yet. Please excuse me if my question is wrong. In the simplest form of linear regression, the data points are two list of scalars x_1, ..., x_n and y_1, ..., y_n. I am wondering if there is a linear regression for two lists of vectors X_1, ..., X_n

Re: [R] How to 'apply' on multiple arguments?

2009-09-05 Thread Peng Yu
:6,nr=2) y=matrix(1:6,nr=2) mapply(function(u,v){u + v},x,y) [1] 2 4 6 8 10 12 On Sat, Sep 5, 2009 at 10:59 AM, Henrique Dallazuannawww...@gmail.com wrote: Yes, see mapply. On Sat, Sep 5, 2009 at 12:18 PM, Peng Yu pengyu...@gmail.com wrote: Hi, I am wonder if there is a function

[R] What is the difference between read.delim and read.delim2?

2009-09-04 Thread Peng Yu
Hi, I don't see what the difference between read.delim and read.delim2 after reading the help. Can somebody let me know what it is? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

[R] How to join two matrices?

2009-09-04 Thread Peng Yu
Hi, Suppose I have the following two matrices. x=matrix(1:4,nr=2) y=matrix(5:8,nr=2) I want to join the two matrices to get the following two new matrices. I did a search but I don't find any relevant webpage. Can somebody let me know how to do it? [,1] [,2] [1,]13 [2,]24

[R] How to or or and all the values in a logical vector?

2009-09-04 Thread Peng Yu
Hi, Suppose I have a logical vector x, I want to compute the 'and' and 'or' of all its element (the result should be a single value TRUE or FALSE). I have read the R-intro.pdf logical vector section, but I don't find the answer. Can somebody let me know how to do it? x= rep(TRUE, 3) Regards,

[R] Is 'history' recorded in Rscript?

2009-09-04 Thread Peng Yu
Hi, I run the following command and try to save the commands that have been run in the script. But it seems that no history is recorded. Is it because that the history is not recorded in Rscript? Regards, Peng $ Rscript savehistory.R f=tempfile() f [1] /tmp/Rtmp7WBjGG/file327b23c6 history()

[R] How to source a script with command line option?

2009-08-28 Thread Peng Yu
Hi, Suppose that I have the following script. $ cat commandArgs.R args=commandArgs(trailingOnly=TRUE) args[1] I can supply command line options $ Rscript commandArgs.R a args=commandArgs(trailingOnly=TRUE) args[1] [1] a I am wondering how to supply the command line arguments when I source

[R] How to convert a string passed as an argument to a vector?

2009-08-28 Thread Peng Yu
Hi, $ cat commandArgs.R args=commandArgs(trailingOnly=TRUE) args[1]+10 I have the above code. But the following command line gives me an error. I am wondering what is the correct way to convert a string to a vector? $ Rscript commandArgs.R 1:3 args=commandArgs(trailingOnly=TRUE) args[1]+10

[R] How to create a random matrix

2009-08-24 Thread Peng Yu
Hi, I did a search but I was able to find how to generate a random matrix. Can somebody let me know how to do it? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] Call perl from R

2009-08-22 Thread Peng Yu
Hi, I see the following package that can help me call perl from R. But the webpage is about 3 years old. I am wondering what the latest package that can help calling perl from R. http://www.omegahat.org/RSPerl/ Regards, Peng __ R-help@r-project.org

[R] Latest information on how to debug R script

2009-08-22 Thread Peng Yu
Hi, http://cran.r-project.org/doc/Rnews/Rnews_2003-3.pdf There is information on how to debug R. But since it is fairly old, I am wondering what the currently best way for debugging R script. Regards, Peng __ R-help@r-project.org mailing list

[R] How to generate an error message when 'match' does not find any matches?

2009-08-22 Thread Peng Yu
Hi, match(4, c(1,2,3)) [1] NA The above code run smoothly. It would not stop when 4 does not mach in c(1,2,3). I am wondering if there is a way to stop the code and pop up an error message immediately. This capability to stop will make debugging easier. Regards, Peng

[R] When factor is better than other types, such as vector and frame?

2009-08-22 Thread Peng Yu
Hi, It is easy to understand the types vector and frame. But I am wondering why the type factor is designed in R. What is the advantage of factor compare with other data types in R? Can somebody give an example in which case the type factor is much better than other data types? Regards, Peng

[R] Command line option to an R script running through Rscript

2009-08-19 Thread Peng Yu
Hi, I know that I can use the following script to get the command line options for an R script. But the output shows two many irrelevant arguments. For example, I only want to pass a, b and c to the script. The first 5 elements in the variable 'args' are not what I want. I am wondering what is

[R] Is there a construct for conditional comment?

2009-08-18 Thread Peng Yu
Hi, In C++, I can use the following construct to choice either of the two blocks the comment but not both. Depending on whether the number after #if is zero or not, the commented block can be chose. I'm wondering if such thing is possible in R? #if 0 commented with 0 #else commented with 1

[R] Can a variable name include '_' or '.' in portable R code

2009-08-16 Thread Peng Yu
Hi, It says in R-intro.pdf, For portable R code (including that to be used in R packages) only A–Za–z0–9 should be used. I'm an wondering why '_' and '.' can be used in portable R code. It very common that some variable name should be composed of two or more English words. Can somebody let me

[R] How to show line number when using Rscript?

2009-08-16 Thread Peng Yu
Hi, When I use Rscript to run an R script, I want Rscript show the line numbers along with the commands executed. I am wondering if there is a way to do so. Regards, Peng __ R-help@r-project.org mailing list

[R] What is the returned type of strsplit?

2009-08-16 Thread Peng Yu
Hi, I run the following program. I thought that 'b' was a matrix. But it is actually not, right? Can somebody elaborate more on the type difference between 'b' and 'c' to help me understand it better? Why 'c' is what it is now? Why 'c' is not the transpose of what it is now? Regards, Peng $

[R] How to specify an addition Rprofile file for Rscript in the command line?

2009-08-11 Thread Peng Yu
Hi, When I use Rscript, I want that it load an additional Rprofile file besides the default ones. I don't find such an option. Can somebody let me know if there is such an option? Regards, Peng __ R-help@r-project.org mailing list

Re: [R] How to show help in the same mode as where the commands is input?

2009-08-11 Thread Peng Yu
, ...){        cat( readLines( files ), sep = \n ) } options( pager = dump.pager ) Romain On 08/06/2009 08:59 PM, Peng Yu wrote: Hi, In R command line, when I type help(something), it will always show the help in the different mode such that I don't see command lines anymore but just

[R] R help from command line

2009-08-11 Thread Peng Yu
Hi, I frequently need to open multiple help pages in R, which requires the start of multiple R sessions. I am wondering if there is a way to invoke the help page from the command line just like 'man'. Regards, Peng __ R-help@r-project.org mailing list

[R] Is there a summary on different version of 'apply' functions? What is the meaning of the prefixes?

2009-08-11 Thread Peng Yu
Hi, There are quiet a few different 'apply' functions, such as lapply, sapply and many more. I'm very familiar with the 'Apply' function in Mathematica. Can somebody point me a summary of all the 'apply' functions in R. Also, I'm curious that what 'l' and 's' (and other prefixes) stand for in

[R] Example scripts for R Manual

2009-08-10 Thread Peng Yu
Hi, I am wondering if some experienced users would help put the ready-to-run code of the examples in the manuals. It would help new users learn R faster by putting all the examples in an ready-to-run R script file. Can somebody help do so sometime and post the code along with the pdf manuals?

Re: [R] Example scripts for R Manual

2009-08-10 Thread Peng Yu
...@gmail.com wrote: Is it really necessary? You can just copy the commands in the manual and paste them to R. Ronggui 2009/8/11 Peng Yu pengyu...@gmail.com: Hi, I am wondering if some experienced users would help put the ready-to-run code of the examples in the manuals. It would help new

[R] How '.' is used?

2009-08-09 Thread Peng Yu
Hi, I know '.' is not a separator in R as in C++. I am wondering where it discusses the detailed usage of '.' in R. Can somebody point me a webpage, a manual or a book that discuss this? Regards, Peng __ R-help@r-project.org mailing list

[R] Which parts of the book Programming with Data: A Guide to the S Language are still relevant now?

2009-08-08 Thread Peng Yu
Hi, The book Programming with Data: A Guide to the S Language was published over 10 years ago. I know that to understand object oriented programming. I should read the associated section in this book. But I am wondering if other chapters, in particular Chapter 3. Quick Reference, are still

[R] How to show both the commands and the output on the screen?

2009-08-08 Thread Peng Yu
Hi, Rscript does not print the commands in the script. I am wondering what command can print both the commands as well as the output on the screen. Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

Re: [R] Is there a 'vi' mode in R?

2009-08-07 Thread Peng Yu
On Fri, Aug 7, 2009 at 5:04 AM, Jakson Alves de Aquinojaksonaqu...@gmail.com wrote: Peng Yu wrote: I'm wondering if R provide a vi mode in the command line just like other shells such as bash do. Can somebody let me know? I maintain a Vim plugin that makes the interaction with R easier

Re: [R] Is there a 'vi' mode in R?

2009-08-07 Thread Peng Yu
On Fri, Aug 7, 2009 at 5:04 AM, Jakson Alves de Aquinojaksonaqu...@gmail.com wrote: Peng Yu wrote: I'm wondering if R provide a vi mode in the command line just like other shells such as bash do. Can somebody let me know? I maintain a Vim plugin that makes the interaction with R easier

[R] How to execute a R script but outputting the result to the screen?

2009-08-06 Thread Peng Yu
Hi, If I run the below command, it will generate a file 'file.Rout' to save the output. But I want the output be shown in the screen directly. I'm wondering if there is a direct way to do so. R CMD BATCH file.R Regards, Peng __ R-help@r-project.org

Re: [R] How to execute a R script but outputting the result to the screen?

2009-08-06 Thread Peng Yu
, 2009 at 9:45 AM, Erik Iversoneiver...@nmdp.org wrote: You did not specify your OS, but you might try at the shell prompt: Rscript file.R See ?Rscript -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Thursday

[R] Is there a 'vi' mode in R?

2009-08-06 Thread Peng Yu
Hi, I'm wondering if R provide a vi mode in the command line just like other shells such as bash do. Can somebody let me know? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

[R] How to show help in the same mode as where the commands is input?

2009-08-06 Thread Peng Yu
Hi, In R command line, when I type help(something), it will always show the help in the different mode such that I don't see command lines anymore but just the help document. If I quit from the help mode, I will only see the command lines by not the help document. I would like the help document

Re: [R] How to execute a R script but outputting the result to the screen?

2009-08-06 Thread Peng Yu
-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Thursday, August 06, 2009 9:35 AM To: r-h...@stat.math.ethz.ch Subject: [R] How to execute a R script but outputting the result to the screen? Hi, If I run the below command, it will generate a file

Re: [R] How to show help in the same mode as where the commands is input?

2009-08-06 Thread Peng Yu
, ...){         cat( readLines( files ), sep = \n )} options( pager = dump.pager ) Romain On 08/06/2009 08:59 PM, Peng Yu wrote: Hi, In R command line, when I type help(something), it will always show the help in the different mode such that I don't see command lines anymore but just the help

[R] String manipulations

2009-07-24 Thread Peng Yu
Hi, I am looking for a reference page that gives me a complete list of R string manipulation operations. At this moment, I am looking for something like basename and dirname. The following webpage doesn't give me any information. Can somebody point me a better resource?

<    1   2   3   4