Re: [R] How to save R clean sessions in BATCH mode?
Le samedi 16 mai 2009 à 17:21 +0200, mcnda...@mncn.csic.es a écrit : Thanks a lot for all of you that have reply me about opening and ending R workspaces in BATCH mode. However replies were a king general and Im afraid I could not take the entire message from them. Therefore I chose to expose here a representative fraction of my work. I have 50 Rdata files (F1,F2,F3,F4, ,F50) with objects inside. I need to: open F1: - perform some simple operations with the objects - export the solution with write.table - end F1 session open F2 repeat procedures as F1 open F50 repeat procedures as F1 My difficulty here is to end a workspace and open one from the scratch to avoid mixing files from consecutive worksessions, and thus using R memory unnecessarily. I could use rm() to delete objects from the previous sessions but it seems not an efficient task. And re-loading R, rebuilding a whole process context, re-allocating memory is an efficient one ? Hah ! Any suggestions on how to perform this in Batch Mode? An examplified help would be nice! Why not encapsulate your procedures in a function taking the filename as its argument and loopîng on the filenames list ? Anything created in the function, being local to the function, will be (efficiently) cleaned up at the function exit. Magic... Exemple : ls() character(0) Foo-runif(10,0,1) ls() [1] Foo ?save.image save.image(Foo1.RData) ls() [1] Foo rm(list=ls()) Foo-letters[round(runif(10,min=1,max=26))] Foo [1] v m b y g u r f y q save.image(Foo2.RData) rm(list=ls()) bar-edit() bar-edit() Waiting for Emacs... bar function(filename) { load(file=filename) print(ls()) print(Foo) invisible(NULL) } ls() [1] bar bar(Foo1.RData) [1] filename Foo # Note : by default, ls() list the function's # environment, not the global one... ** no bar here... [1] 0.8030422 0.6326055 0.8188481 0.6161665 0.5917206 0.6631358 0.7290200 [8] 0.2970315 0.2016259 0.4473244 ls() [1] bar # Bar is still in the global environment... bar(Foo2.RData) [1] filename Foo [1] v m b y g u r f y q ls() [1] bar Good enough for you ? HTH, Emmanuel Charpentier __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Measures
Rafael Marconi Ramos rafaelmr at gmail.com writes: 1) (Goodman Kruskal) lambda 2) (Thiel's) uncertainty coefficient Dear Rafael, have you tried to search for Goodman Kruskal (solution be J Baron) and Thiel (comments by Marc Schwartz and Frank Harrell)? Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] One Sample Nonparametric
Charles Van deZande cvandy26 at gmail.com writes: I'm doing one and two sample nonparametric tests for the median using wilcox test. For a one-sample test I use: wilcox.test(x, mu =50 (or whatever), y=NULL,correct=TRUE) For two-sample test I use: wilcox.test(x,y,correct=TRUE) The problem is when I try to duplicate problems from textbooks, I get p-values that are much different from the examples from the literature. They are off by as much as 30% to 40%. Not even close. Using an exact argument doesn't change the p-value. What am I doing wrong? You have not posted the textbook example you tested. You can use dput to compactly post the data samples. Also check package coin. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sprintf() question
Hi The result of Windows is clearly strange. my Linux machine = good === sessionInfo() R version 2.9.0 (2009-04-17) x86_64-pc-linux-gnu locale: LC_CTYPE=ja_JP.EUC-JP;LC_NUMERIC=C;LC_TIME=ja_JP.EUC-JP;LC_COLLATE=ja_JP.EUC-JP; LC_MONETARY=C;LC_MESSAGES=ja_JP.EUC-JP;LC_PAPER=ja_JP.EUC-JP;LC_NAME=C;LC_ADDRES S=C;LC_TELEPHONE=C;LC_MEASUREMENT=ja_JP.EUC-JP;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base sprintf(%a,1:8) [1] 0x1p+0 0x1p+1 0x1.8p+1 0x1p+2 0x1.4p+2 0x1.8p+2 0x1.cp+2 [8] 0x1p+3 my Windows machine = OMG == sessionInfo() R version 2.9.0 (2009-04-17) i386-pc-mingw32 locale: LC_COLLATE=Japanese_Japan.932;LC_CTYPE=Japanese_Japan.932;LC_MONETARY=Japanese_Japan.932;LC_NUMERIC=C;LC_TIME=Japanese_Japan.932 attached base packages: [1] stats graphics grDevices utils datasets methods base sprintf(%a,1:8) [1] 0x1p+00x1 0x1.8 0x1p+4294967294 [5] 0x1.4p+4294967294 0x1.8p+4294967294 0x1.cp+4294967294 0x1p+4294967293 The result improved when I changed handling of uExponent as follows http://prs.ism.ac.jp/~nakama/working/sprintf_format_a.patch 2009/5/18 Daniel Nordlund djnordl...@verizon.net: -Original Message- From: Ted Harding [mailto:ted.hard...@manchester.ac.uk] Sent: Sunday, May 17, 2009 3:32 PM To: Daniel Nordlund Cc: r-help@r-project.org Subject: RE: [R] sprintf() question On 17-May-09 22:03:19, Daniel Nordlund wrote: When I type the following, I get results different from what I expected. sprintf('%a',3) [1] 0x1.8 Shouldn't the result be [1] 0x1.8p+2 Well, not p+2 but p+1 (0x1.8 = 1.1000[2] ; *2 = 11.000[2] = 3[10]) ; however, I get: sprintf('%a',3) # [1] 0x1.8p+1 which is indeed correct. R version 2.9.0 (2009-04-17) ## Same as yours platform i486-pc-linux-gnu ## Different from yours ... which perhaps suggests that there may be a mis-compilation in the Windows version. Ted. I read through the help ?sprintf and didn't find anything that changed my expectation. What am I misunderstanding? I am using R-2.9.0 binary from CRAN on Windows XP Pro, and my session info is sessionInfo() R version 2.9.0 (2009-04-17) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base Thanks for any enlightenment. Thanks Ted! Enlightenment is what I asked for, and it is what I got. I was having a senior moment I guess. I was picturing 8 as binary 0100, when obviously it is binary 1000. So yes, the required power of 2 is 1, and it is fine with me that Windows implementation does not display it. Thanks again. Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- EI-JI Nakama nakama (a) ki.rim.or.jp \u4e2d\u9593\u6804\u6cbb nakama (a) ki.rim.or.jp __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] (no subject)
Dear R users, Based on a set of binomial sample data, how would you utilize the nlm function in R to estimate the true proportion of the population? Thanks. Debbie _ [[elided Hotmail spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sprintf() question
Daniel Nordlund wrote: Enlightenment is what I asked for, and it is what I got. I was having a senior moment I guess. I was picturing 8 as binary 0100, when obviously it is binary 1000. So yes, the required power of 2 is 1, and it is fine with me that Windows implementation does not display it. Thanks again. Wouldn't be fine with me -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sprintf() question
-Original Message- From: Peter Dalgaard [mailto:p.dalga...@biostat.ku.dk] Sent: Monday, May 18, 2009 12:15 AM To: Daniel Nordlund Cc: ted.hard...@manchester.ac.uk; r-help@r-project.org Subject: Re: [R] sprintf() question Daniel Nordlund wrote: Enlightenment is what I asked for, and it is what I got. I was having a senior moment I guess. I was picturing 8 as binary 0100, when obviously it is binary 1000. So yes, the required power of 2 is 1, and it is fine with me that Windows implementation does not display it. Thanks again. Wouldn't be fine with me -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 In retrospect, Peter is absolutley correct. It is not ok. And EI-JI Nakama nakama (a) ki.rim.or.jp has pointed out some other infelicities in sprintf() on Windows systems. So I am going to bow out of this discussion and get some much needed sleep (12:23am PDT). I am sure that by the time I get up in the morning, the experts will have it figured out. Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] newbie: closing unused connection + readline
I don't understand why read.table would have a problem reading directly from a socket instead of a textConnection. Is this a bug? Some subtlety in the semantics of socketConnection as opposed to textConnection? Incorrect parameters when opening the socketConnection? No problem with socketConnection and read.table. I want to read a line at a time but when I use read.table (socketConnection) then it waits till client socket connection is closed; and entire data comes in as one big chunk. I am reading a line at a time since data will be available after every few seconds and I can process and obtain results of already generated data. Should I use some (eof) character in data so that read.table returns without client closing socket connection and I can read a line too? Thanks for your time sir(s). Regards -Aval. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you save in R?
prixel snickersoof at yahoo.com writes: I know it sounds like a silly question but whenever i click on save to file it doesn't save. Assuming it is Windows GUI and not your grandmother's knitting needles, save to file writes the selected part of the GUI to a file and is not that useful as a function. You should use File/Save Workspace instead, but better avoid this approach and use save(mydata1, mydata2, file=mydata.Rdata) instead to have reproducible results. whenever i use the function attach(___) it doesn't work, Best avoid using attach at all. It can be more confusing than helpful. and says object can not be found. i have a series of data (0,0,0,1,1) that i need to save, then i want to attach(...) it in another R window. Use load(the file you saved above.Rdata) instead in the new R Window. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you save in R?
I disagree with Dieter's last point. Whether you use 'attach' or 'load' should depend on whether you want the objects in the file to remain separate ('attach') or mixed into the global environment ('load'). Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of The R Inferno and A Guide for the Unwilling S User) Dieter Menne wrote: prixel snickersoof at yahoo.com writes: I know it sounds like a silly question but whenever i click on save to file it doesn't save. Assuming it is Windows GUI and not your grandmother's knitting needles, save to file writes the selected part of the GUI to a file and is not that useful as a function. You should use File/Save Workspace instead, but better avoid this approach and use save(mydata1, mydata2, file=mydata.Rdata) instead to have reproducible results. whenever i use the function attach(___) it doesn't work, Best avoid using attach at all. It can be more confusing than helpful. and says object can not be found. i have a series of data (0,0,0,1,1) that i need to save, then i want to attach(...) it in another R window. Use load(the file you saved above.Rdata) instead in the new R Window. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dickey-Fuller Tests with no constant and no trend
Dear Jake, have you had a look at the function 'ud.df()' contained in the package urca? You will find: library(urca) args(ur.df) function (y, type = c(none, drift, trend), lags = 1, selectlags = c(Fixed, AIC, BIC)) HTH, Bernhard -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von jbrukh Gesendet: Freitag, 15. Mai 2009 20:37 An: r-help@r-project.org Betreff: [R] Dickey-Fuller Tests with no constant and no trend R has a Dickey-Fuller Test implementation (adf.test) that tests for unit roots in an autoregressive process with a constant and linear trend. Is there a DF implementation that doesn't use the constant or trend? Thanks, Jake. -- View this message in context: http://www.nabble.com/Dickey-Fuller-Tests-with-no-constant-and- no-trend-tp23565210p23565210.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. * Confidentiality Note: The information contained in this ...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you save in R?
Patrick Burns pburns at pburns.seanet.com writes: I disagree with Dieter's last point. Whether you use 'attach' or 'load' should depend on whether you want the objects in the file to remain separate ('attach') or mixed into the global environment ('load'). Technically a good point, but I found it helpful for starters who want to avoid the inferno of what's attached now? not to use it at all. My suggestion is to use with() instead because it has a higher locality. I know, many of the examples use attach. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] consensus clusterings
Dear all, does anybody know a package or solution which incorporated one of the three algorithms to build consensus clusters, proposed by Nguyen Caruana: - iterative voting consensus (ivc) - iterative probabilistic voting consensus (ipvc) - iterative pairwise consensus (ipc) Thanks in advance. Best wishes Johannes __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simulation
Hi peter, Quite an insight you have there hehe. i am continuing on from the orignal problem of creating a simulation. Im now trying to find (nâ1)S2/Ï2, and fit it to a chi squared dist with 5 degrees of freedom. im having trouble with the coding for this. i think for the second part of that i need to use the fitdist function, but to get it to where i am able to do that, im not sure what to do. THis is what i have been trying to do so far, but it hasn't returned me anything good sum((x-mean(x))^2)/(length(x)-1) i am really confused, can someone please help? Cheers Date: Thu, 14 May 2009 12:05:30 +0100 From: b.rowling...@lancaster.ac.uk To: peterflomconsult...@mindspring.com CC: waclaw.marcin.kusnierc...@idi.ntnu.no; r-help@r-project.org Subject: Re: [R] Simulation As a beginner, I agree the for loop is much clearer to me. [Warning: Contains mostly philosophy] To me, the world and how I interact with it is procedural. When I want to break six eggs I do 'get six eggs, repeat break egg until all eggs broken'. I don't apply an instance of the break egg function over a range of eggs. My world is not functional (just like me, some might say...). Neither do I send a 'break yourself' message to each egg - my world is not object-oriented. That does not mean that these paradigms are not good ways of writing computer programs - they are brilliant ways of writing computer programs. But they build on procedural concepts, and we don't teach children to run before they can walk. So when someone says 'how do I do this a thousand times?' on R-help, I'll assume their knowledge level is that of a beginner, and try to map the solution to their world view. Computer scientists will write their beautiful manuscripts, but how many people who come to R because they want to do a t-test or fit a GLM will read them? That's the R-help audience now. Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ [[elided Hotmail spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] creating and then executing command strings
Greg: Thanks for this concise explanation! I will have a look at the fortunes you mention. Best - P On Fri, May 15, 2009 at 7:36 PM, Greg Snow greg.s...@imail.org wrote: The arrow - is used to assign a value to a variable, the equals sign = is used to specify the value for a function argument. Recent versions of R allow = to be used for - at the top level and certain circumstances which some people find more convenient, but can also lead to confusion (purists always keep them separate). The code: parse( text - paste( ... Will take the results of paste, save them in a variable named text, then pass a copy to the first argument of parse, which is file, not text, so parse will just get confused (looking for a file named what your code is). The code: parse( text = paste( ... Will take the results of paste and pass them to the parse function as the text argument. But having said that, you should refer to fortune(106) (type that after loading the fortunes package) and possibly fortune(181). There are probably better ways to do what you want, Romain's second example is one way. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Philipp Schmidt Sent: Friday, May 15, 2009 8:35 AM To: Romain Francois Cc: r-help@r-project.org Subject: Re: [R] creating and then executing command strings On Fri, May 15, 2009 at 3:38 PM, Romain Francois romain.franc...@dbmail.com wrote: Hi, You can either parse and eval the string you are making, as in: eval( parse( text = paste(avg_,colname, - 0;, sep='') ) ) Or you can do something like this: df[[ paste( avg_, colname, sep = ) ]] - 0 Thanks you so much! I used the first version and it worked. What puzzles me, is that I am not able to use - instead of = (my R book says the two can be exchanged) or break the command into different parts and execute them one after another. I get various error messages when I try: eval( parse( text - paste(avg_,colname, - 0;, sep='') ) ) or text = paste(avg_,colname, - 0;, sep='') parse(text) eval(parse(text)) Anyway, thanks a lot - you greatly improved the likelihood of me not working on the weekend! Best - P __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Sharing Nicely at www.bokaap.net __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you save in R?
I would second Dieter's point. 2009/5/18 Dieter Menne dieter.me...@menne-biomed.de: Patrick Burns pburns at pburns.seanet.com writes: I disagree with Dieter's last point. Whether you use 'attach' or 'load' should depend on whether you want the objects in the file to remain separate ('attach') or mixed into the global environment ('load'). Technically a good point, but I found it helpful for starters who want to avoid the inferno of what's attached now? not to use it at all. My suggestion is to use with() instead because it has a higher locality. I know, many of the examples use attach. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- HUANG Ronggui, Wincent PhD Candidate Dept of Public and Social Administration City University of Hong Kong Home page: http://asrr.r-forge.r-project.org/rghuang.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Chow test(1960)/Structural change test
  Thank your for your answer. I try to perform the Chow test with the formula as you suggest and it works. Nevertheless, I would like to ask additional questions please :   The first one is related to the early one that I have asked to my first message:  When I try to perform another structural change tests, in particular those ones which are based on the Fstats , I write the following code:  fsaveF - Fstats(reg1, from = 7, to = 22, data = data1) sctest(fsaveF, type = aveF)  which give me the following results :         aveF test  data: fsaveF ave.F = 55.15, p-value = 4.329e-15  But when I try the same test with sctest(reg1 , type = aveF, data = data), this does not work although reg1 is already known. When I replace reg1 by a ~ b + c + d the test works. When should I use the fitted model rather than the formula in a structural change test and vis versa ?  I precise that in my case reg1 correspond to a ~ b + c + d.  Second question:  The structural change tests based on the generalized fluctuation test framework that I have performed (Rec-CUSUM and Rec-MOSUM) give me an opposite results (No structural change) with regard to F test framework (there is a structural change). How to deal with this contradiction?  Third question:  Since I have autocorrelation in my regression, should I perform structural change test before or after correcting for autocorrelation?  Many thanks --- En date de : Dim 17.5.09, Achim Zeileis achim.zeil...@wu-wien.ac.at a écrit : De: Achim Zeileis achim.zeil...@wu-wien.ac.at Objet: Re: [R] Chow test(1960)/Structural change test Ã: Axel Leroix axel.ler...@yahoo.fr Cc: r-help@r-project.org Date: Dimanche 17 Mai 2009, 23h22 On Sun, 17 May 2009, Axel Leroix wrote: Hi,  A question on something which normally should be easy !  I perform a linear regression using lm function:  reg1 - lm (a b+c+d, data = database1)  Then I try to perform the Chow (1960) test (structural change test) on my regression. I know the breakpoint date. I try the following code like it is described in the âExamplesâ section of the âstrucchangeâ package :  sctest(reg1, data = database1, type = Chow,  point = 20, asymptotic = FALSE) You just need the formula, not the fitted model: sctest(a ~ b + c + d, data = database1, type = Chow, point = 20) If you want to perform it by hand, then the following should work: fit the nested model and then perform the model comparison calling anova() (or lrtest() from lmtest for the asymptotic version). reg2 - lm(a ~ factor(1:nrow(database1) = 20) / (b + c + d),    data = database1) anova(reg1, reg2) hth, Z  Unfortunately, this does not work and I have the following error message:  Error in UseMethod(sctest) : No applied method for sctest.  I guess that I should compute fs statistics first (Fisher statistics) but Iâm not sure about my guess. Moreover, in case my guess is true I do know how to do it although I have read the package documentation! On the basis of this documentation Iâm able to perform other structural change test (CUSUM, MOSUMâ¦) but Iâm particularly interested in the Chow (1960) test. So please is there someone who can help me in implementing it.  Many thanks in advance.      [[alternative HTML version deleted]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you save in R?
ronggui wrote: I would second Dieter's point. me to, among others because: 2009/5/18 Dieter Menne dieter.me...@menne-biomed.de: Patrick Burns pburns at pburns.seanet.com writes: I disagree with Dieter's last point. Whether you use 'attach' or 'load' should depend on whether you want the objects in the file to remain separate ('attach') or mixed into the global environment ('load'). Technically a good point, but I found it helpful for starters who want to avoid the inferno of what's attached now? not to use it at all. My suggestion is to use with() instead because it has a higher locality. i've seen code where an assumption is made to the effect that packages attached inside a function call will be automatically detached, e.g.: search() (function() attach(list()))() search() unfortunately, ?attach falls short of explaining this is an incorrect expectation, and it might be a good idea to do so. attach may also be confusing in how it interferes with lexical scoping: p = function() print(c) l = list(c=0) attach(l) p() detach() with(l, p()) i.e., attach may modify the behaviour of functions without changing what's passed to them as arguments. vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sample variance from simulation
Hi, g=list() for(i in 1:1000){z[[i]]=rnorm(15,0,1)} I've attempted a similar problem based on the above method. Now, if i want to find the sample variance, do i go about it like this? for (i in 1:1000)vars[[i]] = sum(z[[i]]) vars[[i]] the overall sigma squared will just be 1, because the distribution is standard normal. Is this correct? if so, then to find (nâ1)S^2/Ï^2, i will need s=999*sum(vars[[i]]))/1? Is this correct, or am i getting lost along the way? Thank you Date: Wed, 13 May 2009 16:45:22 +0100 From: b.rowling...@lancaster.ac.uk To: csa...@rmki.kfki.hu CC: r-help@r-project.org Subject: Re: [R] Simulation On Wed, May 13, 2009 at 4:26 PM, Gábor Csárdi csa...@rmki.kfki.hu wrote: On Wed, May 13, 2009 at 5:13 PM, Debbie Zhang debbie0...@hotmail.com wrote: Dear R users, Can anyone please tell me how to generate a large number of samples in R, given certain distribution and size. For example, if I want to generate 1000 samples of size n=100, with a N(0,1) distribution, how should I proceed? (Since I dont want to do rnorm(100,0,1) in R for 1000 times) Why not? It took 0.05 seconds on my 5 years old laptop. Second-guessing the user, I think she maybe doesn't want to type in 'rnorm(100,0,1)' 1000 times... Soln - for loop: z=list() for(i in 1:1000){z[[i]]=rnorm(100,0,1)} now inspect the individual bits: hist(z[[1]]) hist(z[[545]]) If that's the problem, then I suggest she reads an introduction to R... Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Looking to change your car this year? Find car news, reviews and more http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641_t=762955845_r=tig_OCT07_m=EXT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do you save in R?
Dieter Menne dieter.me...@menne-biomed.de wrote Technically a good point, but I found it helpful for starters who want to avoid the inferno of what's attached now? not to use it at all. My suggestion is to use with() instead because it has a higher locality. I know, many of the examples use attach. As a beginner, I find this whole issue very hard to grapple with. When to use attach with $ syntax data = or load I have seen many books and manuals say to just avoid using attach at all, but several of these then go on to use attach quite often. But I run into conceptual problems with all these methods, particularly when I am trying to operate on subsets of a data frame, and then sometimes need to use the [ and ] syntax, sometimes subset = within a function, and sometimes create a separate data frame to then use (but here attach can cause tons of problems). Do other beginners share my confusion? Can some expert point a path through this confusion? thanks Peter PS As a beginner, I appreciate the time that several posters are now taking to elucidate things that may seem obvious. Peter L. Flom, PhD Statistical Consultant www DOT peterflomconsulting DOT com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
On Mon, 18 May 2009 17:33:51 +1030 Debbie Zhang debbie0...@hotmail.com wrote: DZ Based on a set of binomial sample data, how would you utilize the DZ nlm function in R to estimate the true proportion of the DZ population? Dear Debbie, This is a list that is mainly intended helping people if they have a problem writing code. If you expect useful answers you should: - follow the posting guide: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - especially try NOT to give the impression that you are doing homeworks and expect others to do the work for you (thus show at least some effort: what you have searched/found and what you programmed to solve the problem see homework before posting in the posting guide) - Use the subject field of the e-mail to give a pointer of the problem: it increases the probability that someone who has knowledge actually reads your mail Thanks Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Parsing configuration files
Dear list, Is there any functionality in R that would allow me to parse config files? I have trie ??config and apropos('config') without succes, and also search the R package site. Mvh. Marie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Runtime Error! Keep on happening while using amap, anacor and ca pckg
Hi there dear R users, Does anyone have any idea what the following error means and how to sort it out? Runtime Error! Program: C\Program Files\R\R-2.9.0\bin\Rgui.exe This application has requested the Runtime to terminate it in an unusual way. Please contact the applicationâs support team for more information. Here is the story: Running the same code, sometimes the error happens and other times it doesnât. It all started while still using the old R version; therefore I looked for the updates and its keep on happening with the new version too. The packages that I am using while experiencing this continues error are the following: amap anacor ca Please help! Ana [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] MAC OSX vs Win XP: Different stats test results!
Hi all, I wondered whether anyone has some advice on a stats-related 'sanity check', as I ran a nonparametric multivariate test (mulrank function as decribed by R. Wilcox, 2005) on both systems, but got different results (please see below for the system-specific outputs)! The functions I used are attached as well. Any advice would be much appreciated! Thanks in advance for getting back to me! Best wishes, Mareen Mac: data03-selby2(data02, c(1,2), 3) mulrank(3,6,data03$x) $test.stat [1] 0.9331133 $nu1 [1] 11.46300 $p.value [,1] [1,] 0.509296 $N [1] 233 $q.hat [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.4940071 0.5256726 0.5176384 0.5476290 0.4690935 0.5265100 [2,] 0.5170627 0.4791950 0.5026431 0.4867843 0.4778865 0.5033497 [3,] 0.4680729 0.4944258 0.4889563 0.4505391 0.5311420 0.4726002 Win: mulrank(3,6, data03$x) $test.stat [1] 1.114665 $nu1 [1] 8.155991 $p.value [,1] [1,] 0.3491221 $N [1] 233 $q.hat [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.4940071 0.5406417 0.5236837 0.5656338 0.4771799 0.5324505 [2,] 0.5162776 0.4801895 0.5022244 0.4960745 0.4854234 0.4820737 [3,] 0.5013608 0.4920967 0.4810269 0.4482885 0.5326861 0.4871506 http://www.nabble.com/file/p23595008/Rallfun-v92.txt Rallfun-v92.txt -- View this message in context: http://www.nabble.com/MAC-OSX-vs-Win-XP%3A-Different-stats-test-results%21-tp23595008p23595008.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Concatenating two vectors into one
Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Simple plotting errors
Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEANSUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Connection to SQL Server
Dear Users I am new to R. I'm trying to make a connection to Microsoft SQL Server via R. How can I find the correct syntax to make the connection? The Help pdf file has an example for mySql but there's isnt much on SQL Server. Please help. Thanks ! Me. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Concatenating two vectors into one
z-c(x,y) cheers, Simon. - Original Message - From: Henning Wildhagen hwildha...@gmx.de To: r-help@r-project.org Sent: Monday, May 18, 2009 12:09 PM Subject: [R] Concatenating two vectors into one Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Concatenating two vectors into one
x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) ?paste paste(x,y, sep=) andydol...@gmail.com 2009/5/18 Henning Wildhagen hwildha...@gmx.de Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Save Cluster results to data frame
If I cluster my data into 3 sets, using pam for instance, is there a way to save the resultant cluster results, to the originating data frame. and related to that how do i say change the cluster names to something a bit more meaningful that 1..2...3 So it goes like this. Data --- Cluster into 3 groups given them meaningful names ---output back to data frame Thanks for the help Chris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Concatenating two vectors into one
Something like this should work: z- paste(x,y, sep='') HTH, Tony On 18 May, 12:09, Henning Wildhagen hwildha...@gmx.de wrote: Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning -- [[alternative HTML version deleted]] __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Split data frame based on Class
Each row of my data frame is assigned to a class (eg country). Can you suggest how I break apart the data frame so that I create new data frames for each class eg If Class = US put in new dataframe dataUS Thanks in advance for your help Chris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Concatenating two vectors into one
On 18-May-09 11:09:45, Henning Wildhagen wrote: Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning And a very simple solution! Use paste(): x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) paste(x,y) # [1] A 1 B 2 C 3 D 4 E 5 F 6 paste(x,y,sep=) # [1] A1 B2 C3 D4 E5 F6 Ted. PS: 'x*y' will attempt to perform a numerical multiplication. This cannot work for character vectors. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 18-May-09 Time: 12:23:56 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MAC OSX vs Win XP: Different stats test results!
Mareen wrote: Hi all, I wondered whether anyone has some advice on a stats-related 'sanity check', as I ran a nonparametric multivariate test (mulrank function as decribed by R. Wilcox, 2005) on both systems, but got different results (please see below for the system-specific outputs)! The functions I used are attached as well. Any advice would be much appreciated! Thanks in advance for getting back to me! Perhaps you should show us a summary(data03$x) on both systems. It could be that you are not working with the same data... -p Best wishes, Mareen Mac: data03-selby2(data02, c(1,2), 3) mulrank(3,6,data03$x) $test.stat [1] 0.9331133 $nu1 [1] 11.46300 $p.value [,1] [1,] 0.509296 $N [1] 233 $q.hat [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.4940071 0.5256726 0.5176384 0.5476290 0.4690935 0.5265100 [2,] 0.5170627 0.4791950 0.5026431 0.4867843 0.4778865 0.5033497 [3,] 0.4680729 0.4944258 0.4889563 0.4505391 0.5311420 0.4726002 Win: mulrank(3,6, data03$x) $test.stat [1] 1.114665 $nu1 [1] 8.155991 $p.value [,1] [1,] 0.3491221 $N [1] 233 $q.hat [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.4940071 0.5406417 0.5236837 0.5656338 0.4771799 0.5324505 [2,] 0.5162776 0.4801895 0.5022244 0.4960745 0.4854234 0.4820737 [3,] 0.5013608 0.4920967 0.4810269 0.4482885 0.5326861 0.4871506 http://www.nabble.com/file/p23595008/Rallfun-v92.txt Rallfun-v92.txt -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Concatenating two vectors into one
z - paste(x, y, sep = '') z [1] A1 B2 C3 D4 E5 F6 On Mon, May 18, 2009 at 7:09 PM, Henning Wildhagen hwildha...@gmx.de wrote: Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Overdispersion using repeated measures lmer
Dear All I am trying to do a repeated measures analysis using lmer and have a number of issues. I have non-orthogonal, unbalanced data. Count data was obtained over 10 months for three treatments, which were arranged into 6 blocks. Treatment is not nested in Block but crossed, as I originally designed an orthogonal, balanced experiment but subsequently lost a treatment from 2 blocks. My fixed effects are treatment and Month, and my random effects are Block which was repeated sampled. My model is: Model-lmer(Count~Treatment*Month+(Month|Block),data=dataset,family=poisson(link=sqrt)) Is this the only way in which I can specify my random effects? I.e. can I specify them as: (1|Block)+(1|Month)? When I run this model, I do not get any residuals in the error term or estimated scale parameters and so do not know how to check if I have overdispersion. Below is the output I obtained. Generalized linear mixed model fit by the Laplace approximation Formula: Count ~ Treatment * Month + (Month | Block) Data: dataset AIC BIC logLik deviance 310.9 338.5 -146.4292.9 Random effects: Groups NameVariance Std.Dev. Corr Block (Intercept) 0.06882396 0.262343 Month 0.00011693 0.010813 1.000 Number of obs: 160, groups: Block, 6 Fixed effects: Estimate Std. Error z value Pr(|z|) (Intercept) 1.624030 0.175827 9.237 2e-16 *** Treatment2.Radiata0.150957 0.207435 0.728 0.466777 Treatment3.Aldabra -0.005458 0.207435 -0.026 0.979009 Month-0.079955 0.022903 -3.491 0.000481 *** Treatment2.Radiata:Month 0.048868 0.033340 1.466 0.142717 Treatment3.Aldabra:Month 0.077697 0.033340 2.330 0.019781 * --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Correlation of Fixed Effects: (Intr) Trt2.R Trt3.A Month T2.R:M Trtmnt2.Rdt -0.533 Trtmnt3.Ald -0.533 0.450 Month -0.572 0.585 0.585 Trtmnt2.R:M 0.474 -0.882 -0.402 -0.661 Trtmnt3.A:M 0.474 -0.402 -0.882 -0.661 0.454 Any advice on how to account for overdispersion would be much appreciated. Many thanks in advance Christine -- Christine Griffiths School of Biological Sciences University of Bristol Woodland Road Bristol BS8 1UG Tel: 0117 9287593 Fax 0117 925 7374 christine.griffi...@bristol.ac.uk http://www.bio.bris.ac.uk/research/mammal/tortoises.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Runtime Error! Keep on happening while using amap, anacor and ca pckg
Ana Kolar wrote: Hi there dear R users, Does anyone have any idea what the following error means and how to sort it out? Runtime Error! Program: C\Program Files\R\R-2.9.0\bin\Rgui.exe This application has requested the Runtime to terminate it in an unusual way. Please contact the application’s support team for more information. Here is the story: Running the same code, sometimes the error happens and other times it doesn’t. It all started while still using the old R version; therefore I looked for the updates and its keep on happening with the new version too. The packages that I am using while experiencing this continues error are the following: amap anacor ca Please help! Ana [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Where is code that reproduces the error? Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
Steve Murray wrote: Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEANSUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Well, beside the infelicity of having 12 data.frames to represent one year, your need to make a vector of those values as in: plot(c(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* ), type=l) Uwe Ligges Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Concatenating two vectors into one
Henning Wildhagen wrote: Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Homework? Anyway, see ?paste. Uwe Ligges Thanks for your help, Henning __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Parsing configuration files
Marie Sivertsen wrote: Dear list, Is there any functionality in R that would allow me to parse config files? Which kind of config files? R has read.dcf, for example. Uwe Ligges I have trie ??config and apropos('config') without succes, and also search the R package site. Mvh. Marie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Concatenating two vectors into one
It seems that c(x,y) is not correct: z-c(x,y) z [1] A B C D E F 1 2 3 4 5 6 On Mon, May 18, 2009 at 7:17 PM, Simon Pickett simon.pick...@bto.org wrote: z-c(x,y) cheers, Simon. - Original Message - From: Henning Wildhagen hwildha...@gmx.de To: r-help@r-project.org Sent: Monday, May 18, 2009 12:09 PM Subject: [R] Concatenating two vectors into one Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
I'd suggest you first combine the 12 data.frames into one, using melt() from the reshape package. makeDummy - function(.){ # since you don't provide a reproducible example data.frame(x=letters[1:10], y=rnorm(10)) } listOf12DataFrames - lapply(1:12, makeDummy) library(reshape) dm - melt(listOf12DataFrames, id=x) str(dm) # each original data.frame is identified by the integer L1 with(subset(dm, x==a), plot(L1, value, t=l)) baptiste On 18 May 2009, at 13:17, Steve Murray wrote: Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEANSUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Simulation from a multivariate normal distribution
I must to create an array with dimensions 120x8x500. Better I have to make 500 simulations of 8 series of return from a multivariate normal distribution. there's the command mvrnorm but how I can do this repeating the simulation 500 times? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
One way is to create a list of the dataframes and then use 'sapply' to extract the values: df.list - list(FeketeJAN, ..., FeketeDEC) plot(sapply(df.list, function(a) a[AMAZON, SUM_])) On Mon, May 18, 2009 at 7:17 AM, Steve Murray smurray...@hotmail.comwrote: Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEANSUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Split data frame based on Class
?split new.df - split(old.df, old.df$Class) will create a list of dataframes split by Class On Mon, May 18, 2009 at 7:23 AM, Chris Arthur chris.art...@bristol.ac.ukwrote: Each row of my data frame is assigned to a class (eg country). Can you suggest how I break apart the data frame so that I create new data frames for each class eg If Class = US put in new dataframe dataUS Thanks in advance for your help Chris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Parsing configuration files
PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. There are regular expressions that can be used. It is very dependent upon the format of a configuration file; an example would help to show the way. On Mon, May 18, 2009 at 6:10 AM, Marie Sivertsen mariesiv...@gmail.comwrote: Dear list, Is there any functionality in R that would allow me to parse config files? I have trie ??config and apropos('config') without succes, and also search the R package site. Mvh. Marie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
you mean you want to plot SUM against month? (assuming these12 data frames are 12 months). you could first bind them all together using data.frame(), see ?data.frame which would make it much easier. you need to create a variable for months then plot it against your variable. If you dont want to make it easier with a data frame then you would have a long piece of code as follows (assuming I have understood you correctly) plot(seq(1:12),c(FeketeJAN$(SUM_)[row.names(FeketeJAN)==AMAZON],FeketeFEB$(SUM_)[row.names(FeketeFEB)==AMAZON]etc)) Cheers, Si. - Original Message - From: Steve Murray smurray...@hotmail.com To: r-help@r-project.org Sent: Monday, May 18, 2009 12:17 PM Subject: [R] Simple plotting errors Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEANSUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
On Mon, 18 May 2009 11:17:50 + Steve Murray smurray...@hotmail.com wrote: SM plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to SM December* type=l) SM What is it that I'm doing wrong?! try plot( c(FeketeJAN[1,2], FeketeFEB[1,2], ...)),type=l) however it is better to create one big data frame like: Location Mean Sum Month Amazon 144 ... JAN all you need is cbind. hth Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simulation from a multivariate normal distribution
Check out the help page for replicate(). Andy From: barbara.r...@uniroma1.it I must to create an array with dimensions 120x8x500. Better I have to make 500 simulations of 8 series of return from a multivariate normal distribution. there's the command mvrnorm but how I can do this repeating the simulation 500 times? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Notice: This e-mail message, together with any attachme...{{dropped:12}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simulation from a multivariate normal distribution
barbara.r...@uniroma1.it wrote: I must to create an array with dimensions 120x8x500. Better I have to make 500 simulations of 8 series of return from a multivariate normal distribution. there's the command mvrnorm but how I can do this repeating the simulation 500 times? ?replicate Uwe Ligges [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Connection to Microsoft SQL Server
Dear Users I am new to R. I'm trying to make a connection to Microsoft SQL Server via R. How can I find the correct syntax to make the connection? The Help pdf file has an example for mySql but there's isnt much on SQL Server. Please help. I am trying the following code library(RODBC) con-odbcConnect(dbname,hostname) How do I specify the driver,userid,password etc? Many thanks for your help! Me. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Split data frame based on Class
Try split()! ?split e.g a var1 var2 var3 1 a14 2 a25 3 a36 4 b47 5 b58 6 a69 7 b7 NA 8 c82 9 c95 10b34 11a24 12a14 13c23 14c54 split(a,a[var1]) $a var1 var2 var3 1 a14 2 a25 3 a36 6 a69 11a24 12a14 $b var1 var2 var3 4 b47 5 b58 7 b7 NA 10b34 $c var1 var2 var3 8 c82 9 c95 13c23 14c54 Cheers! Kushantha -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Chris Arthur Sent: Monday, May 18, 2009 4:54 PM To: r-help@r-project.org Subject: [R] Split data frame based on Class Each row of my data frame is assigned to a class (eg country). Can you suggest how I break apart the data frame so that I create new data frames for each class eg If Class = US put in new dataframe dataUS Thanks in advance for your help Chris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Chow test(1960)/Structural change test
On Mon, 18 May 2009, Axel Leroix wrote: Thank your for your answer. I try to perform the Chow test with the formula as you suggest and it works. Nevertheless, I would like to ask additional questions please : The first one is related to the early one that I have asked to my first message: When I try to perform another structural change tests, in particular those ones which are based on the Fstats , I write the following code: fsaveF - Fstats(reg1, from = 7, to = 22, data = data1) sctest(fsaveF, type = aveF) which give me the following results : aveF test data: fsaveF ave.F = 55.15, p-value = 4.329e-15 But when I try the same test with sctest(reg1 , type = aveF, data = data), this does not work although reg1 is already known. When I replace reg1 by a ~ b + c + d the test works. When should I use the fitted model rather than the formula in a structural change test and vis versa ? I precise that in my case reg1 correspond to a ~ b + c + d. RTFM. All functions always ask for a formula (= a description of the model under the nullhypothesis). Fstats() has been enhanced for convenience so that you can also supply a fitted linear model which is not available for direct application of the sctest.formula() method. (Personally, I never use sctest.formula() but always explicitely use Fstats(), efp(), or gefp().) Second question: The structural change tests based on the generalized fluctuation test framework that I have performed (Rec-CUSUM and Rec-MOSUM) give me an opposite results (No structural change) with regard to F test framework (there is a structural change). How to deal with this contradiction? The tests based on recursive residuals have good power only if a change occurs early in the sample. They have very poor power for late changes. As there are infinitely many possible patterns of deviation from parameter stability, there is no test that uniformly dominates all others across all conceivable patterns. Which test is used in practice hence depends on the patterns you want have good power against. See the references in the strucchange package for more details. Third question: Since I have autocorrelation in my regression, should I perform structural change test before or after correcting for autocorrelation? Technically you can do both and there are examples for both in the strucchange docs. If you have a good model that can capture all autocorrelation, I would recommend to test for structural change in that model. Otherwise if there is only little autocorrelation that you don't want/need to model explicitely, you can adjust the tests, e.g., by using HAC covariances. These can be plugged into both Fstats() and gefp() (but not efp()). hth, Z __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Connection to Microsoft SQL Server
Meenu Sahi wrote: Dear Users I am new to R. I'm trying to make a connection to Microsoft SQL Server via R. How can I find the correct syntax to make the connection? The Help pdf file has an example for mySql but there's isnt much on SQL Server. Please help. I am trying the following code library(RODBC) con-odbcConnect(dbname,hostname) How do I specify the driver,userid,password etc? Well, you specify the DSN and other details in your Windows settings (somewhere within the control panel) - given your OS is Windows? If you make a call to connect to that DSN, you will be asked for username and password given you haven't specified it with the DSN in your Windows settings. Uwe Ligges Many thanks for your help! Me. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Save Cluster results to data frame
Hi Chris, this isn't particularly a clustering question, is it? Why don't you just take your clustering vector (pam.output.object$clustering) and assign it to a$clustering (given that a is the name of your data frame)? And why don't you just define a new character/string vector and assign the cluster names that you want to it using if or case? Regards, Christian On Mon, 18 May 2009, Chris Arthur wrote: If I cluster my data into 3 sets, using pam for instance, is there a way to save the resultant cluster results, to the originating data frame. and related to that how do i say change the cluster names to something a bit more meaningful that 1..2...3 So it goes like this. Data --- Cluster into 3 groups given them meaningful names ---output back to data frame Thanks for the help Chris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
you mean you want to plot SUM against month? (assuming these12 data frames are 12 months). you could first bind them all together using data.frame(), see ?data.frame which would make it much easier. you need to create a variable for months then plot it against your variable. If you dont want to make it easier with a data frame then you would have a long piece of code as follows (assuming I have understood you correctly) plot(seq(1:12),c(FeketeJAN$(SUM_)[row.names(FeketeJAN)==AMAZON],FeketeFEB$(SUM_)[row.names(FeketeFEB)==AMAZON]etc)) Cheers, Si. - Original Message - From: Steve Murray smurray...@hotmail.com To: r-help@r-project.org Sent: Monday, May 18, 2009 12:17 PM Subject: [R] Simple plotting errors Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEANSUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Concatenating two vectors into one
Sorry, I saw the word concatenate and dived in. Andrew Dolmans solution works fine. Simon. - Original Message - From: Linlin Yan yanlinli...@gmail.com To: Simon Pickett simon.pick...@bto.org Cc: Henning Wildhagen hwildha...@gmx.de; r-help@r-project.org Sent: Monday, May 18, 2009 12:30 PM Subject: Re: [R] Concatenating two vectors into one It seems that c(x,y) is not correct: z-c(x,y) z [1] A B C D E F 1 2 3 4 5 6 On Mon, May 18, 2009 at 7:17 PM, Simon Pickett simon.pick...@bto.org wrote: z-c(x,y) cheers, Simon. - Original Message - From: Henning Wildhagen hwildha...@gmx.de To: r-help@r-project.org Sent: Monday, May 18, 2009 12:09 PM Subject: [R] Concatenating two vectors into one Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
you mean you want to plot SUM against month? (assuming these12 data frames are 12 months). you could first bind them all together using data.frame(), see ?data.frame which would make it much easier. you need to create a variable for months then plot it against your variable. If you dont want to make it easier with a data frame then you would have a long piece of code as follows (assuming I have understood you correctly) plot(seq(1:12),c(FeketeJAN$(SUM_)[row.names(FeketeJAN)==AMAZON],FeketeFEB$(SUM_)[row.names(FeketeFEB)==AMAZON]etc)) Cheers, Si. - Original Message - From: Steve Murray smurray...@hotmail.com To: r-help@r-project.org Sent: Monday, May 18, 2009 12:17 PM Subject: [R] Simple plotting errors Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEANSUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Parsing configuration files
Uwe Ligges wrote: Marie Sivertsen wrote: Dear list, Is there any functionality in R that would allow me to parse config files? Which kind of config files? R has read.dcf, for example. indeed, there are quite a number of more or less unambiguously specified configuration file formats. for the lack of an existing solution (or, more likely, due to my ignorance) i've crufted together a trivial script that parses simple ini-like config files, with square-bracketed section headers, like this: [foo] bar = BAR [bar] foo = ... you just source the script, specify the config file, and get a nested list of config parameters, e.g. source('http://miscell.googlecode.com/svn/rconfig/rconfig.r') config = rconfig('somefile.cfg') config$foo$bar # BAR the functionality is rudimentary and not fool-proof, no string-to-number parsing, no comment skipping, etc. i'm not really suggesting it as a solution to your (underspecified) problem, feel free to modify/extend it to match your needs. vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simulation from a multivariate normal distribution
Liaw, Andy wrote: Check out the help page for replicate(). Andy Or the 'n' argument to mvrnorm (or mvtnorm::rmvnorm for that matter)... From: barbara.r...@uniroma1.it I must to create an array with dimensions 120x8x500. Better I have to make 500 simulations of 8 series of return from a multivariate normal distribution. there's the command mvrnorm but how I can do this repeating the simulation 500 times? [[alternative HTML version deleted]] -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Runtime Error! Keep on happening while using amap, anacor and ca pckg
After Ana Kolar sent me some code in a private mesage: I reduced that to a minimal example that crashed R - due to a bug in amap - hence CCing the amap maintainer to whom the original report should have gone anyway: The function matlogic() in package amap, or more particular the call to: .C(matind, as.integer(nblev), as.integer(x), res = res, as.integer(n), as.integer(m), as.integer(k), PACKAGE = amap) crashes R reproducibly with the following piece of code: library(amap) dat - data.frame(a=rep(0,3), b=rep(1,3)) replicate(100, matlogic(dat)) with Package: amap Version: 0.8-2 Date: 2007-10-03 under R version 2.9.0 Patched (2009-04-27 r48414) OS: Windows XP Pro 32-bit, SP3 Best wishes, Uwe Ligges Uwe Ligges wrote: Ana Kolar wrote: Hi there dear R users, Does anyone have any idea what the following error means and how to sort it out? Runtime Error! Program: C\Program Files\R\R-2.9.0\bin\Rgui.exe This application has requested the Runtime to terminate it in an unusual way. Please contact the application’s support team for more information. Here is the story: Running the same code, sometimes the error happens and other times it doesn’t. It all started while still using the old R version; therefore I looked for the updates and its keep on happening with the new version too. The packages that I am using while experiencing this continues error are the following: amap anacor ca Please help! Ana [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Where is code that reproduces the error? Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
Thanks for all the useful information; use of 'c(...)' did the trick, although in future I'll try to hold the data in a more user-friendly setup. I've now got a plot, but have two issues that I can't seem to resolve: 1, The ylab is overlapping the y-axis tick mark values. I've tried using oma and mar to adjust the outer and plot margins respectively, but this doesn't seem to 'detach' the overlapping text. 2. The x-axis currently has tick mark values of 2 to 12. How do change this to single-letter month labels? So far I've tried xlim=c(J,F,M,A,M...) and names.arg=c(J,F,M...), but these result in errors. Any suggestions would be much appreciated. Thanks again, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MAC OSX vs Win XP: Different stats test results!
If mulrank does any sort of random number generation or non-exhaustive randomization, you should set the seed of the random number generator first: set.seed(1) mulrank(3,6,data03$x) On Mon, May 18, 2009 at 7:37 AM, Mareen mareenwe...@yahoo.com wrote: Hi all, I wondered whether anyone has some advice on a stats-related 'sanity check', as I ran a nonparametric multivariate test (mulrank function as decribed by R. Wilcox, 2005) on both systems, but got different results (please see below for the system-specific outputs)! The functions I used are attached as well. Any advice would be much appreciated! Thanks in advance for getting back to me! Best wishes, Mareen Mac: data03-selby2(data02, c(1,2), 3) mulrank(3,6,data03$x) $test.stat [1] 0.9331133 $nu1 [1] 11.46300 $p.value [,1] [1,] 0.509296 $N [1] 233 $q.hat [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.4940071 0.5256726 0.5176384 0.5476290 0.4690935 0.5265100 [2,] 0.5170627 0.4791950 0.5026431 0.4867843 0.4778865 0.5033497 [3,] 0.4680729 0.4944258 0.4889563 0.4505391 0.5311420 0.4726002 Win: mulrank(3,6, data03$x) $test.stat [1] 1.114665 $nu1 [1] 8.155991 $p.value [,1] [1,] 0.3491221 $N [1] 233 $q.hat [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.4940071 0.5406417 0.5236837 0.5656338 0.4771799 0.5324505 [2,] 0.5162776 0.4801895 0.5022244 0.4960745 0.4854234 0.4820737 [3,] 0.5013608 0.4920967 0.4810269 0.4482885 0.5326861 0.4871506 http://www.nabble.com/file/p23595008/Rallfun-v92.txt Rallfun-v92.txt -- View this message in context: http://www.nabble.com/MAC-OSX-vs-Win-XP%3A-Different-stats-test-results%21-tp23595008p23595008.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to run Rcmdr in Mac Os X Tiger?
Dear Jenny, Please see the instructions for Mac OS X Tiger in the Rcmdr installation notes at http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/installation-notes.html. I hope this helps, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jenny Tan (Dr J) Sent: May-18-09 12:09 AM To: r-help@r-project.org Subject: [R] How to run Rcmdr in Mac Os X Tiger? This question might been asked previously (I googled), but I can't find a workable solution in the archives. My question is: how to run Rcdmr in Mac Os X? The error message when I launched Rcmdr fresh from a R session is: Version of R: R 2.8.1 GUI 1.27 Tiger build 32-bit (5301) library(Rcmdr) Loading required package: tcltk Loading Tcl/Tk interface ... done Loading required package: car Error in structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class = tclObj) : [tcl] invalid command name font. In addition: Warning message: In fun(...) : couldn't connect to display :0 Error : .onAttach failed in 'attachNamespace' Error: package/namespace load failed for 'Rcmdr' jenny [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sample variance from simulation
why not simply vars=list() for (i in 1:1000) vars[[i]] = var(z[[i]]) On Mon, May 18, 2009 at 6:51 AM, Kon Knafelman konk2...@hotmail.com wrote: Hi, g=list() for(i in 1:1000){z[[i]]=rnorm(15,0,1)} I've attempted a similar problem based on the above method. Now, if i want to find the sample variance, do i go about it like this? for (i in 1:1000)vars[[i]] = sum(z[[i]]) vars[[i]] the overall sigma squared will just be 1, because the distribution is standard normal. Is this correct? if so, then to find (n-1)S^2/σ^2, i will need s=999*sum(vars[[i]]))/1? Is this correct, or am i getting lost along the way? Thank you Date: Wed, 13 May 2009 16:45:22 +0100 From: b.rowling...@lancaster.ac.uk To: csa...@rmki.kfki.hu CC: r-help@r-project.org Subject: Re: [R] Simulation On Wed, May 13, 2009 at 4:26 PM, Gábor Csárdi csa...@rmki.kfki.hu wrote: On Wed, May 13, 2009 at 5:13 PM, Debbie Zhang debbie0...@hotmail.com wrote: Dear R users, Can anyone please tell me how to generate a large number of samples in R, given certain distribution and size. For example, if I want to generate 1000 samples of size n=100, with a N(0,1) distribution, how should I proceed? (Since I dont want to do rnorm(100,0,1) in R for 1000 times) Why not? It took 0.05 seconds on my 5 years old laptop. Second-guessing the user, I think she maybe doesn't want to type in 'rnorm(100,0,1)' 1000 times... Soln - for loop: z=list() for(i in 1:1000){z[[i]]=rnorm(100,0,1)} now inspect the individual bits: hist(z[[1]]) hist(z[[545]]) If that's the problem, then I suggest she reads an introduction to R... Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Looking to change your car this year? Find car news, reviews and more http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641_t=762955845_r=tig_OCT07_m=EXT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Function Surv and interpretation
Dr Pearce, 1. The heart of your question is why Surv(time, death) works, when the standard S action would be to match death to the time2 argument. The answer is that Surv is not conventional -- if only 2 unnamed arguments are present, then it assumes that they match to the time and event arguments. At least in my work, 99% of the uses of survival are either (time1, time2, status) or (time, status); so the function was made convenient for the most common case. 2. Q2: why did Surv(time, event=death) give an error message? This was a programming error which has been corrected in the most recent version of the code. 3. I'm not familiar with the details of the cuminc function (I assume from the cmprsk package). However, with the newest version of survival you can use the alternative: fit - survfit(Surv(ftime, fstatus0) ~ group, event=fstatus, data=mydata) The result is a standard survival curve object, so all of the usual plotting methods for survival curves work, e.g., plot(fit[1:3], fun='event', col=c(2,7,5), lty=c(1,2,2)) In the survfit formulation 'status' is still 0/1 for censored/uncensored, and 'event' gives the event type for the deaths. The event code for the censors is ignored and can be any value (but don't use NA - that will cause the observation to be dropped). Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Concatenating two vectors into one
If you want to concatenate the *vectors*, you need 'c', which will also coerce the elements to a common type. If you want to concatenate the corresponding *elements* of the vectors, you need 'paste', which will coerce them to character strings. -s On 5/18/09, Henning Wildhagen hwildha...@gmx.de wrote: Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
Here is a slight elaboration on Jim's solution: # create a vector of the names - month.abb is built into R # This is like: df.names - c(FetekeJAN, FetekeFEB, ...) # but avoids having to write out every name. df.names - paste(Feteke, toupper(month.abb), sep = ) # create a list of the data frames so that df.list[[1]] is FetekeJAN, etc. df.list - lapply(df.names, get) # extract element 1, 2 of each, creating vector amazon.sum amazon.sum - sapply(df.list, [, 1, 2) # plot it plot(amazon.sum, xlab = Month, ylab = Amazon Sum) On Mon, May 18, 2009 at 7:17 AM, Steve Murray smurray...@hotmail.com wrote: Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEAN SUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO 71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB 1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
Dear Debbie, can you **PLEASE** use a 'Subject' in your postings to R-help, and also (see below) DZ == Debbie Zhang debbie0...@hotmail.com on Mon, 18 May 2009 17:33:51 +1030 writes: DZ Dear R users, DZ Based on a set of binomial sample data, how would you DZ utilize the nlm function in R to estimate the true DZ proportion of the population? DZ Thanks. DZ Debbie DZ _ DZ [[elided Hotmail spam]] DZ [[alternative HTML version deleted]] DZ __ DZ R-help@r-project.org mailing list DZ https://stat.ethz.ch/mailman/listinfo/r-help DZ PLEASE do read the posting guide Yes, PLEASE do read *and* then follow it. DZ http://www.R-project.org/posting-guide.html and provide DZ commented, minimal, self-contained, reproducible code. Also, given your postings, I'd start contemplating to add something there saying that we do not allow more than two beginner's questions per day for a specific beginner ... In spite of the above: Congratulations on chosing R, wishing you happy houRs ! Regards, Martin Maechler, ETH Zurich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
read ?par 1.use ylab= to suppress y labels, then mxtext to manually draw em yourself OR use mgp=... within par() 2.use xlab not xlim to change the x axis labels HTH, Si. - Original Message - From: Steve Murray smurray...@hotmail.com To: simon.pick...@bto.org; r-help@r-project.org; ba...@exeter.ac.uk; jholt...@gmail.com Sent: Monday, May 18, 2009 1:39 PM Subject: RE: [R] Simple plotting errors Thanks for all the useful information; use of 'c(...)' did the trick, although in future I'll try to hold the data in a more user-friendly setup. I've now got a plot, but have two issues that I can't seem to resolve: 1, The ylab is overlapping the y-axis tick mark values. I've tried using oma and mar to adjust the outer and plot margins respectively, but this doesn't seem to 'detach' the overlapping text. 2. The x-axis currently has tick mark values of 2 to 12. How do change this to single-letter month labels? So far I've tried xlim=c(J,F,M,A,M...) and names.arg=c(J,F,M...), but these result in errors. Any suggestions would be much appreciated. Thanks again, Steve _ View your Twitter and Flickr updates from one place – Learn more! http://clk.atdmt.com/UKM/go/137984870/direct/01/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sample variance from simulation
Mike Lawrence wrote: why not simply vars=list() for (i in 1:1000) vars[[i]] = var(z[[i]]) ... or, much simpler, vars = sapply(z, var) vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] intermediate iterations of stepwise regression
Hi all, I am performing a stepwise regression by running the step function on an lm object. Now I want to save the intermediate iterations. I know the argument trace=T will print it on the console, but I rather want to assign it to some R object or may be output it in a CSV or text file. Any help will be appreciated. Regards Utkarsh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] intermediate iterations of stepwise regression
Try this: out - capture.output(example(step)) On Mon, May 18, 2009 at 9:11 AM, utkarshsinghal utkarsh.sing...@global-analytics.com wrote: Hi all, I am performing a stepwise regression by running the step function on an lm object. Now I want to save the intermediate iterations. I know the argument trace=T will print it on the console, but I rather want to assign it to some R object or may be output it in a CSV or text file. Any help will be appreciated. Regards Utkarsh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
Try this (and make sure to follow the last line to every message on r-help which asks for reproducible code in questions): plot(amazon.sum, xlab = Month, ylab = Amazon Sum, xaxt = n) axis(1, at = 1:12, substr(month.abb, 1, 1)) On Mon, May 18, 2009 at 8:39 AM, Steve Murray smurray...@hotmail.com wrote: Thanks for all the useful information; use of 'c(...)' did the trick, although in future I'll try to hold the data in a more user-friendly setup. I've now got a plot, but have two issues that I can't seem to resolve: 1, The ylab is overlapping the y-axis tick mark values. I've tried using oma and mar to adjust the outer and plot margins respectively, but this doesn't seem to 'detach' the overlapping text. 2. The x-axis currently has tick mark values of 2 to 12. How do change this to single-letter month labels? So far I've tried xlim=c(J,F,M,A,M...) and names.arg=c(J,F,M...), but these result in errors. Any suggestions would be much appreciated. Thanks again, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MEXVAL
I do not understand the term mexval statistics. I think you want to look for anova.glm, fitting several models leaving each term out one at a time in succession and then using anova.glm to compare your general model with each submodel in succession. If that does NOT give you what you want, please ask again, AFTER first reading the posting guide http://www.R-project.org/posting-guide.html;; And please provide commented, minimal, self-contained, reproducible code with your post, explaining in particular why anova.glm does not seem to solve your problem. There is a problem with SEE in non-normal situations, if by SEE you mean standard error of the estimate. Least squares with normal errors is also maximum likelihood. The consensus among professional statisticians has long been that when the the errors are not additive or normal or independent or have constant variance, the proper generalization is to use maximum likelihood, provided one can select an appropriate likelihood. In particular, glm assumes independent binomial observations. If that is NOT reasonable, you should not be using glm. Hope this helps. Spencer Graves Mihai Nica wrote: Greetings: I would like to kindly ask help with obtaining mexval statistics (marginal explanatory value - percentage increase in SEE if the variable were left out of the regression model) for a logit (glm) model with several continuous independent variables. I believe I can do it manually for each variable, but I really hope there might be somebody who has a function already written. Writing one is still a little over my skills (I am working on it though). Thanks, mike [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Parsing configuration files
This isn't secure but if its just for yourself and friends you could provide them in R source form, e.g. # my config.ini file a = abc b = 12 x = d in which case reading them is just a matter of source(config.ini) or possibly source(config.ini, local = TRUE) On Mon, May 18, 2009 at 6:10 AM, Marie Sivertsen mariesiv...@gmail.com wrote: Dear list, Is there any functionality in R that would allow me to parse config files? I have trie ??config and apropos('config') without succes, and also search the R package site. Mvh. Marie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple plotting errors
Many thanks once more for helping me to solve this. Gabor - I wasn't even aware of month.abb, so thanks for bringing this useful trick to my attention! Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] intermediate iterations of stepwise regression
Hi Gabor, Thanks for your input. It is of some help if not all. fit = lm(y~1, data) out = capture.output(new.fit = step(fit, direction=forward, scope=y~x1+x2+x3)) Here the assignments made inside the capture.output function are no longer valid once I came out of it, i.e. there is no object called 'new.fit' in the global environment. I want to have at least the final model as new.fit, which is not very efficient to extract from out object (of course I don't want to run step function again separately to get new.fit). Is there any way of doing it? It will be a bonus if, somehow, I can have all the intermediate iterations also as R objects. Thanks in advance. Gabor Grothendieck wrote: Try this: out - capture.output(example(step)) On Mon, May 18, 2009 at 9:11 AM, utkarshsinghal utkarsh.sing...@global-analytics.com wrote: Hi all, I am performing a stepwise regression by running the step function on an lm object. Now I want to save the intermediate iterations. I know the argument trace=T will print it on the console, but I rather want to assign it to some R object or may be output it in a CSV or text file. Any help will be appreciated. Regards Utkarsh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sample variance from simulation
Ah, I thought this smelled like homework... Please read the R-help mailing list posting guide (http://www.r-project.org/posting-guide.html), specifically: Basic statistics and classroom homework: R-help is not intended for these. On Mon, May 18, 2009 at 10:35 AM, Kon Knafelman konk2...@hotmail.com wrote: Hey, when i type in either of those formulas into R, i dont really get the answer im looking for. For such large samples, isnt the sample variance meant to approach the actual variance, which is 1 for a standard normal? also, when i use sapply, i 1000 results for variance, where i think i just need one number. I've worked on this problem for so long. The initial problem is as follows Use the simulation capacity of R to generate m = 1 000 samples of size n = 15 from a N(0,1) distribution. Compute the statistic (n-1)S^2/σ^2 for the normally generated values, labelling as NC14. Produce probability histogram for NC14 and superimpose the theoretical distribution for a χ2 (14 degrees of freedom) g=list() for(i in 1:1000){z[[i]]=rnorm(15,0,1)} for (i in 1:1000)vars[[i]] = sum(z[[i]]) vars[[i]] sum(var(z[[i]])) [1] 0.9983413 Does this make sense? my logic is that i use the loop again to add up all the individual variances. im not really sure if i did it correctly, but if someone could make the necessary corrections, i'd be very very greatful. Thanks heaps guys for taking the time to look at this Date: Mon, 18 May 2009 15:06:47 +0200 From: waclaw.marcin.kusnierc...@idi.ntnu.no To: konk2...@hotmail.com CC: mike.lawre...@dal.ca; r-help@r-project.org Subject: Re: [R] sample variance from simulation Mike Lawrence wrote: why not simply vars=list() for (i in 1:1000) vars[[i]] = var(z[[i]]) ... or, much simpler, vars = sapply(z, var) vQ Let ninemsn property help Looking to move somewhere new this winter? -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
On Mon, 18 May 2009, Debbie Zhang wrote: Based on a set of binomial sample data, how would you utilize the nlm function in R to estimate the true proportion of the population? I can't see why anyone would want to use nlm() for this. The sample proportion is the MLE, and binom.test() gives an exact confidence interval. -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] intermediate iterations of stepwise regression
Don't use = to mean assign. Replace all your equal signs (except the ones intended to refer to argument names) with - . On Mon, May 18, 2009 at 10:10 AM, utkarshsinghal utkarsh.sing...@global-analytics.com wrote: Hi Gabor, Thanks for your input. It is of some help if not all. fit = lm(y~1, data) out = capture.output(new.fit = step(fit, direction=forward, scope=y~x1+x2+x3)) Here the assignments made inside the capture.output function are no longer valid once I came out of it, i.e. there is no object called 'new.fit' in the global environment. I want to have at least the final model as new.fit, which is not very efficient to extract from out object (of course I don't want to run step function again separately to get new.fit). Is there any way of doing it? It will be a bonus if, somehow, I can have all the intermediate iterations also as R objects. Thanks in advance. Gabor Grothendieck wrote: Try this: out - capture.output(example(step)) On Mon, May 18, 2009 at 9:11 AM, utkarshsinghal utkarsh.sing...@global-analytics.com wrote: Hi all, I am performing a stepwise regression by running the step function on an lm object. Now I want to save the intermediate iterations. I know the argument trace=T will print it on the console, but I rather want to assign it to some R object or may be output it in a CSV or text file. Any help will be appreciated. Regards Utkarsh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Superscripts and subscripts in trellis graphics
I'd like to annotate an xyplot with an R^2 value, but can not find the syntax to define the superscript format for the text. I'd appreciate suggestions, xyplot(SharkSloughEggs.df$Sharkeggs.rel + SharkSloughEggs.df$SharkHatched.rel + SharkSloughEggs.df$SharkFlooded.rel + HSI.shark$MEAN ~ Year, pch=c(1,9,5,4), lty=c(1,6,3,4), lwd = c(2), col = c(black, blue, green, red), scales=list(tick.number=length(Year)), data=SharkSloughEggs.df, ylab=Relative Egg Success, main=Shark Slough Alligators, par.settings = graph.sets, type = b) trellis.focus() panel.text(x=1999, y = 0.95, labels=Hatched Eggs\nR^2 = -0.18, cex = 0.75) panel.text(x=1998, y = 0.35, labels=Number of Eggs\nR^2 = 0.43,cex = 0.75) panel.text(x=1995, y = 0.25, labels=Flooded Eggs\nR^2 = -0.50, cex = 0.75) panel.text(x=1986, y = 0.3, labels=Mean HSI, cex = 0.75) trellis.unfocus() Thanks Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Seewave options
Thiago de Carvalho wrote: Good afternoon, My name is Thiago. I'm a graduate student and affiliated to an Anuran Bioacustic and Systematics Laboratory at UFU (Federal University of Uberlândia) in Brazil. The professor in charge of the lab (Dr. Ariovaldo Antonio Giaretta) and I have recently been making use of R, specially the packages Sound and Seewave so as to analize anuran recordings. This software is just fantastic, but I am writing to ask for help about the graphics generated by Seewave. A graphic and the script I used are attached to the e-mail, so that you are able to verify if it is possible to reduce the graphic scale of the Y-axis (see we need only until 10 KHz, even less than it). The fact of recording at 44100 Hz/16 bits resolution may be a possible cause for such a long scale, but that is the only way to record with the best quality... If you think it is easier to change my script and send me back, I would reallly appreciate it too. I am looking forward to your reply. Thanks beforehand, See ?spectro and its flim argument: spectro(x, wl = 256, grid = FALSE, osc = TRUE, listen = TRUE, flim = c(0, 10)) Uwe Ligges __ Thiago Ribeiro de Carvalho Laboratório de Comportamento, Ecologia e Sistemática de Anuros Neotropicais Universidade Federal de Uberlândia http://lattes.cnpq.br/0618169962335506 Veja quais são os assuntos do momento no Yahoo! +Buscados http://br.maisbuscados.yahoo.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error in importing text files
Hello All: I am very new to R and am trying to import some (107) text files into R while simultaneously manipulating the data into a structure that I can use. Below is a description of what I am trying to ultimately accomplish. However, I find that I am unable to even read one file into R using the read.table function. I get the following error: test-read.table(test4.txt) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 16 did not have 8 elements So, I would like to resolve the error first, and then ultimately accomplish the goal outlined below. I understand that my ultimate goal may require multiple steps. I am open to that. First, a little background: Data were collected from 107 participants on palm pilots. Participants were randomly beeped 5 times throughout the day for 5 days resulting in a total of 25 measurement occasions. Participants responded to beeps only when they were able to (not in class, driving, etc). Thus, most participants completed far less than 25 measurement occasions. During each measurement occasion participants responded to 32 questions by moving a slider on a 100 point scale. The palms recorded the date, time, palm pilot ID number, response to the beep (non-response = -32767), question number, response latency in milliseconds, response to each question, and three addtiional data points of no interest. The data are arranged in an unstacked (long) text file such that each line contains all of the above information and there are 34 (32 responses plus 2 extra lines of meaningless data) lines per measurement occasion (upto 850 lines of data if all 34 lines are present ! for all 25 measurment occasions). Below is an example of how the data are arranged. 20080204131646 23256063 6 0 20080204131646 233152-1 7 0 20080204150043 2-32767 0 0 65535 20080204182117 2 1283-1 7 0 20080204182117 2 283834 6 0 20080204182117 2 326636 6 0 Year/Month/Day/Time Palm ID Response/Q#Latency Response 3 meangingless columnsThe dataset presented above begins with question 32 of one measurement occasion on Febraury 4, 2008 taken at 13:16:46. The next line (33) is in the datafile because participants had to click a button to exit the measurement occasion. You then see the beginning of another measurement occasion (20080204192117) in which the participant did not respond (-32767). The next measurement occasion begins on the next line which actually starts with response 2 because participants were required to read a screen and click through prior to answering any questions. Thus, anytime participants simply read an instruction page responses are coded as a -1. What I would like to do is write code to automatically import these 107 files into R and structure them appropriately while importing them. Furthermore, I would like for the code to use conditional statements so that whenever it encounters a -32767! it inserts 32 variables (columns) with missing data and whenever it encounters a -1 it deletes that column all together. I would also like the code to separate the combined year/month/day/time column into 4 separate columns (year, month, day, time). Finally, I would like the code to stack the 32 responses during each measurement occasion so that I have 32 columns of reponses plus columns for year, month, day, and latency, but leave each measurment occasion unstacked. Thanks! Eric S McKibben Industrial-Organizational Psychology Graduate Student Clemson University Clemson, SC [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] intermediate iterations of stepwise regression
utkarshsinghal utkarsh.sing...@global-analytics.com wrote Hi all, I am performing a stepwise regression by running the step function on an lm object. Now I want to save the intermediate iterations. I know the argument trace=T will print it on the console, but I rather want to assign it to some R object or may be output it in a CSV or text file. Any help will be appreciated. You've received help in actually doing this. Can I ask why you want to? Stepwise selection is not a good method of model building. Peter Peter L. Flom, PhD Statistical Consultant www DOT peterflomconsulting DOT com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Superscripts and subscripts in trellis graphics
Try: R2 - -0.18 panel.text(label = bquote(R^2 == .(R2)), ... On Mon, May 18, 2009 at 10:25 AM, steve_fried...@nps.gov wrote: I'd like to annotate an xyplot with an R^2 value, but can not find the syntax to define the superscript format for the text. I'd appreciate suggestions, xyplot(SharkSloughEggs.df$Sharkeggs.rel + SharkSloughEggs.df$SharkHatched.rel + SharkSloughEggs.df$SharkFlooded.rel + HSI.shark$MEAN ~ Year, pch=c(1,9,5,4), lty=c(1,6,3,4), lwd = c(2), col = c(black, blue, green, red), scales=list(tick.number=length(Year)), data=SharkSloughEggs.df, ylab=Relative Egg Success, main=Shark Slough Alligators, par.settings = graph.sets, type = b) trellis.focus() panel.text(x=1999, y = 0.95, labels=Hatched Eggs\nR^2 = -0.18, cex = 0.75) panel.text(x=1998, y = 0.35, labels=Number of Eggs\nR^2 = 0.43,cex = 0.75) panel.text(x=1995, y = 0.25, labels=Flooded Eggs\nR^2 = -0.50, cex = 0.75) panel.text(x=1986, y = 0.3, labels=Mean HSI, cex = 0.75) trellis.unfocus() Thanks Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Superscripts and subscripts in trellis graphics
Hi Steve, you need to use the expression() function. I think it is described under ?plotmath. Defo works with mtext, not sure about ylab. try ylab(text=c(expression(paste(Hatched Eggs R^{2} etc. - Original Message - From: steve_fried...@nps.gov To: r-help@r-project.org Sent: Monday, May 18, 2009 3:25 PM Subject: [R] Superscripts and subscripts in trellis graphics I'd like to annotate an xyplot with an R^2 value, but can not find the syntax to define the superscript format for the text. I'd appreciate suggestions, xyplot(SharkSloughEggs.df$Sharkeggs.rel + SharkSloughEggs.df$SharkHatched.rel + SharkSloughEggs.df$SharkFlooded.rel + HSI.shark$MEAN ~ Year, pch=c(1,9,5,4), lty=c(1,6,3,4), lwd = c(2), col = c(black, blue, green, red), scales=list(tick.number=length(Year)), data=SharkSloughEggs.df, ylab=Relative Egg Success, main=Shark Slough Alligators, par.settings = graph.sets, type = b) trellis.focus() panel.text(x=1999, y = 0.95, labels=Hatched Eggs\nR^2 = -0.18, cex = 0.75) panel.text(x=1998, y = 0.35, labels=Number of Eggs\nR^2 = 0.43,cex = 0.75) panel.text(x=1995, y = 0.25, labels=Flooded Eggs\nR^2 = -0.50, cex = 0.75) panel.text(x=1986, y = 0.3, labels=Mean HSI, cex = 0.75) trellis.unfocus() Thanks Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] bagged importance estimates in earth problem
Thanks for your response Gavin. I get the same error as I noted before when running the example from bagEarth. earth and caret are the most recent versions (on the MAC) available on CRAN binaries, 2.0-5 and 3.45 respectively. I see that the CRAN checks for caret lists an error status for version 4.15 r-release-macosx-ix86, which is probably why it is not available in binary form. I also suspect, but am not sure, that this is why varImp fails. Joe --- On Sat, 5/16/09, Gavin Simpson gavin.simp...@ucl.ac.uk wrote: From: Gavin Simpson gavin.simp...@ucl.ac.uk Subject: Re: [R] bagged importance estimates in earth problem To: Joseph Retzer joe_ret...@yahoo.com Cc: R help r-h...@stat.math.ethz.ch Date: Saturday, May 16, 2009, 5:19 PM On Sat, 2009-05-16 at 08:57 -0700, Joseph Retzer wrote: I was trying to produced bagged importance estimates of attributes in earth using the caret package with the following commands: fit2 - bagEarth(loyalty ~ ., data=model1, B = 10) bagImpGCV - varImp(fit2,value=gcv) My bootstrap estimates are produced however the second command varImp produces the following error: Error in UseMethod(varImp) : no applicable method for varImp Not sure what is going on, any advice would be appreciated, The example in ?bagEarth works for me with caret and earth loaded library(earth) data(trees) fit1 - earth(trees[,-3], trees[,3]) fit2 - bagEarth(trees[,-3], trees[,3], B = 10) varImp(fit2) Overall Girth 100.00 Height 2.387985 packageDescription(earth)$Version [1] 2.3-2 packageDescription(caret)$Version [1] 4.15 Have you loaded the relevant packages and are they up-to-date? Can you run the example above? If the example works, then you'll probably need to supply data and code that fails for you or contact the package maintainer for expert help. HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error in importing text files
Eric, The error suggests that the file has an inconsistent number of attributes. You should inspect the file to make sure that each line has the same number of expected attributes (columns). If one or more is missing, it suggests that the data collection process from the Palm Pilot is not what you expect it to be. Perhaps, participants, just didn't answer all of the questions or something like that. Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 Eric McKibben emck...@clemson. edu To Sent by: r-help@r-project.org r-help-boun...@r- cc project.org Subject [R] error in importing text files 05/18/2009 10:42 AM AST Hello All: I am very new to R and am trying to import some (107) text files into R while simultaneously manipulating the data into a structure that I can use. Below is a description of what I am trying to ultimately accomplish. However, I find that I am unable to even read one file into R using the read.table function. I get the following error: test-read.table(test4.txt) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 16 did not have 8 elements So, I would like to resolve the error first, and then ultimately accomplish the goal outlined below. I understand that my ultimate goal may require multiple steps. I am open to that. First, a little background: Data were collected from 107 participants on palm pilots. Participants were randomly beeped 5 times throughout the day for 5 days resulting in a total of 25 measurement occasions. Participants responded to beeps only when they were able to (not in class, driving, etc). Thus, most participants completed far less than 25 measurement occasions. During each measurement occasion participants responded to 32 questions by moving a slider on a 100 point scale. The palms recorded the date, time, palm pilot ID number, response to the beep (non-response = -32767), question number, response latency in milliseconds, response to each question, and three addtiional data points of no interest. The data are arranged in an unstacked (long) text file such that each line contains all of the above information and there are 34 (32 responses plus 2 extra lines of meaningless data) lines per measurement occasion (upto 850 lines of data if all 34 lines are present ! for all 25 measurment occasions). Below is an example of how the data are arranged. 20080204131646 23256063 6 0 20080204131646 233152-1 7 0 20080204150043 2-32767 0 0 65535 20080204182117 2 1283-1 7 0 20080204182117 2 283834 6 0 20080204182117 2 326636 6 0 Year/Month/Day/Time Palm ID Response/Q#Latency Response 3 meangingless columnsThe dataset presented above begins with question 32 of one measurement occasion on Febraury 4, 2008 taken at 13:16:46. The next line (33) is in the datafile because participants had to click a button to exit the measurement occasion. You then see the beginning of another measurement occasion (20080204192117) in which the participant did not respond (-32767). The next measurement occasion begins on the next line which actually starts with response 2 because participants were required to read a screen and click through prior to answering any questions. Thus, anytime participants simply read an instruction page responses are coded as a -1. What I would like to do is write code to automatically import these 107 files into R and structure them appropriately while importing them. Furthermore, I would like for the code to use conditional statements so that whenever it encounters a -32767! it inserts 32 variables (columns) with
Re: [R] comparing two ROCs
Dear R-helper, I am trying to compare two AUCs derived from same population, but one is derived by adding extra features on top of the other. I found the codes below from R-help. I would like to know, in my case, whether I could use cROC, and also how can I got the right correlation (r)? I have been back to the original paper(Hanley 1983). It suggested to calculate rN(correlation coefficient for the discriminant value for +1 labeled value) and rA(correlation coefficient for the discriminant value for -1 labeled value) and then calculate the average correlation and look up the Table they provided (row: average correlation, column: average AUC). However, in that Table the Average AUC need to be bigger than 0.70, which limits the search (always need to have average AUC larger than 0.70). Would you please suggested some way to calculate the correlation ? Thank you very much! Cheers, Xiao From: Bernardo Rangel Tura Date: Thu 16 Dec 2004 - 07:30:37 EST seROC-function(AUC,na,nn){ a-AUC q1-a/(2-a) q2-(2*a^2)/(1+a) se-sqrt((a*(1-a)+(na-1)*(q1-a^2)+(nn-1)*(q2-a^2))/(nn*na)) se } cROC-function(AUC1,na1,nn1,AUC2,na2,nn2,r){ se1-seROC(AUC1,na1,nn1) se2-seROC(AUC2,na2,nn2) sed-sqrt(se1^2+se2^2-2*r*se1*se2) zad-(AUC1-AUC2)/sed p-dnorm(zad) a-list(zad,p) a } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] discrepancies between stata and r for a cox regression
Hello I would like to develop the use of R. Trying R and more particulary the cox model, I am surprised by discrepancies between results with stata and R for a cox model With the same data base, I get a hazard ratio (4.82) that is not the same obtained with stata (4.52) You will find attached the file leukemia.dta I used (Stata) Here are the codes for R leukemia=read.fwf(file=leukem.txt,widths=c(4,2,3,2,5,2),col.names=c(id,TREAT,TIME,STATUS,LOGWBC, GENDER)) library(survival) res - coxph(Surv(TIME, STATUS)~TREAT, data=leukemia) summary(res) and here the codes for for stata infix ID 2-3 TREAT 6 TIME 8-9 STATUS 11 LOGWBC 12-16 GENDER 18 using g:rleukem.txt,clear stset TIME, failure(STATUS==1) stcox TREAT SPSS and EPIinfo give the same HR than Stata I tried with an other database without any problem What would be the problem??? I changed of pc and versions of R (2.81 2.9.0) without any change. The means are the same for the two packages. I saw a few posts with discrepancies but not with the same database Thanks in advance Michel Boutsen Brussel's University Department of Biostatistics 1 1 6 1 2.31 0 2 1 6 1 4.06 1 3 1 6 1 3.28 0 4 1 6 0 3.2 0 5 1 7 1 4.43 0 6 1 9 0 2.8 0 7 1 10 1 2.96 0 8 1 10 0 2.7 0 9 1 11 0 2.6 0 10 1 13 1 2.88 0 11 1 16 1 3.6 1 12 1 17 0 2.16 0 13 1 19 0 2.05 0 14 1 20 0 2.01 1 15 1 22 1 2.32 1 16 1 23 1 2.57 1 17 1 25 0 1.78 1 18 1 32 0 2.2 1 19 1 32 0 2.53 1 20 1 34 0 1.47 1 21 1 35 0 1.45 1 22 2 1 1 2.8 1 23 2 1 1 51 24 2 2 1 4.91 1 25 2 2 1 4.48 1 26 2 3 1 4.01 1 27 2 4 1 4.36 1 28 2 4 1 2.42 1 29 2 5 1 3.49 1 30 2 5 1 3.97 0 31 2 8 1 3.52 0 32 2 8 1 3.05 0 33 2 8 1 2.32 0 34 2 8 1 3.26 1 35 2 11 1 3.49 0 36 2 11 1 2.12 0 37 2 12 1 1.5 0 38 2 12 1 3.06 0 39 2 15 1 2.3 0 40 2 17 1 2.95 0 41 2 22 1 2.73 0 42 2 23 1 1.97 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/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] discrepancies between stata and r for a cox regression
On Mon, 18 May 2009, Michel Boutsen wrote: Hello I would like to develop the use of R. Trying R and more particulary the cox model, I am surprised by discrepancies between results with stata and R for a cox model With the same data base, I get a hazard ratio (4.82) that is not the same obtained with stata (4.52) I would expect that setting method = breslow replicates the results from Stata (et al.). As ?coxph points out: method: a character string specifying the method for tie handling. If there are no tied death times all the methods are equivalent. Nearly all Cox regression programs use the Breslow method by default, but not this one. The Efron approximation is used as the default here, as it is much more accurate when dealing with tied death times, and is as efficient computationally. The exact method computes the exact partial likelihood, which is equivalent to a conditional logistic model. If there are a large number of ties the computational time will be excessive. hth, Z You will find attached the file leukemia.dta I used (Stata) Here are the codes for R leukemia=read.fwf(file=leukem.txt,widths=c(4,2,3,2,5,2),col.names=c(id,TREAT,TIME,STATUS,LOGWBC, GENDER)) library(survival) res - coxph(Surv(TIME, STATUS)~TREAT, data=leukemia) summary(res) and here the codes for for stata infix ID 2-3 TREAT 6 TIME 8-9 STATUS 11 LOGWBC 12-16 GENDER 18 using g:rleukem.txt,clear stset TIME, failure(STATUS==1) stcox TREAT SPSS and EPIinfo give the same HR than Stata I tried with an other database without any problem What would be the problem??? I changed of pc and versions of R (2.81 2.9.0) without any change. The means are the same for the two packages. I saw a few posts with discrepancies but not with the same database Thanks in advance Michel Boutsen Brussel's University Department of Biostatistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Read.table problems
Dear all, I have a file which I've converted from NetCDF (.nc) to text (.txt) using ncdump in Unix (as I had problems using the ncdf package to do this). The first few rows (as copied and pasted from the Unix console) of the file appear as follows: _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, As you can see, there are a lot of NA values before the actual numeric values start further down the dataset. My problem is that I'm having trouble reading this file into R. I think the problem lies with the sep= argument, although I may be wrong. I tried the following command at first, as the data appear to be comma separated: read.table(test86.txt, skip=43, na.strings=-, header=FALSE, sep=,) - test86 # skip =43 due to meta-data information being held in the initial rows Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 29 did not have 25 elements I then tried sep= , followed by sep= but received a similar-type error message (although line 29 doesn't appear to be especially different from the rest). I subsequently tried using sep=\t and then sep=\n. These both result in the data being read in without an error message being displayed, although the data are formatted as follows: head(test86) V1 1 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 2 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 3 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 4 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 5 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 6 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, dim(test86) [1] 179899 1 Instead of one column, I'd expect there to be 720. I think I'm getting something wrong relating to the sep= argument (or possibly mis-using na.strings?). If anyone has any solutions to this then I'd be very grateful to hear them. Many thanks for any advice, Steve __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] discrepancies between stata and r for a cox regression
try res - coxph(Surv(TIME, STATUS)~TREAT, data=leukemia, method=breslow) R default for handling ties is Efron's method, whereas it's Breslow for STATA. Have a look under method in ?coxph it clearly states this, and STATA output clearly states the Breslow method for ties in the output of running a cox model. HTH Gary --- Dr Gary S Collins Tel: +44 (0)1865 284418 Centre for Statistics in Medicine Fax: +44 (0)1865 284424 Wolfson College Annexewww.csm-oxford.org.uk University of Oxford Linton Road Oxford, OX2 6UD --- Michel Boutsen wrote: Hello I would like to develop the use of R. Trying R and more particulary the cox model, I am surprised by discrepancies between results with stata and R for a cox model With the same data base, I get a hazard ratio (4.82) that is not the same obtained with stata (4.52) You will find attached the file leukemia.dta I used (Stata) Here are the codes for R leukemia=read.fwf(file=leukem.txt,widths=c(4,2,3,2,5,2),col.names=c(id,TREAT,TIME,STATUS,LOGWBC, GENDER)) library(survival) res - coxph(Surv(TIME, STATUS)~TREAT, data=leukemia) summary(res) and here the codes for for stata infix ID 2-3 TREAT 6 TIME 8-9 STATUS 11 LOGWBC 12-16 GENDER 18 using g:rleukem.txt,clear stset TIME, failure(STATUS==1) stcox TREAT SPSS and EPIinfo give the same HR than Stata I tried with an other database without any problem What would be the problem??? I changed of pc and versions of R (2.81 2.9.0) without any change. The means are the same for the two packages. I saw a few posts with discrepancies but not with the same database Thanks in advance Michel Boutsen Brussel's University Department of Biostatistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] build CONTENTS or 00Index.html without installing whole package
Replying to my own message, I've now fixed up the bash script so that it works (below). I don't think that buildVignettes does anything I need, so I commented it out (but now runs). Rscript, and not R CMD (which I was mistakenly using before), seems to be the way to run arbitrary R functions from a script like this, although R CMD works for the perl script. But the main problem remains. Still no 00Index.html filles or CONTENTS. I suppose I could write a script to generate the 00Index.html file from the Rd files, but I'm sure I'd be reinventing the wheel. Reminder: The main purpose of this is to set up a site with all the help files of all the packages available in html format, and pdf files of vignettes. Once I figure this out, it will be much easier for someone else to reproduce the site I have at http://finzi.psych.upenn.edu, and easier for me to maintain it. #!/bin/bash # makes indexable help files for R packages, including pdf vignettes # usage inst.bat [files] (in quotes, if wildcards) for PKG in `ls $1` do tar xfz $PKG PK=`echo $PKG | /bin/sed -e 's/.tar.gz//' | cut -d_ -f1` echo $PK mkdir -pv /usr/lib/R/library/$PK mkdir -pv /usr/lib/R/library/$PK/html # copy description (which contains version number) cp $PK/DESCRIPTION /usr/lib/R/library/$PK # move vignettes if present if [ -d $PK/inst/doc ]; then mkdir -pv /usr/lib/R/library/$PK/doc cp $PK/inst/doc/* /usr/lib/R/library/$PK/doc # Rscript --default-packages=tools --no-init-file --no-save \ #-e buildVignettes('$PK','/usr/lib/R/library/$PK') fi # make html files R CMD perl /usr/share/R/perl/build-help.pl --html \ /home/baron/$PK /usr/lib/R/library rm -rf $PK done Rscript --no-init-file --no-save -e make.packages.html() __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Read.table problems
On May 18, 2009, at 11:24 AM, Steve Murray wrote: Dear all, I have a file which I've converted from NetCDF (.nc) to text (.txt) using ncdump in Unix (as I had problems using the ncdf package to do this). The first few rows (as copied and pasted from the Unix console) of the file appear as follows: _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, As you can see, there are a lot of NA values before the actual numeric values start further down the dataset. My problem is that I'm having trouble reading this file into R. I think the problem lies with the sep= argument, although I may be wrong. I tried the following command at first, as the data appear to be comma separated: read.table(test86.txt, skip=43, na.strings=-, header=FALSE, sep=,) - test86 # skip =43 due to meta-data information being held in the initial rows Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 29 did not have 25 elements I then tried sep= , followed by sep= but received a similar-type error message (although line 29 doesn't appear to be especially different from the rest). I subsequently tried using sep=\t and then sep=\n. These both result in the data being read in without an error message being displayed, although the data are formatted as follows: head(test86) V1 1 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 2 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 3 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 4 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 5 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 6 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, dim(test86) [1] 179899 1 Instead of one column, I'd expect there to be 720. I think I'm getting something wrong relating to the sep= argument (or possibly mis-using na.strings?). If anyone has any solutions to this then I'd be very grateful to hear them. Many thanks for any advice, Steve Two problems, 1. Your first line above has one more column/entry than the subsequent lines. If that is correct, you need to use the 'fill = TRUE' argument so that all subsequent rows are filled to have the same number of columns. If the above is due to a copy/paste error, then disregard this. 2. You are using a '-' (hyphen) as your 'na.strings' character, when the data is using a '_' (underscore). Additionally, I would use 'strip.white = TRUE', to aid in getting rid of extraneous white space around your fields/separators. That will also help with column separations. Thus (on OSX) with the above data copied to the clipboard: read.table(pipe(pbpaste), na.strings = _, sep = ,, fill = TRUE, strip.white = TRUE) V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21 V22 V23 V24 V25 V26 1 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 2 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 3 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 4 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 5 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 6 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 7 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 8 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 9 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 10 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and
Re: [R] bagged importance estimates in earth problem
Joe, On Mon, May 18, 2009 at 11:01 AM, Joseph Retzer joe_ret...@yahoo.com wrote: Thanks for your response Gavin. I get the same error as I noted before when running the example from bagEarth. earth and caret are the most recent versions (on the MAC) available on CRAN binaries, 2.0-5 and 3.45 respectively. That is probably your problem. caret is at 4.15 and earth is now at 2.3-2. caret 3.45 was released on 2008-10-17 and many changes have been made to both packages since then. I see that the CRAN checks for caret lists an error status for version 4.15 r-release-macosx-ix86, which is probably why it is not available in binary form. I also suspect, but am not sure, that this is why varImp fails. No, not at all true. I build it on OS X and R-Forge checks it every night. Please don't extrapolate, especially if you haven't sent a reproducible example. Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RES: Read.table problems
I was having this problem with a file. My problem was a ' indo the name, link Ricardo D'avilla, the ' skipped all sep to the end of the file. Maybe it is your problem. Atenciosamente, Leandro Lins Marino Centro de Avaliação Fundação CESGRANRIO Rua Santa Alexandrina, 1011 - 2º andar Rio de Janeiro, RJ - CEP: 20261-903 R (21) 2103-9600 R.:236 (21) 8777-7907 ( lean...@cesgranrio.org.br Aquele que suporta o peso da sociedade é precisamente aquele que obtém as menores vantagens. (SMITH, Adam) Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO AMBIENTE Esta mensagem, incluindo seus anexos, pode conter informacoes privilegiadas e/ou de carater confidencial, nao podendo ser retransmitida sem autorizacao do remetente. Se voce nao e o destinatario ou pessoa autorizada a recebe-la, informamos que o seu uso, divulgacao, copia ou arquivamento sao proibidos. Portanto, se você recebeu esta mensagem por engano, por favor, nos informe respondendo imediatamente a este e-mail e em seguida apague-a. -Mensagem original- De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Em nome de Marc Schwartz Enviada em: segunda-feira, 18 de maio de 2009 13:58 Para: Steve Murray Cc: r-help@r-project.org Assunto: Re: [R] Read.table problems On May 18, 2009, at 11:24 AM, Steve Murray wrote: Dear all, I have a file which I've converted from NetCDF (.nc) to text (.txt) using ncdump in Unix (as I had problems using the ncdf package to do this). The first few rows (as copied and pasted from the Unix console) of the file appear as follows: _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, As you can see, there are a lot of NA values before the actual numeric values start further down the dataset. My problem is that I'm having trouble reading this file into R. I think the problem lies with the sep= argument, although I may be wrong. I tried the following command at first, as the data appear to be comma separated: read.table(test86.txt, skip=43, na.strings=-, header=FALSE, sep=,) - test86 # skip =43 due to meta-data information being held in the initial rows Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 29 did not have 25 elements I then tried sep= , followed by sep= but received a similar-type error message (although line 29 doesn't appear to be especially different from the rest). I subsequently tried using sep=\t and then sep=\n. These both result in the data being read in without an error message being displayed, although the data are formatted as follows: head(test86) V1 1 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 2 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 3 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 4 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 5 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 6 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, dim(test86) [1] 179899 1 Instead of one column, I'd expect there to be 720. I think I'm getting something wrong relating to the sep= argument (or possibly mis-using na.strings?). If anyone has any solutions to this then I'd be very grateful to hear them. Many thanks for any advice, Steve Two problems, 1. Your first line above has one more column/entry than the subsequent lines. If that is correct, you need to use the 'fill = TRUE' argument so that all subsequent rows are filled to have the same number of columns. If the above is due to a copy/paste error, then disregard this. 2. You are using a '-' (hyphen) as your 'na.strings' character, when the data is using a '_' (underscore). Additionally, I would use 'strip.white = TRUE', to aid in getting rid of extraneous white space around your fields/separators. That will also help with column separations. Thus (on OSX) with the above data copied to the clipboard: read.table(pipe(pbpaste), na.strings = _, sep = ,, fill = TRUE,
Re: [R] bagged importance estimates in earth problem
Max, If you read my message closely, you'll see I'm indicating that the check error may explain why carat 4.15 _is not available in CRAN binaries_. Because of this (not having the latest version) I suspect varImp is returning the error I detailed. Can you provide information as to why 4.15 is not available? That would be useful. Also, as far a reproducible example is concerned, I noted that the example in bagEarth produces the same error as my original problem (i.e. I can reproduce the error on my machine with that code/data which is also available to others). Again, a more careful read of my original email would have made that clear. Thanks, --- On Mon, 5/18/09, Max Kuhn mxk...@gmail.com wrote: From: Max Kuhn mxk...@gmail.com Subject: Re: [R] bagged importance estimates in earth problem To: Joseph Retzer joe_ret...@yahoo.com Cc: gavin.simp...@ucl.ac.uk, R help r-h...@stat.math.ethz.ch Date: Monday, May 18, 2009, 12:08 PM Joe, On Mon, May 18, 2009 at 11:01 AM, Joseph Retzer joe_ret...@yahoo.com wrote: Thanks for your response Gavin. I get the same error as I noted before when running the example from bagEarth. earth and caret are the most recent versions (on the MAC) available on CRAN binaries, 2.0-5 and 3.45 respectively. That is probably your problem. caret is at 4.15 and earth is now at 2.3-2. caret 3.45 was released on 2008-10-17 and many changes have been made to both packages since then. I see that the CRAN checks for caret lists an error status for version 4.15 r-release-macosx-ix86, which is probably why it is not available in binary form. I also suspect, but am not sure, that this is why varImp fails. No, not at all true. I build it on OS X and R-Forge checks it every night. Please don't extrapolate, especially if you haven't sent a reproducible example. Max [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] discrepancies between stata and r for a cox regression
Hello I would like to develop the use of R. Trying R and more particulary the cox model, I am surprised by discrepancies between results with stata and R for a cox model With the same data base, I get a hazard ratio (4.82) that is not the same obtained with stata (4.52) You will find attached the file leukemia.dta I used (Stata) Here are the codes for R library(foreign) leukemia-read.dta(leukemia.dta) library(survival) res - coxph(Surv(TIME, STATUS)~TREAT, data=leukemia) summary(res) and here the codes for for stata use leukemia.dta,clear stset TIME, failure(STATUS==1) stcox TREAT SPSS and EPIinfo give the same HR than Stata I tried with an other database without any problem What would be the problem??? I changed of pc and versions of R (2.81 2.9.0) without any change. The means are the same for the two packages. I saw a few posts with discrepancies but with no explanations Thanks in advance Michel Boutsen Brussel's University Department of Biostatistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.