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 Aquino 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 interactio

[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 rel

[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 d

[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 https://stat.e

[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? ht

Re: [R] Example scripts for R Manual

2009-08-10 Thread Peng Yu
Is it really necessary? You can just copy the commands in the manual > and paste them to R. > > Ronggui > > 2009/8/11 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

[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 https://stat.ethz.ch/

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

2009-08-11 Thread Peng Yu
iles, ...){ >        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

[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 'lap

[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 k

[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 https://stat.ethz.ch/mailman/listinfo/r-help

[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 $ Rsc

[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 #end

[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

[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 ma

[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 https://s

[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] 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 http://ww

[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 sou

[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 E

[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 posti

[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,]2

[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, Pe

[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" > histor

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

2009-09-05 Thread Peng Yu
history(file="text.Rhistory") 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, &

[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? m

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

2009-09-05 Thread Peng Yu
n the directory that Rscript look for? That would > be the only way 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. > > -- &g

[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 and

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

2009-09-05 Thread Peng Yu
x(1: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 Dallazuanna wrote: > Yes, see mapply. > > On Sat, Sep 5, 2009 at 12:18 PM, Peng Yu wrote: >> >> Hi, >> >> I am wonder if

[R] How to figure the type of a variable?

2009-09-06 Thread Peng Yu
Hi, I want to know what is there returned values of 'lm'. 'class' and 'lm' does not show that the returned value has the variable coefficients, etc. I am wondering what is the command to show the detailed information. If possible, I aslo want the lower level information. For example, I want to sho

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 ARTURO wrote: > maybe > > windows() > > > On Sun Sep 06 12:53:14 EDT 2009

[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 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 https://stat.ethz.ch/mailman/listinfo/r-hel

[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 htt

[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) > attr(x,"n

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 Winsemius 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 >&g

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

2009-09-06 Thread Peng Yu
> > par(ask=T) > > 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

[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-help

[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 https://stat.ethz.ch/mailman/l

[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 print

[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 http://www.R-project.o

Re: [R] get the command line

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

[R] How to refer to the last a few rows?

2009-09-14 Thread Peng Yu
Hi, x=matrix(1:60,nr=6) I can refer the last 2 rows by x[5:6,] If I don't know the total number of rows is 6, is there a way to refer the last 2 rows? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLE

[R] What are the return values of aov?

2009-09-14 Thread Peng Yu
Hi, I don't quite understand what are the return values of aov. I know that it has 'coefficients'. But I need to know what all the other return values are. Can somebody let me know how to figure them? Value: An object of class 'c("aov", "lm")' or for multiple responses of class 'c("mao

Re: [R] What are the return values of aov?

2009-09-14 Thread Peng Yu
es" "assign""qr""df.residual" [9] "contrasts" "xlevels" "call" "terms" [13] "model" On Mon, Sep 14, 2009 at 4:01 PM, Jorge Ivan Velez wrote: > Hi Peng, > Try > n

Re: [R] What are the return values of aov?

2009-09-14 Thread Peng Yu
; that was probably in S-PLUS (not in the version of R on my laptop).  In this > case, many of the details are on the help page for lm, which is only obvious > when you realize that aov is a wrapper for lm, but not quite so obvious for > the beginner (so Peng Yu, look at ?lm). > >

[R] syntax of formula

2009-09-14 Thread Peng Yu
Hi, I am looking for a complete description of the syntax of the formula that shall be specified in, for example, aov. But I can't find a complete description. Can somebody point to me if there is such a resource? Regards, Peng __ R-help@r-project.org

[R] How to know the current line number in browser()?

2009-09-15 Thread Peng Yu
Hi, I tried the command 'where' in browser(). But it does not give me the current line number (or the content of the current line). Is there a command for this? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-

[R] coefficients of aov results has less number of elements?

2009-09-15 Thread Peng Yu
Hi, I run the following commands. 'A' has 3 levels and 'B' has 4 levels. Should there be totally 3+4 = 7 coefficients (A1, A2, A3, B1, B2, B3, B4)? > a=3 > b=4 > n=1000 > A = rep(sapply(1:a,function(x){rep(x,n)}),b) > B = as.vector(sapply(sapply(1:b, function(x){rep(x,n)}), > function(x){rep(x,a

[R] How to remove 'NA's?

2009-09-15 Thread Peng Yu
Hi, > match(c(3,4), c(3,2,1)) [1] 1 NA The above result has 'NA' in. Is there a way to make 'match' does not produce any 'NA's? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

[R] What does 'collapse' mean in apply()?

2009-09-16 Thread Peng Yu
Hi, I can't find 'collapse' in the help of apply. Can somebody let me know where its document is? What is 'collapse' for? > x=matrix(1:6,nr=2) > apply(x,1,paste,collapse=',') [1] "1,3,5" "2,4,6" > Regards, Peng __ R-help@r-project.org mailing list htt

[R] What is the difference between double quote (") and single quote (')?

2009-09-16 Thread Peng Yu
Hi, According to my understand of the description in R-intro, double quote and single quote are the same. Can somebody confirm if this is the case? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE d

[R] How to convert a frame to a matrix while maintaining that a number is still a number?

2009-09-16 Thread Peng Yu
Hi, See the code below. 'x' is a frame. x$C1 are all numbers 1, 2 and 3. 'as.matrix(x)' convert x$C1 to strings "1", "2" and "3". I'm wondering how to maintain that the first column of 'as.matrix(x)' still numbers. Regards, Peng $ cat read.csv "C1","C2" "1","x" "2","y" "3","z" $ Rscript read.c

[R] How not to keep the redundant space when convert a data frame with as.matrix()?

2009-09-16 Thread Peng Yu
Hi, The first column in as.matrix(x) has extra spaces (" "), which I don't want. Is there a way not to generate those spaces? Regards, Peng > x=data.frame(x=1:10,y=letters[11:20]) > as.matrix(x) xy [1,] " 1" "k" [2,] " 2" "l" [3,] " 3" "m" [4,] " 4" "n" [5,] " 5" "o" [6,] " 6" "p

[R] Why strsplit can be used with matrix but not data.frame?

2009-09-16 Thread Peng Yu
Hi, As show in the code below, strsplit can be applied to a matrix but not a data.frame. I don't understand why R is designed in this way. Can somebody help me understand it? How to split all the strings in x$y? x=data.frame(x=1:10,y=rep("abc",10)) strsplit(x$y,'b') #Error in strsplit(x$y, "b") :

Re: [R] Why strsplit can be used with matrix but not data.frame?

2009-09-16 Thread Peng Yu
On Wed, Sep 16, 2009 at 8:30 PM, David Winsemius wrote: > > On Sep 16, 2009, at 9:22 PM, Peng Yu wrote: > >> Hi, >> >> As show in the code below, strsplit can be applied to a matrix but not >> a data.frame. I don't understand why R is designed in this way.

[R] What is the best way to get a subset of a data.frame?

2009-09-16 Thread Peng Yu
Hi, I want to construct a data.frame 'y' by using x$x and x$y. I think that there might be better ways to do it (because, for example, we can use a_matrix[3:5,] to extract certain rows, where 'a_matrix' is a matrix). Can somebody let know what the best way is? > a=data.frame(x=1:10,y=rep("abc",10

[R] Which one shall I use? '=' or '<-'?

2009-09-16 Thread Peng Yu
Hi, I was told to use "<-" instead of "=" in the mailing list. I am wondering what the difference between them? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www

[R] How to extract data.frame columns using regex?

2009-09-16 Thread Peng Yu
Hi, data.frame(x1=1:11,x2=2:12,x3=3:13,y=4:14) I want to extract all the columns that with the name 'x?'. Is there a general way to do this in R? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

[R] What is the time complexity of 'match()'?

2009-09-17 Thread Peng Yu
Hi, Suppose 'x' is a vector of length n and 'y' is a vector of length m, I am wondering what the time complexity of 'match(x,y)' is. Is it n times m? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

[R] How to generate a matrix where each row (or column) is the same vector?

2009-09-17 Thread Peng Yu
Hi, I can use the following code to generate a matrix, each column of which is 'x'. But I have to specify '5' twice in the second command. I am wondering if there is a better way to do it. > x=1:10 > matrix(rep(x,5),nc=5) > t(matrix(rep(x,5),nc=5)) Regards, Peng

[R] What does model.matrix() return?

2009-09-17 Thread Peng Yu
Hi, I don't understand what the meaning of the following lines returned by model.matrix(). Can somebody help me understand it? What can they be used for? attr(,"assign") [1] 0 1 2 2 attr(,"contrasts") attr(,"contrasts")$A [1] "contr.treatment" attr(,"contrasts")$B [1] "contr.treatment" Regards,

[R] r-inferno.pdf with detailed table of contents and bookmarks

2009-09-17 Thread Peng Yu
Hi, I don't find a r-inferno.pdf that has detailed table of contents and bookmarks. If it is possible, can somebody help generated one and post it on line? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

[R] How write the same number of elements in the first line as the rest of the file with write.table()?

2009-09-17 Thread Peng Yu
Hi, The first line has less elements than the rest of 'rownames_colnames.write.table.xls'. I am wondering if there is a way to print an additional '\t' at the beginning of the first line. $ Rscript write.table.R > x=matrix(1:20,nc=2) > rownames(x)=letters[1:10] > colnames(x)=letters[1:2] > write.

[R] Weird read.table error? (line `n' did not have `m' elements)

2009-09-21 Thread Peng Yu
Hi, I have the following commands. It says line 5205 does not have 22 elements. But I use my 'vim' checked that line in the file. It has 22 fields. Can somebody let me know how to further debug this case? Regards, Peng > annotation = read.table("../EC_results/Juan_15wks_gene_core.xls", header=T,

Re: [R] Weird read.table error? (line `n' did not have `m' elements)

2009-09-21 Thread Peng Yu
On Mon, Sep 21, 2009 at 9:12 PM, Peng Yu wrote: > Hi, > > I have the following commands. It says line 5205 does not have 22 > elements. But I use my 'vim' checked that line in the file. It has 22 > fields. Can somebody let me know how to further debug this

Re: [R] Weird read.table error? (line `n' did not have `m' elements)

2009-09-21 Thread Peng Yu
---\t---" On Mon, Sep 21, 2009 at 9:34 PM, Gabor Grothendieck wrote: > Its highly unusual to use xls as the extension for a text file. > Use something more suggestive. > > print out the line in question.  For example, note that scan > and read.table have different defaults for the

[R] Singular model.matrix of nested designs

2009-09-22 Thread Peng Yu
Hi, I want to do ANOVA for nested designs like following. I don't understand why the matrix (t(X) %*% X) is singular. Can somebody help me understand it? Regards, Peng > a=2 > b=3 > n=4 > A = as.vector(sapply(1:a,function(x){rep(x,b*n)})) > B = as.vector(sapply(1:(a*b), function(x){rep(x,n)})) >

[R] How to get the current script file name in the script?

2009-09-22 Thread Peng Yu
Hi, Right now, I hardcode the file name in the script. But when I change the script name, I have to change the file name in the script to make sure the file name inside the script is synchronized with the script name. I am wondering if there is an automatic way to get the script file name in a scr

Re: [R] Singular model.matrix of nested designs

2009-09-22 Thread Peng Yu
On Tue, Sep 22, 2009 at 5:00 PM, Uwe Ligges wrote: > > > Peng Yu wrote: >> >> Hi, >> >> I want to do ANOVA for nested designs like following. I don't >> understand why the matrix (t(X) %*% X) is singular. Can somebody help >> me understand it?

[R] How to read zip file?

2009-09-22 Thread Peng Yu
Hi, Suppose that I have a csv file that is compressed with zip, is there a way to read it in R without first decompressing it to a file. Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] How to read zip file?

2009-09-22 Thread Peng Yu
No. My machine is a linux machine. On Tue, Sep 22, 2009 at 9:02 PM, Gabor Grothendieck wrote: > If you have the 7z zip utility and are on Windows > (or use 7z and grep on UNIX): > > DF <- read.csv(pipe("7z x myfile.zip -so | findstr $")) > > > On Tue, Sep 2

[R] strange split behavior?

2009-09-22 Thread Peng Yu
Hi, Please see the command with a comment below. I don't find 'A630039F22Rik' in y. But 'A630039F22Rik' is in z. Can somebody let me know what the problem is? Regards, Peng > str(x) int [1:365494] 6 7 8 14 15 18 19 21 25 29 ... > str(y) Factor w/ 29904 levels "0610005C13Rik",..: 17261 28617 15

Re: [R] strange split behavior?

2009-09-23 Thread Peng Yu
On Wed, Sep 23, 2009 at 1:24 AM, Peter Dalgaard wrote: > Peng Yu wrote: >> >> Hi, >> >> Please see the command with a comment below. I don't find >> 'A630039F22Rik' in y. But 'A630039F22Rik' is in z. Can somebody let me >> know wh

[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? http://wiki.r-project.org/

[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 ma

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

2009-08-06 Thread Peng Yu
Thu, Aug 6, 2009 at 9:45 AM, Erik Iverson 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 O

[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 gu

[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
f rather than R. > > > > On Thu, Aug 6, 2009 at 11:18 AM, Peng Yu wrote: > > I didn't know that OS matters. My machine is a linux machine. > > > I have a few different version of R installed in my machine (different > > commands like R, R-2.9.0, R-2.8 ..). Bu

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

2009-08-06 Thread Peng Yu
t; dump.pager <- function( files, ...){ >         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)",

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 Aquino 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 interactio

[R] How to show number in the %f format?

2009-09-23 Thread Peng Yu
Hi, I have the following matrix, which is printed %e format (in C's way). I am wondering how make it be printed in %f format (in C's way)? Regards, Peng > significant_analysis_results[,7:8] pval(ki-wt) pval(ko-wt) Nab2 1.913348979e-06 2.731944670e-09 Rasal12.482254110e

Re: [R] How to show number in the %f format?

2009-09-23 Thread Peng Yu
On Wed, Sep 23, 2009 at 5:16 PM, David Winsemius wrote: > > On Sep 23, 2009, at 5:58 PM, Peng Yu wrote: > >> Hi, >> >> I have the following matrix, which is printed %e format (in C's way). >> I am wondering how make it be printed in %f format (in C's

[R] How to open only one file in a .gz file?

2009-09-25 Thread Peng Yu
Hi, Suppose that there are multiple files in a .gz file. How to open only one file in it? I don't find such options in the help. Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

[R] Looking for a textbook that is more concise than Applied Linear Statistical Models (2004 version)

2009-09-26 Thread Peng Yu
Hi, I know this is a little bit offtopic on this list. But I can't find a more appropriate forum that I can ask. If there is a high quality forum on statistics textbook discussion, please let me know. I am reading Applied Linear Statistical Models. One drawback that I feel about this book is that

[R] How to compile R with command completion?

2009-09-29 Thread Peng Yu
Hi, I want to compile R with command completion. But I don't find such an option in configure. Can somebody let me know how to enable command completion in an R session? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/li

Re: [R] How to compile R with command completion?

2009-09-29 Thread Peng Yu
On Tue, Sep 29, 2009 at 3:47 PM, Tobias Verbeke wrote: > Peng Yu wrote: > >> I want to compile R with command completion. But I don't find such an >> option in configure. Can somebody let me know how to enable command >> completion in an R session? > > AFAIK

Re: [R] How to compile R with command completion?

2009-09-30 Thread Peng Yu
On Tue, Sep 29, 2009 at 10:39 PM, Martin Morgan wrote: > Peng Yu wrote: >> On Tue, Sep 29, 2009 at 3:47 PM, Tobias Verbeke >> wrote: >>> Peng Yu wrote: >>> >>>> I want to compile R with command completion. But I don't find such an >>>&g

[R] How to get duplicated items in a vector?

2009-10-01 Thread Peng Yu
Hi, > x=c(rep(1,3),rep(3,2)) > x [1] 1 1 1 3 3 > duplicated(x) [1] FALSE TRUE TRUE FALSE TRUE > As shown in the above code, 'duplicated' doesn't return 'F' for the first '1' and first '3' in 'x'. I am wondering if there is a function that can return an indicator for any element whether it appe

[R] How to show clustering results?

2009-10-03 Thread Peng Yu
Hi, I know the following code can show the dendrogram. But I also want to plot the points on a figure and have circles (or boxes) around the points in a cluster (see http://www.autonlab.org/tutorials/kmeans11.pdf for some examples). I am wondering how to do so in R. Regards, Peng x1 = c(0,0) x2

[R] Is there a recent book on Q-Q plot and data visualization in general?

2009-10-06 Thread Peng Yu
Hi, I want to look for some detailed explanation on the properties of Q-Q plot and how the properties are derived. In R, there is the following reference. Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole. Somebody also mentioned the following boo

Re: [R] Is there a recent book on Q-Q plot and data visualization in general?

2009-10-06 Thread Peng Yu
TF8&s=books&qid=1254856526&sr=8-1#reader Regards, Peng On Tue, Oct 6, 2009 at 9:50 AM, Paul Hiemstra wrote: > Hi Peng Yu, > > Chapter 13 of the following book provides a good description of the > assumption done when using regression and other techniques. It also >

[R] Robust estimation references

2009-10-07 Thread Peng Yu
Hi, Can somebody help recommend some good introductory textbooks on robust estimation (graduate school level)? I found this one, but the reviews on this are quite diverse. http://www.amazon.com/Introduction-Estimation-Hypothesis-Statistical-Modeling/dp/0127515429/ref=sr_1_1?ie=UTF8&s=books&qid=1

[R] How to start R in mac with the current directory as the current working directory?

2009-10-08 Thread Peng Yu
Hi, I installed R on mac (see below). When I start it from a terminal by the following command, the current working directory is always '~' no matter where my current directory is in the terminal. I'm wondering if there is a way to make the gui R on mac inherent the current directory from the term

[R] 64-bit R on mac

2009-10-08 Thread Peng Yu
Hi, My Mac OS is Leopard. I downloaded R-GUI-5496-2.9-leopard-Leopard64.dmg from http://r.research.att.com/. I run R from the image disk, but it always "quit unexpectedly". What could cause the problem? Is it because that I have a 32 bit R installed already installed in the same machine. Regards

Re: [R] How to start R in mac with the current directory as the current working directory?

2009-10-08 Thread Peng Yu
On Thu, Oct 8, 2009 at 10:57 AM, Steve Lianoglou wrote: > Hi Peng, > > On Oct 8, 2009, at 11:21 AM, Peng Yu wrote: > >> Hi, >> >> I installed R on mac (see below). When I start it from a terminal by >> the following command, the current working directory

[R] Is there a book that summarizes different correlation methods?

2009-10-08 Thread Peng Yu
Hi, I know what the following correlation methods ("pearson", "kendall", "spearman") are through wiki. But I'm wondering if there is a good book that discuss why these metrics are defined and when to use one coefficient versus the others. cor.test(x, y, alternative = c("two.sided", "less

  1   2   3   4   >