[R] Including entire dataframe in svyglm formula
Hello! I am attempting to use svyglm {survey package} with a large set of predictors and would like to be able to automatically use all the variables in my data as the predictors without having to type out their names explicitly, similar to the way one can do: x1=c(1,2,3,4) x2=c(3,5,4,1) y = x1+x2+rnorm(4,0,1) xdataframe = data.frame(x1,x2) lm(y~., data=xdataframe) #or lm(y~xdataframe) and the period or dataframe name will cause all predictors to be included. I have been trying that with the following code (and all sorts of permutations thereof): svd = svydesign(id =~PSUSCID, weights=~GSWGT1, data=data.frame(cbind(y1, xfull))) model = svyglm(y1~., data=svd$variables[,-1], design=svd) where y1 is a vector of my independent variable and xfull is a matrix of my independent variables. I receive the following error: Error in svyglm.survey.design(y1 ~ ., data = svd$variables, design = svd) : all variables must be in design= argument Is there any way I can avoid explicitly typing out the names of all the predictors in my formula in svyglm? (I have 60+.) Thanks so much! -nate cermak student, university of washington __ 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] Correlation coefficient of large data sets
I think what you have done should be fine. read.table() will return a data frame, which cor() can handle happily. For example: my.data - read.table(file.csv, header = TRUE, row.names = 1, sep=,, strip.white = TRUE) # assign your data to my.data cor(my.data) # calculate the correlation matrix between all variables (columns) of my.data What happens if you try that? __ 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] Frequencies from a matrix - spider from frequencies
On 03/16/2010 02:43 AM, Uwe Dippel wrote: ... Thanks, Jim, this one works (with your random data)! (In case anyone reads and wants this as well, package plotrix provides radial.plot.) The overlap is normal, because it's random data. When the respondents have a less random streak of answering (and they do), this plot will show some continuity throughout the questions; and identify those questions clearly, which fall outside of this continuity. This is why I prefer to use it here. Uwe Yes, I realized that I had forgotten to require(plotrix) after I sent the message. From your example, you might also want to look at the diamondplot function, also in plotrix. Jim __ 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] OT Sorta: Odds Are, It's Wrong...
On 03/16/2010 03:22 AM, Marc Schwartz wrote: Hi all, I thought that readers of R-Help might find the following article at ScienceNews of interest: Odds Are, It's Wrong Science fails to face the shortcomings of statistics By Tom Siegfried March 27th, 2010; Vol.177 #7 (p. 26) http://www.sciencenews.org/view/feature/id/57091/title/Odds_are,_its_wrong The real problem with statistics may not be that it is so hard to learn, but that it is so easy to forget. Jim __ 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] R on Linux - a primer
On Sun, 14 Mar 2010, Jonathan Baron wrote: Just to make this thoroughly confusing, I will say that I am very happy with Fedora I can second that, as I have found Fedora (and before that, RedHat) plus KDE to create less response interference for those of us who use Windows. Not by choice, but in almost every position I have held recently, I was the sole person who dual-booted to Linux. I've yet to find an application that I can't install on Fedora, but I have had to admit defeat on a PC with Ubuntu in a lab where I collaborate. Jim __ 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] OT Sorta: Odds Are, It's Wrong...
G'day all, On Mon, 15 Mar 2010 12:46:42 -0500 Marc Schwartz marc_schwa...@me.com wrote: In turn, that reminds me of Stephen Senn's writing in Dicing with Death: Chance, Risk and Health: We can predict nothing with certainty but we can predict how uncertain our predictions will be, on average that is. And I am reminded Stephen Senn's citation of Maurice Kendal in the same book: `Life', the statistician Maurice Kendal once remarked, `would be simpler if the Bayesians followed the example or their master and published posthumously'. Cheers, Berwin __ 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] OT Sorta: Odds Are, It's Wrong...
Marc Schwartz-3 wrote: I thought that readers of R-Help might find the following article at ScienceNews of interest: Odds Are, It's Wrong Science fails to face the shortcomings of statistics By Tom Siegfried March 27th, 2010; Vol.177 #7 (p. 26) http://www.sciencenews.org/view/feature/id/57091/title/Odds_are,_its_wrong Too bad the article is so long that all my p-value-greedy colleagues from the medical faculty won't read it. Journals should apply a post-hoc Bonferroni-correction by the number of p-values cited in an article. Dieter -- View this message in context: http://n4.nabble.com/OT-Sorta-Odds-Are-It-s-Wrong-tp1593626p1594511.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] Problem in installing ncdf package
Dear R communities Could you please help me with the problem I encounter while trying to install the ncdf package? download.packages(ncdf, /home/user/soft/R/library/) cd /home/user/soft/R/library R CMD INSTALL ncdf_1.6.tar.gz # fail sudo R CMD INSTALL ncdf_1.6.tar.gz # fail cd /home/user/soft/ # download http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.0.1.tar.gz tar -xzvf netcdf-4.0.1.tar.gz R CMD INSTALL --configure-args=-with-netcdf_incdir=/home/user/soft/netcdf-4.0.1/libsrc -with-netcdf_libdir=/home/user/soft/netcdf-4.0.1/libsrc/ ncdf_1.6.tar.gz # Error: user specified netCDF library directory does not have libnetcdf.a ! Thank you very much for your kind help. [[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] recursive default argument error
I do not understand this. I have the same problem and I tried to reproduce it thusly Q - 3 test - function(q=Q){ cat(q, \n) } test() 3 Q - 3 test - function(q=Q){ test2(q, \n) } test2 - function(q, a){ cat(q, a) } test() 3 Q - 3 test - function(q=Q){ z - paste(q, \n) test2(z, cat) } test2 - function(q, F){ F(q) } test() 3 Surly these should have the same problem? I really do not understand the following explanation, but the get(.., envir=environment(ThisFunc)) works nicely, but I do not know why. I thought if I could write a toy programme to reproduce it... cheers Worik One of the most important things to know about the evaluation of arguments to a function is that supplied arguments and default arguments are treated differently. The supplied arguments to a function are evaluated in the evaluation frame of the calling function. The default arguments to a function are evaluated in the evaluation frame of the function. the parameter testparams, when no matching argument is passed, is given the default value which is the value of the variable testparams looked-up *not* in the environment where foo is defined, and *not* in the environment where foo is called, but rather in the local environment created when the function is called and where parameters are mapped to values -- and in this environment, testparams is a parameter, which is already being under evaluation, hence the recursive lookup error. in some programming languages, testparams (the default value) would come from the definition-time environment, so you'd not have problems; in others, it's more like in r: python x = 1; def foo(x, y=x): return y; foo(2) # 1 ruby x = 1; def foo(x, y=x); y; end; foo(2) # 2 you just have to get used to it. I can obviously rename testparams but I would still like to understand why this breaks. I would have thought the right hand side of testparams=testparams would have been evaluated in the namespace outside the script and not the function. How can I force it to be evaluated in the namespace outside the function ? something like this ugly hack seems to solve the problem: foo = function(testparams = get(testparams, envir=environment(foo)) 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. [[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] labels gone
Hi Milton, Thanks for your help. I must confess that I don't understand what your code means at this moment. But you really helped me out and I'll figure it out later. Thanks. Cheers. Zhongyi On Tue, Mar 16, 2010 at 12:26 AM, milton ruser milton.ru...@gmail.comwrote: Hi Zhongyi, I must confess I not understood completely what you need, but... Tau-seq(0.05,0.95,0.05); Pi - seq(0.19,0.01,-0.01); par(cex.axis=0.8,ps=9,mar=c(1.5,1,0.5,1), oma=c(1,1,0.2,1) ,tck=-0.01); plot(Tau,Pi, type='l', xlab=Tau,ylab=Pi,col=4, xaxt=n, yaxt=n); axis(1,labels=F) axis(1,line=-1, lwd=0) axis(2,labels=F) axis(2,line=-0.5, lwd=0) mtext(x_txt,side=1, line=0.5) mtext(y_txt,side=2, line=1.2) cheers milton On Tue, Mar 16, 2010 at 12:28 AM, Zhongyi Yuan zhongyi-y...@uiowa.eduwrote: Dear R users: I am drawing a graph with the following code: Tau-seq(0.05,0.95,0.05); Pi - seq(0.19,0.01,-0.01); par(cex.axis=0.8,ps=9,mar=c(1.5,1,0.5,1), oma=c(1,1,0.2,1) ,tck=-0.01); plot(Tau,Pi, type='l', xlab=Tau,ylab=Pi,col=4); I want to make the graph take as little space as possible. Here I run into two problems. One is that the labels are gone, the other is the scale numbers of axises are a little too far from my axises. Can anyone help me with this? I am new to graphics and have spent a lot of time on par but still not yet got it. Thanks. best, Zhongyi [[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. [[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] C# DLL Library
Good afternoon everybody, I am sorry, this question might look trivial to some of you, but I read quite a lot of stuff about package creation and I would like a bit of you advices. I would like to develop a core library which I will be using both from R and from C#. I read that it was possible to import DLL to R. The thing is, I am not sure that the DLL created with C# will be compatible. I still have not implemented anything, so if it is only a matter of method signatures, I can make sure everything fits. Otherwise, I could use a C++ DLL, but I don't know if it is really recommended. (In fact, I would love to be able to develop it in Visual Studio because it is where I developed the rest of my platform). So, what would you advise? - Writing the DLL freely in C# and then create a wrapper? - Writing it in C++ - Writing it in C, the other options are really not good ideas. Thanks, -- Jeremie Smaga [[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] Package documentation in dissertation
See: https://stat.ethz.ch/pipermail/r-help/2005-April/070581.html On Mon, Mar 15, 2010 at 11:16 PM, statmobile statmob...@gmail.com wrote: Hey Gabor, Thanks, I tried that, although I can't compile it directly. Do you know where I can get the R LaTeX definitions in order to compile that? Thanks! Gabor Grothendieck wrote: Try: R CMD Rdconv --type=latex myfile.Rd On Mon, Mar 15, 2010 at 8:46 PM, statmobile statmob...@gmail.com wrote: Hey Everyone, I wrote up a library for my dissertation work, and I'd love to include it as an appendix. I have found ways to export the Rd files as html, txt and pdf/ps, but not a raw tex export. I've had to resort to dumping it into text files, and just using verbatim in my LaTeX code. Does anybody have any recommendations or experiences with dealing with this? Please CC me on any response, as I only get summary emails from the list. Thanks in advance! Brian __ 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] Ensembles in cforest
Dear List, I'm trying to find a way to extract the individual conditional inference trees from cforest ( a modelling function in the party package) in a manner analogous to getTree in randomForest and I'm struggling. I can see that the information is held within the ensemble list, but haven't been able to work out how this sequence of nested lists is structured or if any of the items are named. Any help would be appreciated. I'm running R2.10.0 on windows XP. Kind Regards, Philip This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory. The contents of this email may relate to dealings with other companies within the Detica Limited group of companies. Detica Limited is registered in England under No: 1337451. Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, England. [[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] How to parse a string (by a new markup) with R ?
Hello all, For some work I am doing on RNA, I want to use R to do string parsing that (I think) is like a simplistic HTML parsing. For example, let's say we have the following two variables: Seq - GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str - ... Say that I want to parse Seq According to Str, by using the legend here Seq: GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str: ... | | | | | | | || | +-+ +--+ +---+ +---++-+ |Stem 1Stem 2 Stem 3 | || ++ Stem 0 Assume that we always have 4 stems (0 to 3), but that the length of letters before and after each of them can very. The output should be something like the following list structure: list( Stem 0 opening = GCCTCGA, before Stem 1 = TA, Stem 1 = list(opening = GCTC, inside = AGTTGGGA, closing = GAGC ), between Stem 1 and 2 = G, Stem 2 = list(opening = TACGA, inside = CTGAAGA, closing = TCGTA ), between Stem 2 and 3 = AGGtC, Stem 3 = list(opening = ACCAG, inside = TTCGATC, closing = CTGGT ), After Stem 3 = , Stem 0 closing = TCC ) I don't have any experience with programming a parser, and would like advices as to what strategy to use when programming something like this (and any recommended R commands to use). What I was thinking of is to first get rid of the Stem 0, then go through the inner string with a recursive function (let's call it seperate.stem) that each time will split the string into: 1. before stem 2. opening stem 3. inside stem 4. closing stem 5. after stem Where the after stem will then be recursively entered into the same function (seperate.stem) The thing is that I am not sure how to try and do this coding without using a loop. Any advices will be most welcomed. Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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] C# DLL Library
Hello Richard, Thanks for the tips. I was aware of the R(D)COM. In the last public version, there is now splash screen appearing which is kind of boring so I think I need to buy it or something. Anyway, I think the idea was to create a common CORE library that can be used from C# and from R. So I think I'll have a look at RCPP which looks to be the best solution. Have you tried it already? Do you know any good tutorial for this package? Thanks, Jeremie On Tue, Mar 16, 2010 at 5:23 PM, richard.cot...@hsl.gov.uk wrote: I would like to develop a core library which I will be using both from R and from C#. - Writing the DLL freely in C# and then create a wrapper? - Writing it in C++ - Writing it in C, the other options are really not good ideas. As far as I know, there currently is no way to call .NET code from R. If you want a library that can be called from both a .NET environment and from R, then writing it in C or C++ is likely your best bet. Alternatively, you can run R code from within .NET using the rcom package. There's an example in F# here (what's true for F# is true for C#). http://cs.hubfs.net/blogs/thepopeofthehub/archive/2007/11/06/FSharpWithR.aspx See ?.C for calling C code, and the rcpp package for an interface to C++ code. Choosing between those two languages mostly depends on whether on not your library is especially suited to object oriented programming or not. Regards, Richie. Mathematical Sciences Unit* **HSL* http://www.hsl.gov.uk/contact-us.htm r-help-boun...@r-project.org wrote on 16/03/2010 09:04:54: Good afternoon everybody, I am sorry, this question might look trivial to some of you, but I read quite a lot of stuff about package creation and I would like a bit of you advices. I read that it was possible to import DLL to R. The thing is, I am not sure that the DLL created with C# will be compatible. I still have not implemented anything, so if it is only a matter of method signatures, I can make sure everything fits. Otherwise, I could use a C++ DLL, but I don't know if it is really recommended. (In fact, I would love to be able to develop it in Visual Studio because it is where I developed the rest of my platform). So, what would you advise? Thanks, -- Jeremie Smaga [[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. -- *ATTENTION:* This message contains privileged and confidential information intended for the addressee(s) only. If this message was sent to you in error, you must not disseminate, copy or take any action in reliance on it and we request that you notify the sender immediately by return email. Opinions expressed in this message and any attachments are not necessarily those held by the *Health and Safety Laboratory http://www.hsl.gov.uk/*or any person connected with the organisation, save those by whom the opinions were expressed. Please note that any messages sent or received by the *Health and Safety Laboratory http://www.hsl.gov.uk/* email system may be monitored and stored in an information retrieval system. -- Think before you print - do you really need to print this email? -- -- Scanned by *MailMarshal* - Marshal's comprehensive email content security solution. Download a free evaluation of MailMarshal at www.marshal.com ** -- -- Jeremie Smaga [[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] C# DLL Library
Hello, disclaimer: I don't know C# at all and how it might connect to c++, etc ... For an introductory ride about Rcpp, you can consult the Rcpp-introduction vignette which you can download from the cran page of Rcpp or if you have it installed, you can just do: vignette( Rcpp-introduction, package = Rcpp ) For semi-self-explanatory code examples, you can consult our unit tests: system.file( unitTests, package = Rcpp ) For more questions, we have a dedicated mailing list: https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel Romain Le 16/03/10 11:43, Jeremie Smaga a écrit : Hello Richard, Thanks for the tips. I was aware of the R(D)COM. In the last public version, there is now splash screen appearing which is kind of boring so I think I need to buy it or something. Anyway, I think the idea was to create a common CORE library that can be used from C# and from R. So I think I'll have a look at RCPP which looks to be the best solution. Have you tried it already? Do you know any good tutorial for this package? Thanks, Jeremie On Tue, Mar 16, 2010 at 5:23 PM,richard.cot...@hsl.gov.uk wrote: I would like to develop a core library which I will be using both from R and from C#. - Writing the DLL freely in C# and then create a wrapper? - Writing it in C++ - Writing it in C, the other options are really not good ideas. As far as I know, there currently is no way to call .NET code from R. If you want a library that can be called from both a .NET environment and from R, then writing it in C or C++ is likely your best bet. Alternatively, you can run R code from within .NET using the rcom package. There's an example in F# here (what's true for F# is true for C#). http://cs.hubfs.net/blogs/thepopeofthehub/archive/2007/11/06/FSharpWithR.aspx See ?.C for calling C code, and the rcpp package for an interface to C++ code. Choosing between those two languages mostly depends on whether on not your library is especially suited to object oriented programming or not. Regards, Richie. Mathematical Sciences Unit* **HSL*http://www.hsl.gov.uk/contact-us.htm r-help-boun...@r-project.org wrote on 16/03/2010 09:04:54: Good afternoon everybody, I am sorry, this question might look trivial to some of you, but I read quite a lot of stuff about package creation and I would like a bit of you advices. I read that it was possible to import DLL to R. The thing is, I am not sure that the DLL created with C# will be compatible. I still have not implemented anything, so if it is only a matter of method signatures, I can make sure everything fits. Otherwise, I could use a C++ DLL, but I don't know if it is really recommended. (In fact, I would love to be able to develop it in Visual Studio because it is where I developed the rest of my platform). So, what would you advise? Thanks, -- Jeremie Smaga -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/OIXN : raster images and RImageJ |- http://tr.im/OcQe : Rcpp 0.7.7 `- http://tr.im/O1wO : highlight 0.1-5 __ 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] Fwd: Cumulative normal distr
Hi, How to fit data to cumulative normal distribution? I tried such way: library(MASS) ed-c(1:10) cnd-function(mn,sdd){pnorm(c(1:10),mn,sdd)} fitdistr(ed,cnd,start=list(mn=mean(ed),sdd=sd(ed))) ..but an error occured: Error in solve.default(res$hessian) : function Lapack 'dgesv': system are exactly singular Thank you for help Antony -- __ 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] kknn and logistic regression: how to cross-validate binary prediction
Take a look at the caret package http://cran.r-project.org/web/packages/caret/index.html and the package vignettes, especially the one labeled as model builing. Max On Mar 15, 2010, at 6:11 PM, noclue_ tim@netzero.net wrote: I am comparing kknn and logistic regression for binary outcome prediction - For kknn, I can do - kknn_-kknn(out_come ~ age + gender , learn_, valid_) fit-fitted(kknn_) table(valid_$out_come, fit) to get validation results in cross-tabulation. - For logistic, how can I do the equivalent cross-validation? logit_-glm(out_come ~ age + gender, data=learn_, family=binomial) ... ... then how could I fit the logistic regression on validation data (ie. valid_) to get predicted outcome? Thanks! -- View this message in context: http://n4.nabble.com/kknn-and-logistic-regression-how-to-cross-validate-binary-prediction-tp1594107p1594107.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-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] interactive 3d plot (identifying datapoint when clicked or mouse-overed)
Is there a package that provides interactive 3d scatter plot with the functionality of identifying the datapoint when clicked or mouse-overed? Or, if not, which package is the best alternative (with some modification) to produce the similar effect? If there is a rotation feature, it is +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] interactive 3d plot (identifying datapoint when clicked or mouse-overed)
Dear June Kim, The scatter3d function in the Rcmdr package, or in the development version of the car package on R-Forge, can do interactive point identification. (For the version in car, set id.method=identify.) Regards, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of June Kim Sent: March-16-10 7:20 AM To: r-help@r-project.org Subject: [R] interactive 3d plot (identifying datapoint when clicked or mouse-overed) Is there a package that provides interactive 3d scatter plot with the functionality of identifying the datapoint when clicked or mouse-overed? Or, if not, which package is the best alternative (with some modification) to produce the similar effect? If there is a rotation feature, it is +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. __ 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] map2poly - map lat/long cannot be unconstrained?
An ideal question for R-sig-geo. Firstly, consider using sp classes, which try to help more in plotting correctly specified spatial data, and note that Map2poly has not only been deprecated for a long time, but was recently removed from the namespace of the maptools package. Secondly, consider that the aspect of spatial data should not in general be manipulable, meters should stay meters on both axes. Thrirdly, if you want to overplot points, do use points(), not plot(). Using methods for sp classes would handle this directly, where plot(..., add=TRUE) assumes that a previous plot() call has set the plotting window and axes. Hope this helps, Roger Euan Reavie wrote: Using the maptools function map2poly I have created a map/polylist object - a map of the Great Lakes. My goal is to passively plot additional data on this map. Unfortunately I am not able to change (distort) the relative scale of the axes for the map, and so the sample points do not line up correctly on the map. In the code below, notice that I have set the same axis ranges on each plot for x (longitude) and y (latitude), and yet it has no effect on the map plot. For example, if I stretch the plot window vertically, the y data spread out accordingly, but the map remains undistorted. No matter how much I try to stretch the y axis, the y:x ratio scale remains 1:1. How do I force the map to fit the ranges that I set like I can for the data plot? *# make the map object lakes tmp - read.shape('D:/R/great lakes map/grtlakes/grtlakes') lakes - Map2poly(tmp) # read sample location data to be plotted on map locs - read.table(locs.csv, header=TRUE, sep=,, na.strings=NA, dec=., strip.white=TRUE) # plot map, then sample locations plot(lakes,xlim=range(-76,-93), ylim=range(40,50)) par(new=TRUE) # put next plot on same graph plot(LATITUDE~LONGITUDE, data=locs,xlim=range(-76,-93),ylim=range(40,50)) box()* Thank you for any help - Euan. Euan D. Reavie Center for Water and the Environment Natural Resources Research Institute University of Minnesota Duluth 1900 East Camp Street, Ely, MN 55731 email ereavie *at sign* nrri.umn.edu [[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. - Roger Bivand Economic Geography Section Department of Economics Norwegian School of Economics and Business Administration Helleveien 30 N-5045 Bergen, Norway -- View this message in context: http://n4.nabble.com/map2poly-map-lat-long-cannot-be-unconstrained-tp1593866p1594757.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.
Re: [R] How to parse a string (by a new markup) with R ?
How are you supposed to interprete the string that is doing the parsing? Does each sequence have the same number of for the opening sequence as it does for on the ending sequence? That what it appears to be looking at the way stem 3 is parsed. You will have to provide a little more insight on how to interprete the symbols. Does the parsing always start with a partial stem 0 as your example shows? Is there a way of making sure you have the right sequences when you start? Is there a chance of error in the middle of the string that you have to restart from? How long are these strings that you want to parse? Is each one a self contained sequence like you show in your example, or do they go on for thousands of characters? Is there always at least one '.' between stems? A full set of rules as to how the parsing should be done would be useful. Do you have the BNF syntax for parsing? On Tue, Mar 16, 2010 at 6:10 AM, Tal Galili tal.gal...@gmail.com wrote: Hello all, For some work I am doing on RNA, I want to use R to do string parsing that (I think) is like a simplistic HTML parsing. For example, let's say we have the following two variables: Seq - GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str - ... Say that I want to parse Seq According to Str, by using the legend here Seq: GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str: ... | | | | | | | || | +-+ +--+ +---+ +---++-+ |Stem 1Stem 2 Stem 3 | || ++ Stem 0 Assume that we always have 4 stems (0 to 3), but that the length of letters before and after each of them can very. The output should be something like the following list structure: list( Stem 0 opening = GCCTCGA, before Stem 1 = TA, Stem 1 = list(opening = GCTC, inside = AGTTGGGA, closing = GAGC ), between Stem 1 and 2 = G, Stem 2 = list(opening = TACGA, inside = CTGAAGA, closing = TCGTA ), between Stem 2 and 3 = AGGtC, Stem 3 = list(opening = ACCAG, inside = TTCGATC, closing = CTGGT ), After Stem 3 = , Stem 0 closing = TCC ) I don't have any experience with programming a parser, and would like advices as to what strategy to use when programming something like this (and any recommended R commands to use). What I was thinking of is to first get rid of the Stem 0, then go through the inner string with a recursive function (let's call it seperate.stem) that each time will split the string into: 1. before stem 2. opening stem 3. inside stem 4. closing stem 5. after stem Where the after stem will then be recursively entered into the same function (seperate.stem) The thing is that I am not sure how to try and do this coding without using a loop. Any advices will be most welcomed. Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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.
[R] function arguments: name of an object vs. call producing the object?
In a function, say foo.glm for glm objects I want to use the name of the object as a label for some output, but *only* if a glm object was passed as an argument, not a call to glm() producing that object. How can I distinguish these two cases? For example, I can use the following to get the name of the argument: foo.glm - function(object) { oname - as.character(sys.call())[2] oname } indep - glm(Freq ~ mental + ses, family = poisson, data = Mental) foo.glm(indep) [1] indep But in foo.glm() I want to avoid using this as oname: foo.glm(glm(formula = Freq ~ mental + ses, family = poisson, data = Mental)) [1] glm(formula = Freq ~ mental + ses, family = poisson, data = Mental) Here is Mental, if it matters. dput(Mental) structure(list(ses = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L), .Label = c(1, 2, 3, 4, 5, 6), class = c(ordered, factor)), mental = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c(Well, Mild, Moderate, Impaired), class = c(ordered, factor)), Freq = c(64L, 94L, 58L, 46L, 57L, 94L, 54L, 40L, 57L, 105L, 65L, 60L, 72L, 141L, 77L, 94L, 36L, 97L, 54L, 78L, 21L, 71L, 54L, 71L)), .Names = c(ses, mental, Freq), row.names = c(NA, -24L), class = data.frame) -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ 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] R on Linux - a primer
Axel Urbiz wrote: Hi, I'm looking to move from Windows into a 64-bit Linux environment. Which is the best Linux Flavor to use within R? To install R on this environment, do I need to do any compiling? Thanks all! Axel. You have received a number of useful replies. I will add my 2 cents as well. First, make sure the distribution you choose does have a 64 bit version, since that is what you are looking for. That said, allow me to share my Linux philosophy. There are many distributions out there, each with their pluses and minuses. For example, I used SuSE and OpenSuSE for awhile. It was good in that things worked out of the box, and it has (had?) a good sysadmin tool. The problem was, if I needed to compile stuff, the tools for development were not included in the default install, so I had to search for them (a full install may have fixed this, but the full install was really bloated). Most of the popular distributions come with some kind of sysadmin tool. This is a useful thing for someone totally new to Linux. It can be frustrating if you decide on a new distribution, since the sysadmin stuff will look different. I eventually moved away from OpenSuSE because the life cycle of supported versions was quite short. I don't like being forced to re-install a new OS just to get the latest patches. So, I moved to Slackware (they have a 64 bit version now BTW). I love it, but it's not for everybody. The biggest obstacle to most people is that it has no sysadmin tool. It is your responsibility to edit the config files in a text editor, if you want to fine-tune or customize things. It is your responsibility to do dependency checking when installing packages (this is a plus in that when you install something and something breaks, you know what to blame). This means you need to invest some time and learn a little more Linux than other distributions forces you to learn. The full install is not bloated and comes with all the development tools needed. I always compile R from source and it is easy. ./configure make su make install In closing (congratulations if you've read this far), there is probably not a wrong choice of Linux to run R on. Choose a flavour of Linux that you like. Many distributions have Live versions. These are versions that boot and run from your DVD drive. It's a good way to get a feeling for a particular distribution without installing anything. -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 __ 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 arguments: name of an object vs. call producing the object?
On 16/03/2010 8:26 AM, Michael Friendly wrote: In a function, say foo.glm for glm objects I want to use the name of the object as a label for some output, but *only* if a glm object was passed as an argument, not a call to glm() producing that object. How can I distinguish these two cases? Look at typeof(substitute(object)). For example, f - function(object) typeof(substitute(object)) f(aname) [1] symbol f(aname+1) [1] language That will tell you if an object was passed by name, or if you got an expression to produce the object. One problem with this approach is that it only looks at the direct call to f, for example g - function(x) f(x) g(aname + 1) [1] symbol because substitute looks at the f(x) call, not the g(aname + 1) call. Duncan Murdoch For example, I can use the following to get the name of the argument: foo.glm - function(object) { oname - as.character(sys.call())[2] oname } indep - glm(Freq ~ mental + ses, family = poisson, data = Mental) foo.glm(indep) [1] indep But in foo.glm() I want to avoid using this as oname: foo.glm(glm(formula = Freq ~ mental + ses, family = poisson, data = Mental)) [1] glm(formula = Freq ~ mental + ses, family = poisson, data = Mental) Here is Mental, if it matters. dput(Mental) structure(list(ses = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L), .Label = c(1, 2, 3, 4, 5, 6), class = c(ordered, factor)), mental = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c(Well, Mild, Moderate, Impaired), class = c(ordered, factor)), Freq = c(64L, 94L, 58L, 46L, 57L, 94L, 54L, 40L, 57L, 105L, 65L, 60L, 72L, 141L, 77L, 94L, 36L, 97L, 54L, 78L, 21L, 71L, 54L, 71L)), .Names = c(ses, mental, Freq), row.names = c(NA, -24L), class = data.frame) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How can I calculate the error of a fit parameter, when the data set has an error itself?
Hi out there, imagine you have a dataset (x,y) with errors f, so that each y_i is y_i +- f_i. This is the normal case for almost all measurements, that one quantity y can only be measured with a certain accuracy. x-c(1,2,3) y-c(1.1,0.8,1.3) f-c(0.2,0.2,0.2) plot(x,y) #whereas every y has the uncertainty of f If I now perform a nls-fit (and force the data through (0,0) to have only one fitting parameter) n-nls(y~a*x,start=list(a=1)) summary(n) I end up with an estimate of a of 1.4 +- 0.06 as standard error of the fit. In this case the error gives only the accuracy of the fit itself, but does not include the measurement errors in y: f (error bars). How is it possible to take them into account? I know that there is the chi-squared test, where the goodness of the fit is calculated, but again this does not include the errors itself. There should be an easy solution, since this is a common problem in science, which I haven't found yet. Any suggestions or solutions? Thanks in advance! -- Markus __ 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] R-Documentation including an image?
Dear List Members, I was wondering if there's a way to include an image in a .Rd file, something like \img{} In http://cran.r-project.org/doc/manuals/R-exts.html#Documenting-packages nothing's mentioned regarding images (besides the image of the workspace) Is there a way to include an image? Thanks in advance, Thomas -- Dipl.-Ing. Thomas Roth (geb. Kaliwe) Technische Universitaet Berlin Institut für Werkzeugmaschinen und Fabrikbetrieb (IWF) Fachgebiet Qualitaetswissenschaft Pascalstr. 8-9 10587 Berlin Tel:+49 (0) 30 / 314 23 565 e-mail: thomas.r...@tu-berlin.de Web: www.qualitaetswissenschaft.de __ 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] unknown compression
Thanks to Uwe Ligges, simply putting library(xxx) dump(ls(pos=2)),file=xxx.r) gives a file with all the 'pure R' function in a package This just solved my problem, as an added curiosity or just for completion sake, if the package 'xxx' has some C/Fortran code , ie an /lib/xxx.dll in Windows, will Rcmd INSTALL xxx work when xxx has a R; man and lib subfolders? not a src subfolder since I have the dll not the original C/for Thanks Heberto Ghezzo From: Uwe Ligges [lig...@statistik.tu-dortmund.de] Sent: Sunday, March 14, 2010 2:04 PM To: R Heberto Ghezzo, Dr Subject: Re: [R] unknown compression On 13.03.2010 22:33, R Heberto Ghezzo, Dr wrote: Hello Uwe / Rohlf Yes I know that, the problem here is that I have a package, old, it says Built: R 2.0.0; ; 2004-11-15 14:58:41; windows it is not in CRAN the author and manteiner can not be reached, so I have no way of obtaining the source tarball. The only solution is to decompress the pair .rdb .rdx if it is possible? In that case you can load the package and save all functions from that environment into a new package. The tool to load the serialized databases is lazyLoad() - or more low level lazyLoadDBfetch(), both not intended to be called by a user. Best wishes, Uwe Thanks for any help Heberto Ghezzo From: Uwe Ligges [lig...@statistik.tu-dortmund.de] Sent: Saturday, March 13, 2010 3:37 PM To: R Heberto Ghezzo, Dr Cc: r-help@r-project.org Subject: Re: [R] unknown compression On 12.03.2010 21:34, R Heberto Ghezzo, Dr wrote: Hello, I am trying to modify some functions in an existing package. I can get a function by just typing the name in the console, but how can I get all the functions in a package? the ./R/ subdirectory has files xx.rdb and xx.rdx which I can not decompress with 7-zip or with unzip, unrar etc. The help files are compressed with gzip in the ./man/ folder and can be unzipped easily. You are looking in a binary package. Instead of that, just download a source package (i.e. a not yet compiled one) from CRAN where you find the sources in plain text. Uwe Ligges Thanks for your help heberto.ghe...@mcgill.ca __ 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] G-test : log-likelihood ratio test
Dear Peter, I am running your g.test() with the william's correction but I have a question about the input numbers. These are my data: Our data are consistent with those obtained using microarray comparative genome hybridization in that we found significantly fewer variants per Mb on the X compared to the autosomal chromosomes (152 versus 336 respectively, G = 93.4, P 2e-16, df = 1), and in exons (including UTRs) compared to non-exonic regions (69 versus 392 respectively, G = 14,226, P 2e-16, df = 1). How do I have to write the input? Should I have to include any total number (in this case Mb) minus the variants? g.test(rbind(c(152,(999848)),c(336,(999664))), correct = williams) or g.test(rbind(c(152,336)), correct = williams) ? Thanks a lot for your help, Carine Carine Gubelmann, PhD student EPFL, Institute of Bioengineering Bldg. AI 1351 Station 15 CH-1015 Lausanne Phone: + 41 (0) 21 693 09 59 Fax: + 41 (0) 21 693 09 80 [[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] G-test : log-likelihood ratio test
Can you please, do not write my question on the internet server, Thanks De : Gubelmann Carine Envoyé : mardi, 16. mars 2010 13:36 À : 'r-h...@stat.math.ethz.ch' Objet : [R] G-test : log-likelihood ratio test Dear Peter, I am running your g.test() with the william's correction but I have a question about the input numbers. These are my data: Our data are consistent with those obtained using microarray comparative genome hybridization in that we found significantly fewer variants per Mb on the X compared to the autosomal chromosomes (152 versus 336 respectively, G = 93.4, P 2e-16, df = 1), and in exons (including UTRs) compared to non-exonic regions (69 versus 392 respectively, G = 14,226, P 2e-16, df = 1). How do I have to write the input? Should I have to include any total number (in this case Mb) minus the variants? g.test(rbind(c(152,(999848)),c(336,(999664))), correct = williams) or g.test(rbind(c(152,336)), correct = williams) ? Thanks a lot for your help, Carine [[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] R Training
Hi all, There are still places available on the following courses. For more detailed information and a registration form please contact: train...@mango-solutions.com or visit our website at www.mango-solutions.com. * Introduction to R: 6th - 7th April, Birmingham UK * R for Actuaries: 20th - 21st April, Frankfurt Germany * R for Pharmacometrics: 4th - 5th May, New Jersey USA * R for Actuaries: 10th - 11th May, London UK * Introduction to R: 17th - 18th May, Basel Switzerland * Introduction to R: 20th - 21st May, New York USA * R for Pharmacometrics at Page: 7th - 8th June, Berlin Germany * Advanced R Programming: 29th - 30th June, London UK * R Graphics: 6th - 7th July, London UK At Mango we provide a combination of both standard and customised training courses to a wide range of audiences across the world, to help kick-start or enhance your R programming abilities. Training courses can be customised to use your own data, helping to ensure the training is immediately relevant to the day to day work of the attendees. In order to ensure the quality of training consistently meets our standards, we have to limit the number of attendees. Private courses are also available utilising your own data customised to your own business requirements. As part of the course development we produce tailored documentation for users to keep and use as a reference. We also offer a technical helpdesk ability for attendees to use after the course to ask those questions that always seem to occur after the trainer has left the building, thus ensuring that the learning process becomes an iterative process and allowing attendees to utilize the skills learnt at their normal work. Prices, booking forms and further information can be accessed by emailing train...@mango-solutions.com Many thanks Sarah Lewis mangosolutions T: +44 (0)1249 767700 F: +44 (0)1249 767707 Unit 2 Greenways Business Park Bellinger Close Chippenham Wilts SN15 1BN UK LEGAL NOTICE \ This message is intended for the use of...{{dropped:14}} __ 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] boxplot, vertical position of x-axis labels
hello, i can't figure out how to change the vertical position of my x axis labels.. boxplot(c(1:12)~c(rep(1,6),rep(2,6)),at=c(1,2), col=c(0,grey),las=1,xaxt=n) ### i put paragraphs in the x-labels because of limited horizontal space axis(1,at=c(1,2),adj=1,labels=c(Salix Scrub,Tall Forb)) ...the labels are one line above usual position and cross the tickmarks and i don't know how to get around this. can anyone help with this? thanks in advance. kay -- View this message in context: http://n4.nabble.com/boxplot-vertical-position-of-x-axis-labels-tp1594857p1594857.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.
Re: [R] R-Documentation including an image?
Roth, Thomas wrote: I was wondering if there's a way to include an image in a .Rd file, something like \img{} Not yet, but it has been on the top wish list since years now, and there is hope. Dieter -- View this message in context: http://n4.nabble.com/R-Documentation-including-an-image-tp1594853p1594856.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.
Re: [R] R-Documentation including an image?
On 16/03/2010 9:26 AM, Roth, Thomas wrote: Dear List Members, I was wondering if there's a way to include an image in a .Rd file, something like \img{} In http://cran.r-project.org/doc/manuals/R-exts.html#Documenting-packages nothing's mentioned regarding images (besides the image of the workspace) Is there a way to include an image? Not currently. That's an improvement that may eventually come, but it won't make 2.11.x. Duncan Murdoch __ 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 parse a string (by a new markup) with R ?
Hi Jim, Thanks for the questions, here are my answers: *Q: Does each sequence have the same number of for the opening sequence as it does for on the ending sequence? * A: Yes *Q: Does the parsing always start with a partial stem 0 as your example shows? * A: No. Sometimes it will start with a few . *Q: Is there a way of making sure you have the right sequences when you start? * A: I am not sure I understand what you mean. *Q: Is there a chance of error in the middle of the string that you have to restart from?* A: Sadly, yes. In which case, I'll need to ignore one of the inner stems... *Q: How long are these strings that you want to parse? * A: Each string has between 60 to 150 characters (and I have tens of thousands of them...) *Q: Is each one a self contained sequence like you show in your example, or do they go on for thousands of characters? * A: each sequence is self contained. *Q: Is there always at least one '.' between stems? * A: No. *Q: A full set of rules as to how the parsing should be done would be useful.* A: I agree. But since I don't have even a basic idea on how to start coding this, I thought first to have some help on the beginning and try to tweak with the other cases that will come up before turning back for help. *Q: Do you have the BNF syntax for parsing?* A: No. Your e-mail is the first time I came across it ( http://en.wikipedia.org/wiki/BackusNaur_Formhttp://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form ). Thanks for the help, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Tue, Mar 16, 2010 at 1:59 PM, jim holtman jholt...@gmail.com wrote: How are you supposed to interprete the string that is doing the parsing? Does each sequence have the same number of for the opening sequence as it does for on the ending sequence? That what it appears to be looking at the way stem 3 is parsed. You will have to provide a little more insight on how to interprete the symbols. Does the parsing always start with a partial stem 0 as your example shows? Is there a way of making sure you have the right sequences when you start? Is there a chance of error in the middle of the string that you have to restart from? How long are these strings that you want to parse? Is each one a self contained sequence like you show in your example, or do they go on for thousands of characters? Is there always at least one '.' between stems? A full set of rules as to how the parsing should be done would be useful. Do you have the BNF syntax for parsing? On Tue, Mar 16, 2010 at 6:10 AM, Tal Galili tal.gal...@gmail.com wrote: Hello all, For some work I am doing on RNA, I want to use R to do string parsing that (I think) is like a simplistic HTML parsing. For example, let's say we have the following two variables: Seq - GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str - ... Say that I want to parse Seq According to Str, by using the legend here Seq: GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str: ... | | | | | | | || | +-+ +--+ +---+ +---++-+ |Stem 1Stem 2 Stem 3 | || ++ Stem 0 Assume that we always have 4 stems (0 to 3), but that the length of letters before and after each of them can very. The output should be something like the following list structure: list( Stem 0 opening = GCCTCGA, before Stem 1 = TA, Stem 1 = list(opening = GCTC, inside = AGTTGGGA, closing = GAGC ), between Stem 1 and 2 = G, Stem 2 = list(opening = TACGA, inside = CTGAAGA, closing = TCGTA ), between Stem 2 and 3 = AGGtC, Stem 3 = list(opening = ACCAG, inside = TTCGATC, closing = CTGGT ), After Stem 3 = , Stem 0 closing = TCC ) I don't have any experience with programming a parser, and would like advices as to what strategy to use when programming something like this (and any recommended R commands to use). What I was thinking of is to first get rid of the Stem 0, then go through the inner string with a recursive function (let's call it seperate.stem) that each time will split the string into: 1. before stem 2. opening stem 3. inside stem 4. closing stem 5. after stem Where the after stem will then be
[R] passing columns of tables as a variable to functions
hello! ive come across the following problem: im writing a function to ease the production of maps. as my tables have headers, id like to include an option in my function header to pass these columns to use them inside the evaluation block. the function looks as follows: # maptable #the name of the table containing coordinates and columns for measured values # value: which column of my table to use (e.g. Alt, slope, us, etc... # labels(maptable) # [1] pos.e pos.n Alt slope us uus lc make.map-function (maptable,value) { pos.e-maptable$pos.e #calling the column directly works pos.n-maptable$pos.n #calling the column directly works key-maptable$value #this doesnt work. output: NULL ... rest of function, irrelevant to my question } for example, i call the function by: make.map(elevation,Alt,Altitude,Sightings) and my interp from akima package denies work, since key is NULL interp(pos.e,pos.n,key,...) have i just missed something? ive browsed the help pages and the archive, looked into crawleys R book but didnt find any solution, though im pretty sure this should be achievable! __ 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] Loading workspaces from the command line
It is a promising solution. Yet, there is room for improvement. I revise the if condition so it won't throw an error during ordinary startup. .First - function() { if (length(commandArgs(T))0 commandArgs(T)[1] == ld){ load(commandArgs(T)[-1], .GlobalEnv) } } For the Rload script, it should be: gnome-terminal --command R --args ld '$1' Note the single quotation of $1. Without it, it does not work if the file name contains space. HTH Best Ronggui On 12 January 2009 23:45, Zhou Fang zhou.zf...@gmail.com wrote: Well, that isn't ideal for my purposes. (A little context - basically I have a script that I'm running for a lot of simulations, which is kinda buggy, and what I'm doing is I'm having the script periodically save whatever it has done so far to an automatically named file. Then if something odd happens in between two saves, I can run forward from a previously saved point to find the problem and figure out why it happened, and also I won't risk losing everything if something catastrophic happens.) Anyways, if anyone's interested, in .Rprofile .First - function(){ if (rev(commandArgs())[2] == ld){ load(rev(commandArgs())[1], .GlobalEnv) } } Then e.g. alias Rload='R --arg ld' or make a bash script with gnome-terminal --command R --args ld $1 and set some Open With options, and you'll be about to open R workspaces from Nautilus etc by point and click. Zhou On Mon, Jan 12, 2009 at 3:14 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Another possibility is to have a separate directory for each project and place an .RData file in each. Now just cd to whatever directory corresponds to the project you wish to work on and start R normally. No code is needed. On Mon, Jan 12, 2009 at 10:04 AM, Zhou Fang zhou.zf...@gmail.com wrote: Ok, looks like I can do what I want with --args, commandArgs() and an appropiate .First. Thanks, Zhou On Mon, Jan 12, 2009 at 2:27 PM, David Winsemius dwinsem...@comcast.net wrote: See if this material is helpful: http://cran.r-project.org/doc/manuals/R-intro.html#Invoking-R-from-the-command-line -- David Winsemius On Jan 12, 2009, at 7:24 AM, Zhou Fang wrote: That's not really what I meant by 'command line'. I meant, well, loading from e.g. a bash shell, not from within an interactive R session itself. Thanks anyways, Zhou (Possibly this email was sent twice. Apologies) On Mon, Jan 12, 2009 at 12:15 PM, Henrique Dallazuanna www...@gmail.com wrote: See ?load On Mon, Jan 12, 2009 at 10:12 AM, Zhou Fang zhou.zf...@gmail.com wrote: Hi, Is there any way to load workspaces (e.g. stuff from save.image) from the command line? I'm on Linux, and would find this very helpful. I'm guessing this functionality can be duplicated with a skillful bash script to rename the particular file to .RData (and then back once R terminates), but I'm wondering if there's a better way. Zhou Fang __ 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ 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. -- Wincent Ronggui HUANG Doctoral Candidate Dept of Public and Social Administration City University of Hong Kong 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] How to parse a string (by a new markup) with R ?
We show how to use the gsubfn package to parse this. The rules are not entirely clear so we will assume the following: - there is a fixed template for the output which is the same as your output but possibly with different character strings filled in. This implies, for example, that there are exactly Stem0, Stem1, Stem2 and Stem3 and no fewer or more stems. - the sequence always starts with the open of Stem0, at least one dot and the open of Stem1. There are no dots prior to the open of Stem0. This seems to be implicit in your sample output since there is no zero length string in your sample output corresponding to dots prior to Stem0. - Stem0 closes with the same number of as there are to open it You can modify this yourself to take into account the actual rules whatever they are. We first calculate, k, the number of leading 's using strapply. Then we replace the leading k 's with }'s and the trailing k 's with {'s giving us Str3: }}}..{{{. We again use strapply, this time to get the lengths of the runs. Note that zero length runs are possible so we cannot, for example, use rle for this. For example there is a zero length run of dots between the last and the first {. read.fwf is used to actually parse out the strings using the lengths we just calculated. Finally we fill in the template using relist. # inputs Seq - GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str - ... template - list( Stem 0 opening = , before Stem 1 = , Stem 1 = list(opening = , inside = , closing = ), between Stem 1 and 2 = , Stem 2 = list(opening = , inside = , closing = ), between Stem 2 and 3 = , Stem 3 = list(opening = , inside = , closing = ), After Stem 3 = , Stem 0 closing = ) # processing # create string made by repeating string s k times followed by more reps - function(s, k, more = ) { paste(paste(rep(s, k), collapse = ), more, sep = ) } library(gsubfn) k - nchar(strapply(Str, ^+, c)[[1]]) Str2 - sub(^+, reps(}, k), Str) Str3 - sub(reps(, k, ([^]*)$), reps({, k, \\1), Str2) pat - ^(}*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)({*)([.]*)$ lens - sapply(strapply(Str3, pat, c)[[1]], nchar) tokens - unlist(read.fwf(textConnection(Seq), lens, as.is = TRUE)) closeAllConnections() tokens[is.na(tokens)] - out - relist(tokens, template) out Here is the str of the output for your sample input: str(out) List of 9 $ Stem 0 opening : chr GCCTCGA $ before Stem 1 : chr TA $ Stem 1 :List of 3 ..$ opening: chr GCTC ..$ inside : chr AGTTGGGA ..$ closing: chr GAGC $ between Stem 1 and 2: chr G $ Stem 2 :List of 3 ..$ opening: chr TACGA ..$ inside : chr CTGAAGA ..$ closing: chr TCGTA $ between Stem 2 and 3: chr AGGtC $ Stem 3 :List of 3 ..$ opening: chr ACCAG ..$ inside : chr TTCGATC ..$ closing: chr CTGGT $ After Stem 3: chr $ Stem 0 closing : chr TCC On Tue, Mar 16, 2010 at 6:10 AM, Tal Galili tal.gal...@gmail.com wrote: Hello all, For some work I am doing on RNA, I want to use R to do string parsing that (I think) is like a simplistic HTML parsing. For example, let's say we have the following two variables: Seq - GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str - ... Say that I want to parse Seq According to Str, by using the legend here Seq: GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str: ... | | | | | | | || | +-+ +--+ +---+ +---++-+ | Stem 1 Stem 2 Stem 3 | | | ++ Stem 0 Assume that we always have 4 stems (0 to 3), but that the length of letters before and after each of them can very. The output should be something like the following list structure: list( Stem 0 opening = GCCTCGA, before Stem 1 = TA, Stem 1 = list(opening = GCTC, inside = AGTTGGGA, closing = GAGC ), between Stem 1 and 2 = G, Stem 2 = list(opening = TACGA, inside = CTGAAGA, closing = TCGTA ), between Stem 2 and 3 = AGGtC, Stem 3 = list(opening = ACCAG, inside = TTCGATC, closing = CTGGT ), After Stem 3 = , Stem 0 closing = TCC ) I don't have any experience with programming a parser, and would like advices as to what strategy to use when programming something like this (and any recommended R commands to use). What I was thinking of is to first get rid of the Stem 0,
Re: [R] boxplot, vertical position of x-axis labels
On Mar 16, 2010, at 9:37 AM, Kay Cichini wrote: hello, i can't figure out how to change the vertical position of my x axis labels.. boxplot(c(1:12)~c(rep(1,6),rep(2,6)),at=c(1,2), col=c(0,grey),las=1,xaxt=n) ### i put paragraphs in the x-labels because of limited horizontal space ?axis Try using the padj argument (and it bothered me to use the cr's rather than \n, so I modified the labels argument as well): axis(1,at=c(1,2),adj=1,padj=0.5,labels=c(Salix\nScrub,Tall\nForb)) ...the labels are one line above usual position and cross the tickmarks and i don't know how to get around this. can anyone help with this? thanks in advance. -- David Winsemius, MD West Hartford, CT __ 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] Odp: boxplot, vertical position of x-axis labels
Hi r-help-boun...@r-project.org napsal dne 16.03.2010 14:37:01: hello, i can't figure out how to change the vertical position of my x axis labels.. boxplot(c(1:12)~c(rep(1,6),rep(2,6)),at=c(1,2), col=c(0,grey),las=1,xaxt=n) ### i put paragraphs in the x-labels because of limited horizontal space axis(1,at=c(1,2),adj=1,labels=c(Salix Scrub,Tall Forb)) ...the labels are one line above usual position and cross the tickmarks and i don't know how to get around this. Not sure if it is the only way but # first put only labels axis(1,at=c(1,2),adj=1, tick=F, line=2,labels=c(Salix Scrub,Tall Forb)) # add axis without labels axis(1,at=c(1,2),adj=1, tick=T,labels=c(NA, NA)) Regards Petr can anyone help with this? thanks in advance. kay -- View this message in context: http://n4.nabble.com/boxplot-vertical-position- of-x-axis-labels-tp1594857p1594857.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-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] remove substring from each string vector component
Hi all, I have a string vector like that: x=c(1\t\t, 2, 3\t\t\t) I need to remove all the occurrences of \t, in order to obtain: x = 1 2 3 I'm trying to use the function substring2, and it works for each component, for example: substring2(x[1], \t) = gives x = 1 23\t\t\t I'd like to apply this function to each component and I tried the following: myfun = function(x, i) { substring2(x[i], \t) = } lapply(x, myfun) which gives x= I know that I'm wrong somewhere using lapply, but I can't fix it. Thanks in advance, Arnaud Chozo [[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] Problem in installing ncdf package
On 16.03.2010 07:06, BabyL BabyK wrote: Dear R communities Could you please help me with the problem I encounter while trying to install the ncdf package? download.packages(ncdf, /home/user/soft/R/library/) cd /home/user/soft/R/library R CMD INSTALL ncdf_1.6.tar.gz # fail sudo R CMD INSTALL ncdf_1.6.tar.gz # fail cd /home/user/soft/ # download http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.0.1.tar.gz tar -xzvf netcdf-4.0.1.tar.gz R CMD INSTALL --configure-args=-with-netcdf_incdir=/home/user/soft/netcdf-4.0.1/libsrc -with-netcdf_libdir=/home/user/soft/netcdf-4.0.1/libsrc/ ncdf_1.6.tar.gz # Error: user specified netCDF library directory does not have libnetcdf.a ! You need to install netcdf first, then specify the include and libdir (the later will contain the lib afterwards). Uwe Ligges Thank you very much for your kind help. [[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] passing columns of tables as a variable to functions
Sacha - The $ notation can only be used when you literally use the name of the column you want. If the name of the column is stored in a variable, you should use this notation: maptable[,value] to refer to the column whose name is stored in value. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Tue, 16 Mar 2010, Sacha Viquerat wrote: hello! ive come across the following problem: im writing a function to ease the production of maps. as my tables have headers, id like to include an option in my function header to pass these columns to use them inside the evaluation block. the function looks as follows: # maptable #the name of the table containing coordinates and columns for measured values # value: which column of my table to use (e.g. Alt, slope, us, etc... # labels(maptable) # [1] pos.e pos.n Alt slope us uus lc make.map-function (maptable,value) { pos.e-maptable$pos.e #calling the column directly works pos.n-maptable$pos.n #calling the column directly works key-maptable$value #this doesnt work. output: NULL ... rest of function, irrelevant to my question } for example, i call the function by: make.map(elevation,Alt,Altitude,Sightings) and my interp from akima package denies work, since key is NULL interp(pos.e,pos.n,key,...) have i just missed something? ive browsed the help pages and the archive, looked into crawleys R book but didnt find any solution, though im pretty sure this should be achievable! __ 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] remove substring from each string vector component
Hi Arnaud, how about this: x=c(1\t\t, 2, 3\t\t\t) gsub(\t,,x) hth. arnaud chozo schrieb: Hi all, I have a string vector like that: x=c(1\t\t, 2, 3\t\t\t) I need to remove all the occurrences of \t, in order to obtain: x = 1 2 3 I'm trying to use the function substring2, and it works for each component, for example: substring2(x[1], \t) = gives x = 1 23\t\t\t I'd like to apply this function to each component and I tried the following: myfun = function(x, i) { substring2(x[i], \t) = } lapply(x, myfun) which gives x= I know that I'm wrong somewhere using lapply, but I can't fix it. Thanks in advance, Arnaud Chozo [[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. -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 __ 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] heatmap.2 - ColSideColors question
Hi, I wanted to make more than one side color bar. For example, I can make one side color bar (col1) with the following code: --- library(gplots) mat - matrix(sample(1:100,40),nrow=5) class1 - c(rep(0,4),rep(1,4)) col1 - ifelse(class1 == 0,blue,red) class2 - c(rep(1,3),rep(2,5)) col2 - ifelse(class2 == 0,yellow,green) heatmap.2(mat,col=greenred(75),ColSideColors=col1,trace=none, dendrogram = column,labCol = NULL) --- How can I modify the code so that both col1 col2 are displayed in the heatmap? thanks! [[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 variable in the file
Hi user's I'm learning how to use R and I have a problem with the format file. How do I to write in a file? I have some variables which I would like to write in a file.  Att. Marize Simões __ 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] heatmap.2 - ColSideColors question
On 03/16/2010 04:06 PM, Tim Smith wrote: Hi, I wanted to make more than one side color bar. The function heatmap.plus (library: heatmap.plus) can do that, just combine the different color vectors with cbind(col1,col2). Unfortunately the arguments required for heatmap, heatmap.2 and heatmap.plus are slightly different. r For example, I can make one side color bar (col1) with the following code: --- library(gplots) mat - matrix(sample(1:100,40),nrow=5) class1 - c(rep(0,4),rep(1,4)) col1 - ifelse(class1 == 0,blue,red) class2 - c(rep(1,3),rep(2,5)) col2 - ifelse(class2 == 0,yellow,green) heatmap.2(mat,col=greenred(75),ColSideColors=col1,trace=none, dendrogram = column,labCol = NULL) --- How can I modify the code so that both col1 col2 are displayed in the heatmap? thanks! [[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] remove substring from each string vector component
Hi! It's just this easy: x=gsub(\t,,x) For more complex things, it's worth learning some regular expressions syntax. Miguel On Tue, Mar 16, 2010 at 2:50 PM, arnaud chozo arnaud.ch...@gmail.comwrote: Hi all, I have a string vector like that: x=c(1\t\t, 2, 3\t\t\t) I need to remove all the occurrences of \t, in order to obtain: x = 1 2 3 I'm trying to use the function substring2, and it works for each component, for example: substring2(x[1], \t) = gives x = 1 23\t\t\t I'd like to apply this function to each component and I tried the following: myfun = function(x, i) { substring2(x[i], \t) = } lapply(x, myfun) which gives x= I know that I'm wrong somewhere using lapply, but I can't fix it. Thanks in advance, Arnaud Chozo [[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.
Re: [R] Save variable in the file
Dear Marize, It depends a bit on what format you would like to write your data as and what your goals are. Try looking at ?save ?write.table save() will save objects as an R data file, write.table() will write tables to a file, you can specify the delimiter (e.g., , for commas, \t for tab, etc.). What kind of file are you hoping to write to? Best regards, Josh On Tue, Mar 16, 2010 at 8:15 AM, rizesimoes rizesim...@uol.com.br wrote: Hi user's I'm learning how to use R and I have a problem with the format file. How do I to write in a file? I have some variables which I would like to write in a file.  Att. Marize Simões __ 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. -- Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.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] aggregate without removing empty subset
As I told you in private, thanks, it works perfectly. More precisely, I am working with 3D array. Your code works well (both on matrix or on array). But when part is a factor with only one value, the result has not a correct dimension (vector if m is a matrix, a matrix if m is an array). Any way to fix that ? m1 - matrix(1:12,4) m2 - array(1:24,dim=c(4,3,2)) part1 - factor(c(A,B,A,B),levels=c(A,B,C)) part2 - factor(c(A,A,A,A),levels=c(A)) apply(m1, 2, tapply, part1, mean) ##Perfect (dim=c(3,3)) apply(m1, 2, tapply, part2, mean) ## dim=NULL... apply(m2, c(2,3), tapply, part1, mean) ## Perfect (dim=c(3,3,2)) apply(m2, c(2,3), tapply, part2, mean) ## dim=c(3,2) Christophe Try this: apply(m, 2, tapply, part, mean) On Mon, Mar 15, 2010 at 2:10 PM, Christophe Genolini cgeno...@u-paris10.fr wrote: Hi the list, As it is say in its doc, the aggregate function remove empty subsets. Is it possible to NOT remove empty subset ? --- 8 --- m - matrix(1:12,4) part - factor(c(A,B,A,B),levels=c(A,B,C)) aggregate(m,list(part),mean) ### I get: # Group.1 V1 V2 V3 # 1 A 2 6 10 # 2 B 3 7 11 # ### I would like: # Group.1 V1 V2 V3 # 1 A 2 6 10 # 2 B 3 7 11 # 3 C NA NA NA --- 8 -- Thanks Christophe __ 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] remove substring from each string vector component
On Mar 16, 2010, at 9:50 AM, arnaud chozo wrote: Hi all, I have a string vector like that: x=c(1\t\t, 2, 3\t\t\t) I need to remove all the occurrences of \t, in order to obtain: x = 1 2 3 I'm trying to use the function substring2, and it works for each component, for example: substring2(x[1], \t) = gives x = 1 23\t\t\t I'd like to apply this function to each component and I tried the following: myfun = function(x, i) { substring2(x[i], \t) = } lapply(x, myfun) which gives x= I know that I'm wrong somewhere using lapply, but I can't fix it. Thanks in advance, Arnaud Chozo This is a place to use regular expressions with gsub(): x - c(1\t\t, 2, 3\t\t\t) gsub(\\t, , x) [1] 1 2 3 See ?regex and ?gsub Note that you have to double the backslashes in the regex. 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 provide commented, minimal, self-contained, reproducible code.
Re: [R] How to parse a string (by a new markup) with R ?
Gabor, Thank you very very much! Your code consists of so many commands I never played with, both helpful and educational. Thanks! Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Tue, Mar 16, 2010 at 4:24 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: We show how to use the gsubfn package to parse this. The rules are not entirely clear so we will assume the following: - there is a fixed template for the output which is the same as your output but possibly with different character strings filled in. This implies, for example, that there are exactly Stem0, Stem1, Stem2 and Stem3 and no fewer or more stems. - the sequence always starts with the open of Stem0, at least one dot and the open of Stem1. There are no dots prior to the open of Stem0. This seems to be implicit in your sample output since there is no zero length string in your sample output corresponding to dots prior to Stem0. - Stem0 closes with the same number of as there are to open it You can modify this yourself to take into account the actual rules whatever they are. We first calculate, k, the number of leading 's using strapply. Then we replace the leading k 's with }'s and the trailing k 's with {'s giving us Str3: }}}..{{{. We again use strapply, this time to get the lengths of the runs. Note that zero length runs are possible so we cannot, for example, use rle for this. For example there is a zero length run of dots between the last and the first {. read.fwf is used to actually parse out the strings using the lengths we just calculated. Finally we fill in the template using relist. # inputs Seq - GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str - ... template - list( Stem 0 opening = , before Stem 1 = , Stem 1 = list(opening = , inside = , closing = ), between Stem 1 and 2 = , Stem 2 = list(opening = , inside = , closing = ), between Stem 2 and 3 = , Stem 3 = list(opening = , inside = , closing = ), After Stem 3 = , Stem 0 closing = ) # processing # create string made by repeating string s k times followed by more reps - function(s, k, more = ) { paste(paste(rep(s, k), collapse = ), more, sep = ) } library(gsubfn) k - nchar(strapply(Str, ^+, c)[[1]]) Str2 - sub(^+, reps(}, k), Str) Str3 - sub(reps(, k, ([^]*)$), reps({, k, \\1), Str2) pat - ^(}*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)({*)([.]*)$ lens - sapply(strapply(Str3, pat, c)[[1]], nchar) tokens - unlist(read.fwf(textConnection(Seq), lens, as.is = TRUE)) closeAllConnections() tokens[is.na(tokens)] - out - relist(tokens, template) out Here is the str of the output for your sample input: str(out) List of 9 $ Stem 0 opening : chr GCCTCGA $ before Stem 1 : chr TA $ Stem 1 :List of 3 ..$ opening: chr GCTC ..$ inside : chr AGTTGGGA ..$ closing: chr GAGC $ between Stem 1 and 2: chr G $ Stem 2 :List of 3 ..$ opening: chr TACGA ..$ inside : chr CTGAAGA ..$ closing: chr TCGTA $ between Stem 2 and 3: chr AGGtC $ Stem 3 :List of 3 ..$ opening: chr ACCAG ..$ inside : chr TTCGATC ..$ closing: chr CTGGT $ After Stem 3: chr $ Stem 0 closing : chr TCC On Tue, Mar 16, 2010 at 6:10 AM, Tal Galili tal.gal...@gmail.com wrote: Hello all, For some work I am doing on RNA, I want to use R to do string parsing that (I think) is like a simplistic HTML parsing. For example, let's say we have the following two variables: Seq - GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str - ... Say that I want to parse Seq According to Str, by using the legend here Seq: GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCCA Str: ... | | | | | | | || | +-+ +--+ +---+ +---++-+ |Stem 1Stem 2 Stem 3 | || ++ Stem 0 Assume that we always have 4 stems (0 to 3), but that the length of letters before and after each of them can very. The output should be something like the following list structure: list( Stem 0 opening =
Re: [R] R-Documentation including an image?
Thank you for the info, I couldn't find anything in the documentation and wasn't sure ut now I know for sure. -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Dieter Menne Gesendet: Dienstag, 16. März 2010 14:36 An: r-help@r-project.org Betreff: Re: [R] R-Documentation including an image? Roth, Thomas wrote: I was wondering if there's a way to include an image in a .Rd file, something like \img{} Not yet, but it has been on the top wish list since years now, and there is hope. Dieter -- View this message in context: http://n4.nabble.com/R-Documentation-including-an-image-tp1594853p1594856.ht ml 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-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] memory failure in adonis function (permanova)
Dear all, I am trying to get a PERMANOVA with quite large data set. I am reading a lot about this question, but I do not get the answer about it. Although I know that the R function is adonis () (vegan package), it does not work: adonis(Pha.env~SPha, data=Pha, permutations=10) The error message: Error: cannot allocate vector of size 334.2 Mb In addition: Warning messages: 1: In vegdist(lhs, method = method, ...) : Reached total allocation of 1535Mb: see help(memory.size) 2: In vegdist(lhs, method = method, ...) : Reached total allocation of 1535Mb: see help(memory.size) 3: In vegdist(lhs, method = method, ...) : Reached total allocation of 1535Mb: see help(memory.size) 4: In vegdist(lhs, method = method, ...) : Reached total allocation of 1535Mb: see help(memory.size) When I have received this message from R usually it is due to an incorrect introduction of the function elements (i.e., memory message errors). However, I've just checked my matrix (Pha.env is a data.frame with num or int variables, and, Pha is a data.frame with factor variables) and the length of matrices is the same. I know that I'm wrong somewhere specifying the matrices in adonis(), but I can't fix it. Thanks in advance, Paloma [[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] function arguments: name of an object vs. call producing the object?
Thanks, Duncan In my context, the following gives me what I want: foo.glm - function(object) { + if (typeof(substitute(object))==symbol) + oname - as.character(sys.call())[2] + else oname - NULL + oname + } indep - glm(Freq ~ mental + ses, family = poisson, data = Mental) foo.glm(indep) [1] indep foo.glm(glm(formula = Freq ~ mental + ses, family = poisson, data = Mental)) NULL Duncan Murdoch wrote: On 16/03/2010 8:26 AM, Michael Friendly wrote: In a function, say foo.glm for glm objects I want to use the name of the object as a label for some output, but *only* if a glm object was passed as an argument, not a call to glm() producing that object. How can I distinguish these two cases? Look at typeof(substitute(object)). For example, f - function(object) typeof(substitute(object)) f(aname) [1] symbol f(aname+1) [1] language That will tell you if an object was passed by name, or if you got an expression to produce the object. One problem with this approach is that it only looks at the direct call to f, for example g - function(x) f(x) g(aname + 1) [1] symbol because substitute looks at the f(x) call, not the g(aname + 1) call. Duncan Murdoch For example, I can use the following to get the name of the argument: foo.glm - function(object) { oname - as.character(sys.call())[2] oname } indep - glm(Freq ~ mental + ses, family = poisson, data = Mental) foo.glm(indep) [1] indep But in foo.glm() I want to avoid using this as oname: foo.glm(glm(formula = Freq ~ mental + ses, family = poisson, data = Mental)) [1] glm(formula = Freq ~ mental + ses, family = poisson, data = Mental) Here is Mental, if it matters. dput(Mental) structure(list(ses = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L), .Label = c(1, 2, 3, 4, 5, 6), class = c(ordered, factor)), mental = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c(Well, Mild, Moderate, Impaired), class = c(ordered, factor)), Freq = c(64L, 94L, 58L, 46L, 57L, 94L, 54L, 40L, 57L, 105L, 65L, 60L, 72L, 141L, 77L, 94L, 36L, 97L, 54L, 78L, 21L, 71L, 54L, 71L)), .Names = c(ses, mental, Freq), row.names = c(NA, -24L), class = data.frame) -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ 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 arguments: name of an object vs. call producing theobject?
Michael: Well, several possibilities come to mind, but their appropriateness depends on what your argument could be. 1) The deparse(substitute(...)) construction will get you the character string that was used as the argument and you can grep for ~ in it. 2) Or maybe check the class of the argument (e.g. if it's a formula it will inherit from formula). 3) Or create separate (S3) methods foo.glm, foo.formula, etc. for the different classes that you wish to consider. This might be the cleanest approach, but it requires more planning. HTH Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Friendly Sent: Tuesday, March 16, 2010 5:27 AM To: R-Help Subject: [R] function arguments: name of an object vs. call producing theobject? In a function, say foo.glm for glm objects I want to use the name of the object as a label for some output, but *only* if a glm object was passed as an argument, not a call to glm() producing that object. How can I distinguish these two cases? For example, I can use the following to get the name of the argument: foo.glm - function(object) { oname - as.character(sys.call())[2] oname } indep - glm(Freq ~ mental + ses, family = poisson, data = Mental) foo.glm(indep) [1] indep But in foo.glm() I want to avoid using this as oname: foo.glm(glm(formula = Freq ~ mental + ses, family = poisson, data = Mental)) [1] glm(formula = Freq ~ mental + ses, family = poisson, data = Mental) Here is Mental, if it matters. dput(Mental) structure(list(ses = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L), .Label = c(1, 2, 3, 4, 5, 6), class = c(ordered, factor)), mental = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c(Well, Mild, Moderate, Impaired), class = c(ordered, factor)), Freq = c(64L, 94L, 58L, 46L, 57L, 94L, 54L, 40L, 57L, 105L, 65L, 60L, 72L, 141L, 77L, 94L, 36L, 97L, 54L, 78L, 21L, 71L, 54L, 71L)), .Names = c(ses, mental, Freq), row.names = c(NA, -24L), class = data.frame) -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ 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] Help with calculating entropy of data
mnstn wrote: Hello All, My question is not directly related to R but rather on which statistical method I should look in to for capturing the entropy of a data-set as a number. In this figure http://www.twitpic.com/18sob5 are two data sets blue and green (x-axis is time) that fluctuate between (-1,+1). Clearly, green has 4 jumps while blue has 1 (and a some?). Intuitively, green has more entropy than blue. Is there a robust statistical quantity that can capture their relative flexibilities? Additionally I am hoping this method will differentiate between two cases where both spend 50% of time in each of the states -1 and +1 but one has more jumps than the other. I am guessing the limits of that quantity are 0 (no change) and N-1 (for N time steps). Sigma( mod(value(t)-value(t-1))/2 )? I am just thinking out loud here. I have about 200 such plots and I would like to arrange them in order of their entropy. Thanks and I sincerely apologize if you feel this is not the right place to ask this question. MoonStone Google information theory and entropy, and you'll find lots of stuff. If memory serves me, Henri Theil's book, Economics and Information Theory, has a good discussion of this kind of stuff. Marsh Feldman -- View this message in context: http://n4.nabble.com/Help-with-calculating-entropy-of-data-tp1593954p1595156.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] nested looping functions and dataframes
Hey All, So, I am confused how exactly to use nesting loop functions in R to spit out data frames. I've managed to create a working function for my data set that generates a data frame for a given set of Year i and Location j; but how would I do it for all Years and Locations? Here is my working function: test-function(i,j){ a-x[which(x$Year==i x$Location==j),] b-as.data.frame(as.matrix(table(a$Species,a$Species))) c-b[-which(b$Var1==b$Var2),-3] c$Year-i; c$Location-j return(c) } Where, x is a dataframe that looks like the following: head(x,n=20) Year LocationSpecies 66 1998 PIPE_7 ACMI2 67 1998 PIPE_7 AMAR2 68 1998 PIPE_7 AMCA6 69 1998 PIPE_7 ANCY 70 1998 PIPE_7 ASVE 71 1998 PIPE_7 BOCU 72 1998 PIPE_7 CIFL 73 1998 PIPE_7 DAPU5 74 1998 PIPE_7 DICHANTHEL 75 1998 PIPE_7 GABO2 76 1998 PIPE_7 HEHE5 77 1998 PIPE_7 LIAS 78 1998 PIPE_7 LIPY 79 1998 PIPE_7 PAVI2 80 1998 PIPE_7 PHPI 81 1998 PIPE_7 PHVI5 82 1998 PIPE_7 RAPI 83 1998 PIPE_7 SOCA6 84 1998 PIPE_7 VIPE2 85 1998 PIPE_7 ZIAU and when feeding x into my function test with the parameters i = 1998 and j = PIPE_7, I get the following dataframe, c: head(test(1998,PIPE_7),n=20) Var1 Var2 Year Location 2 AMAR2 ACMI2 1998 PIPE_7 3 AMCA6 ACMI2 1998 PIPE_7 4ANCY ACMI2 1998 PIPE_7 5ASVE ACMI2 1998 PIPE_7 6BOCU ACMI2 1998 PIPE_7 7CIFL ACMI2 1998 PIPE_7 8 DAPU5 ACMI2 1998 PIPE_7 9 DICHANTHEL ACMI2 1998 PIPE_7 10 GABO2 ACMI2 1998 PIPE_7 11 HEHE5 ACMI2 1998 PIPE_7 12 LIAS ACMI2 1998 PIPE_7 13 LIPY ACMI2 1998 PIPE_7 14 PAVI2 ACMI2 1998 PIPE_7 15 PHPI ACMI2 1998 PIPE_7 16 PHVI5 ACMI2 1998 PIPE_7 17 RAPI ACMI2 1998 PIPE_7 18 SOCA6 ACMI2 1998 PIPE_7 19 VIPE2 ACMI2 1998 PIPE_7 20 ZIAU ACMI2 1998 PIPE_7 21 ACMI2 AMAR2 1998 PIPE_7 I have searched through the R-help archives for hints, which have not been successful in answering my question. As a new user to R and programming languages, I truly appreciate your help and thank you for your patience. Thanks in advance for your response, Lanna Jin - Lanna Jin lanna...@gmail.com 510-898-8525 -- View this message in context: http://n4.nabble.com/nested-looping-functions-and-dataframes-tp1595166p1595166.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.
Re: [R] Error in library(eda) : there is no package called 'eda'
On 15.03.2010 21:44, Phil Spector wrote: Peter - While the message hasn't been shown in more recent versions of R, older ( 2.9) versions of R used to print the following: library(eda) Warning message: package 'eda' has been merged into 'stats' ... which happened for R-1.9.0 roughly 6 years ago. Uwe Ligges So I would guess the functions you're looking for are now automatically loaded when you start R. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Mon, 15 Mar 2010, Peter Lauren wrote: I am using RGui version 2.10.1 (2009-12-14) for Windows.? When I enter the call ? library(eda) ? the following message ensues. ? Error in library(eda) : there is no package called 'eda' ? I thought that eda was a standard library for exploratory data analysis.? However I could not find it in the list of packages in the pull-down menu either. ? Any assistance with finding this package would be greatly appreciated. ? Many thanks in advance, Peter Lauren. ? [[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] nested looping functions and dataframes
Lanna - Here's one way: makeframe = function(x){ b = as.data.frame(as.matrix(table(x$Species,x$Species))) b = b[!(b$Var1 == b$Var2),-3] data.frame(Year=x$Year[1],Location=x$Location[1],b) } result = lapply(split(x,list(x$Year,x$Location)),makeframe) result will be a list of data frames, one for each Year/Location combination.You can find the data frame for a particular Year/Location combination as Year = 1998 Location = 'PIPE_7' result[[paste(Year,Location,sep='.')]] Hope this helps. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Tue, 16 Mar 2010, Lanna Jin wrote: Hey All, So, I am confused how exactly to use nesting loop functions in R to spit out data frames. I've managed to create a working function for my data set that generates a data frame for a given set of Year i and Location j; but how would I do it for all Years and Locations? Here is my working function: test-function(i,j){ a-x[which(x$Year==i x$Location==j),] b-as.data.frame(as.matrix(table(a$Species,a$Species))) c-b[-which(b$Var1==b$Var2),-3] c$Year-i; c$Location-j return(c) } Where, x is a dataframe that looks like the following: head(x,n=20) Year LocationSpecies 66 1998 PIPE_7 ACMI2 67 1998 PIPE_7 AMAR2 68 1998 PIPE_7 AMCA6 69 1998 PIPE_7 ANCY 70 1998 PIPE_7 ASVE 71 1998 PIPE_7 BOCU 72 1998 PIPE_7 CIFL 73 1998 PIPE_7 DAPU5 74 1998 PIPE_7 DICHANTHEL 75 1998 PIPE_7 GABO2 76 1998 PIPE_7 HEHE5 77 1998 PIPE_7 LIAS 78 1998 PIPE_7 LIPY 79 1998 PIPE_7 PAVI2 80 1998 PIPE_7 PHPI 81 1998 PIPE_7 PHVI5 82 1998 PIPE_7 RAPI 83 1998 PIPE_7 SOCA6 84 1998 PIPE_7 VIPE2 85 1998 PIPE_7 ZIAU and when feeding x into my function test with the parameters i = 1998 and j = PIPE_7, I get the following dataframe, c: head(test(1998,PIPE_7),n=20) Var1 Var2 Year Location 2 AMAR2 ACMI2 1998 PIPE_7 3 AMCA6 ACMI2 1998 PIPE_7 4ANCY ACMI2 1998 PIPE_7 5ASVE ACMI2 1998 PIPE_7 6BOCU ACMI2 1998 PIPE_7 7CIFL ACMI2 1998 PIPE_7 8 DAPU5 ACMI2 1998 PIPE_7 9 DICHANTHEL ACMI2 1998 PIPE_7 10 GABO2 ACMI2 1998 PIPE_7 11 HEHE5 ACMI2 1998 PIPE_7 12 LIAS ACMI2 1998 PIPE_7 13 LIPY ACMI2 1998 PIPE_7 14 PAVI2 ACMI2 1998 PIPE_7 15 PHPI ACMI2 1998 PIPE_7 16 PHVI5 ACMI2 1998 PIPE_7 17 RAPI ACMI2 1998 PIPE_7 18 SOCA6 ACMI2 1998 PIPE_7 19 VIPE2 ACMI2 1998 PIPE_7 20 ZIAU ACMI2 1998 PIPE_7 21 ACMI2 AMAR2 1998 PIPE_7 I have searched through the R-help archives for hints, which have not been successful in answering my question. As a new user to R and programming languages, I truly appreciate your help and thank you for your patience. Thanks in advance for your response, Lanna Jin - Lanna Jin lanna...@gmail.com 510-898-8525 -- View this message in context: http://n4.nabble.com/nested-looping-functions-and-dataframes-tp1595166p1595166.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-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] bottlenecks in R script
hello *, im running into two major bottlenecks an R script. 1. going through a 40mb file and reading in via readLines() 1 line at a time is almost an order of magnitude slow than the equivalent in python, im wondering if there are alternatives to readLines(), doing more lines at a time helps a bit 2. generating date sequences takes a long time, im basically doing something like seq.Date(Sys.Date(), length.out = 300, by ='day') a lot while digging into it, i strace'd the running process and it seems the bulk of the time is spent checking for /etc/localtime stat(/etc/localtime, {st_mode=S_IFREG|0644, st_size=2819, ...}) = 0 strace -cp 2964 Process 2964 attached - interrupt to quit ^CProcess 2964 detached % time seconds usecs/call callserrors syscall -- --- --- - - 94.610.006387 0 55872 stat 2.580.000174 0 568 read 1.420.96 0 285 write 1.390.94 1 137 brk -- --- --- - - 100.000.006751 56862 total has anybody ran into similar problems? __ 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] aggregate without removing empty subset
If the factor have only level: apply(m1, 2, tapply, addNA(part2), mean)[-2,,drop = FALSE] On Tue, Mar 16, 2010 at 12:43 PM, Christophe Genolini cgeno...@u-paris10.fr wrote: As I told you in private, thanks, it works perfectly. More precisely, I am working with 3D array. Your code works well (both on matrix or on array). But when part is a factor with only one value, the result has not a correct dimension (vector if m is a matrix, a matrix if m is an array). Any way to fix that ? m1 - matrix(1:12,4) m2 - array(1:24,dim=c(4,3,2)) part1 - factor(c(A,B,A,B),levels=c(A,B,C)) part2 - factor(c(A,A,A,A),levels=c(A)) apply(m1, 2, tapply, part1, mean) ##Perfect (dim=c(3,3)) apply(m1, 2, tapply, part2, mean) ## dim=NULL... apply(m2, c(2,3), tapply, part1, mean) ## Perfect (dim=c(3,3,2)) apply(m2, c(2,3), tapply, part2, mean) ## dim=c(3,2) Christophe Try this: apply(m, 2, tapply, part, mean) On Mon, Mar 15, 2010 at 2:10 PM, Christophe Genolini cgeno...@u-paris10.fr wrote: Hi the list, As it is say in its doc, the aggregate function remove empty subsets. Is it possible to NOT remove empty subset ? --- 8 --- m - matrix(1:12,4) part - factor(c(A,B,A,B),levels=c(A,B,C)) aggregate(m,list(part),mean) ### I get: # Group.1 V1 V2 V3 # 1 A 2 6 10 # 2 B 3 7 11 # ### I would like: # Group.1 V1 V2 V3 # 1 A 2 6 10 # 2 B 3 7 11 # 3 C NA NA NA --- 8 -- Thanks Christophe __ 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ 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] unknown compression
On 16.03.2010 14:35, R Heberto Ghezzo, Dr wrote: Thanks to Uwe Ligges, simply putting library(xxx) dump(ls(pos=2)),file=xxx.r) gives a file with all the 'pure R' function in a package This just solved my problem, as an added curiosity or just for completion sake, if the package 'xxx' has some C/Fortran code , ie an /lib/xxx.dll in Windows, will Rcmd INSTALL xxx work when xxx has a R; man and lib subfolders? not a src subfolder since I have the dll not the original C/for No, it won't work that way. But you could use some trick in order to inject the library. Since that one was compiled and linked against an ancient version of R, there is always the risk that your library won't work at all or causes crashes, of course. As an example see package rcom that does such nasty things by delivering the files somewhere in ./inst and ciopies on installation to ./libs using its configure.win file. Best, Uwe Ligges Thanks Heberto Ghezzo From: Uwe Ligges [lig...@statistik.tu-dortmund.de] Sent: Sunday, March 14, 2010 2:04 PM To: R Heberto Ghezzo, Dr Subject: Re: [R] unknown compression On 13.03.2010 22:33, R Heberto Ghezzo, Dr wrote: Hello Uwe / Rohlf Yes I know that, the problem here is that I have a package, old, it says Built: R 2.0.0; ; 2004-11-15 14:58:41; windows it is not in CRAN the author and manteiner can not be reached, so I have no way of obtaining the source tarball. The only solution is to decompress the pair .rdb .rdx if it is possible? In that case you can load the package and save all functions from that environment into a new package. The tool to load the serialized databases is lazyLoad() - or more low level lazyLoadDBfetch(), both not intended to be called by a user. Best wishes, Uwe Thanks for any help Heberto Ghezzo From: Uwe Ligges [lig...@statistik.tu-dortmund.de] Sent: Saturday, March 13, 2010 3:37 PM To: R Heberto Ghezzo, Dr Cc: r-help@r-project.org Subject: Re: [R] unknown compression On 12.03.2010 21:34, R Heberto Ghezzo, Dr wrote: Hello, I am trying to modify some functions in an existing package. I can get a function by just typing the name in the console, but how can I get all the functions in a package? the ./R/ subdirectory has files xx.rdb and xx.rdx which I can not decompress with 7-zip or with unzip, unrar etc. The help files are compressed with gzip in the ./man/ folder and can be unzipped easily. You are looking in a binary package. Instead of that, just download a source package (i.e. a not yet compiled one) from CRAN where you find the sources in plain text. Uwe Ligges Thanks for your help heberto.ghe...@mcgill.ca __ 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] Error in pruning hclust object using maptree package
On 15.03.2010 16:37, Keith wrote: Dear R users, Due to too many children in my clustering result, I would like to prune the tree-like hclust object into a certain groups. However, an error: clip.clust: no data provided for hclust object always shows up. Firstly, I tried the example in the maptree package, and it worked well. Then, I tried to used the example in stats package to generate a hclust object and tried the clip.clust method again, and the error still occurred. Here is the example: hc - hclust(dist(USArrests), ave) pr - clip.clust(hc, k=4) Error in clip.clust(hc, k = 4) : clip.clust: no data provided for hclust object Have you read ?clip.clust ?? It says for argument data: data clustered dataset for hclust application. whic means you need to provide data as the error message suggests as well. pr - clip.clust(hc, k=4, data=USArrests) pr$membership works for me. Uwe Ligges Does anyone have the idea? My environment is R version 2.10.1 (2009-12-14) x86_64-pc-linux-gnu [1] maptree_1.4-6 Best regards, Keith __ 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] Package documentation in dissertation
Thanks Gabor, that looks to be exactly what I was seeking. I'll play around with that. Thanks, Brian On Tue, Mar 16, 2010 at 05:19:23AM -0400, Gabor Grothendieck wrote: See: https://stat.ethz.ch/pipermail/r-help/2005-April/070581.html On Mon, Mar 15, 2010 at 11:16 PM, statmobile statmob...@gmail.com wrote: Hey Gabor, Thanks, I tried that, although I can't compile it directly. Do you know where I can get the R LaTeX definitions in order to compile that? Thanks! Gabor Grothendieck wrote: Try: R CMD Rdconv --type=latex myfile.Rd On Mon, Mar 15, 2010 at 8:46 PM, statmobile statmob...@gmail.com wrote: Hey Everyone, I wrote up a library for my dissertation work, and I'd love to include it as an appendix. I have found ways to export the Rd files as html, txt and pdf/ps, but not a raw tex export. I've had to resort to dumping it into text files, and just using verbatim in my LaTeX code. Does anybody have any recommendations or experiences with dealing with this? Please CC me on any response, as I only get summary emails from the list. Thanks in advance! Brian __ 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. -- Brian J. Lopes PhD Student Department of Statistics and Operations Research University of North Carolina at Chapel Hill To know that we know what we know, and that we do not know what we do not know, that is true knowledge --Henry David Thoreau (quoting Confucius): Walden __ 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] nested looping functions and dataframes
Thanks Phil, That worked wonders! Best, Lanna 2010/3/16 Phil Spector spec...@stat.berkeley.edu Lanna - Here's one way: makeframe = function(x){ b = as.data.frame(as.matrix(table(x$Species,x$Species))) b = b[!(b$Var1 == b$Var2),-3] data.frame(Year=x$Year[1],Location=x$Location[1],b) } result = lapply(split(x,list(x$Year,x$Location)),makeframe) result will be a list of data frames, one for each Year/Location combination.You can find the data frame for a particular Year/Location combination as Year = 1998 Location = 'PIPE_7' result[[paste(Year,Location,sep='.')]] Hope this helps. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Tue, 16 Mar 2010, Lanna Jin wrote: Hey All, So, I am confused how exactly to use nesting loop functions in R to spit out data frames. I've managed to create a working function for my data set that generates a data frame for a given set of Year i and Location j; but how would I do it for all Years and Locations? Here is my working function: test-function(i,j){ a-x[which(x$Year==i x$Location==j),] b-as.data.frame(as.matrix(table(a$Species,a$Species))) c-b[-which(b$Var1==b$Var2),-3] c$Year-i; c$Location-j return(c) } Where, x is a dataframe that looks like the following: head(x,n=20) Year LocationSpecies 66 1998 PIPE_7 ACMI2 67 1998 PIPE_7 AMAR2 68 1998 PIPE_7 AMCA6 69 1998 PIPE_7 ANCY 70 1998 PIPE_7 ASVE 71 1998 PIPE_7 BOCU 72 1998 PIPE_7 CIFL 73 1998 PIPE_7 DAPU5 74 1998 PIPE_7 DICHANTHEL 75 1998 PIPE_7 GABO2 76 1998 PIPE_7 HEHE5 77 1998 PIPE_7 LIAS 78 1998 PIPE_7 LIPY 79 1998 PIPE_7 PAVI2 80 1998 PIPE_7 PHPI 81 1998 PIPE_7 PHVI5 82 1998 PIPE_7 RAPI 83 1998 PIPE_7 SOCA6 84 1998 PIPE_7 VIPE2 85 1998 PIPE_7 ZIAU and when feeding x into my function test with the parameters i = 1998 and j = PIPE_7, I get the following dataframe, c: head(test(1998,PIPE_7),n=20) Var1 Var2 Year Location 2 AMAR2 ACMI2 1998 PIPE_7 3 AMCA6 ACMI2 1998 PIPE_7 4ANCY ACMI2 1998 PIPE_7 5ASVE ACMI2 1998 PIPE_7 6BOCU ACMI2 1998 PIPE_7 7CIFL ACMI2 1998 PIPE_7 8 DAPU5 ACMI2 1998 PIPE_7 9 DICHANTHEL ACMI2 1998 PIPE_7 10 GABO2 ACMI2 1998 PIPE_7 11 HEHE5 ACMI2 1998 PIPE_7 12 LIAS ACMI2 1998 PIPE_7 13 LIPY ACMI2 1998 PIPE_7 14 PAVI2 ACMI2 1998 PIPE_7 15 PHPI ACMI2 1998 PIPE_7 16 PHVI5 ACMI2 1998 PIPE_7 17 RAPI ACMI2 1998 PIPE_7 18 SOCA6 ACMI2 1998 PIPE_7 19 VIPE2 ACMI2 1998 PIPE_7 20 ZIAU ACMI2 1998 PIPE_7 21 ACMI2 AMAR2 1998 PIPE_7 I have searched through the R-help archives for hints, which have not been successful in answering my question. As a new user to R and programming languages, I truly appreciate your help and thank you for your patience. Thanks in advance for your response, Lanna Jin - Lanna Jin lanna...@gmail.com 510-898-8525 -- View this message in context: http://n4.nabble.com/nested-looping-functions-and-dataframes-tp1595166p1595166.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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Lanna Jin lanna...@gmail.com 510-898-8525 [[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] Changing global variables from functions
Hey all, I'm relatively new to the R-environment. I'm having a bit of trouble with encapsulation. I have a globally declared variable that doesn't update it when I change it in a function. For example when I run the following function deckn-NULL deck1-1 #52 card deck deck-function() { #Creating a standard deck deck1-c(1:52) deckn-deck1 #Creating n decks for (i in 2:num_decks) { deckn-c(deckn,52*i+deck1-1) } } deckn NULL it returns NULL for deckn instead of a vector of values. Is there an easy fix to update deckn in the function so that it outputs a vector of values ( I don't wish the function to return a value just update the current one)? Thanks in advance, Josh Elliott -- View this message in context: http://n4.nabble.com/Changing-global-variables-from-functions-tp1595002p1595002.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] Writting in the file
Hi user I'm learning how to use R and I have a problem with the format file. How do I to write in a file? I have some variables which I would like to write in a file.  Att. Marize Simões __ 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] bottlenecks in R script
Check out read.csv.sql in the sqldf package. It reads a file directly into sqlite without going through R and then from there into R. It sets up the database and file layouts in the database for you and also destroys the database when finished so reading is just a matter of one line of R code. It also has the capability of reading any portion of the file that can be specified in sql. See examples on home page: http://sqldf.googlecode.com On Tue, Mar 16, 2010 at 12:51 PM, Joe Calderon calderon@gmail.com wrote: hello *, im running into two major bottlenecks an R script. 1. going through a 40mb file and reading in via readLines() 1 line at a time is almost an order of magnitude slow than the equivalent in python, im wondering if there are alternatives to readLines(), doing more lines at a time helps a bit 2. generating date sequences takes a long time, im basically doing something like seq.Date(Sys.Date(), length.out = 300, by ='day') a lot while digging into it, i strace'd the running process and it seems the bulk of the time is spent checking for /etc/localtime stat(/etc/localtime, {st_mode=S_IFREG|0644, st_size=2819, ...}) = 0 strace -cp 2964 Process 2964 attached - interrupt to quit ^CProcess 2964 detached % time seconds usecs/call calls errors syscall -- --- --- - - 94.61 0.006387 0 55872 stat 2.58 0.000174 0 568 read 1.42 0.96 0 285 write 1.39 0.94 1 137 brk -- --- --- - - 100.00 0.006751 56862 total has anybody ran into similar problems? __ 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] Regarding variable importance in the randomForest package
Seems like you're new to R as well? The first argument should contain only the predictor variables, but you used the entire data frame that contains the response. Andy -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Corinne Staley Sent: Monday, March 15, 2010 9:52 PM To: r-help@r-project.org Subject: [R] Regarding variable importance in the randomForest package For anyone who is knowledgeable about the randomForest package in R, I have a question: When I look at the variable importance for data, I see that my response variable is included along with my predictor variables. That is, I am getting a MeanDecreaseGini for my response variable, and therefore it seems as though it is being treated as a predictor variable. my code (just in case it helps) : comm.RF-randomForest(model.data,y=model.data$Comm_Heir,mtry=8 ,importance=T) Apologies if it's a stupid question, but I'm new to randomForests. Hopefully that makes sense and if anyone can let me know how remedy this situation, I would be so grateful. Cheers! [[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: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] inner join sqldf
Its unlikely that the inner join is what you want. prochi has only 5 levels so the result is going to be enormous. In the second statement you are trying to union incompatible tables. Get an introductory book on SQL and read up on how it works. On Mon, Mar 15, 2010 at 10:39 AM, Newbie19_02 nvanzuy...@gmail.com wrote: Dear Gabor, require(sqldf) file(description=http://n4.nabble.com/file/n1593282/test_sql_psd.txt;, open=) file(description=http://n4.nabble.com/file/n1593282/test_sql_tsf.txt;, open=) test_sql_psd - read.table(file=http://n4.nabble.com/file/n1593282/test_sql_psd.txt;, header=TRUE, sep=\t, dec=., na.strings=NA, check.names=TRUE, quote= \') test_sql_tsf -read.table(http://n4.nabble.com/file/n1593282/test_sql_tsf.txt; , header=TRUE, sep=\t, dec=., na.strings=NA, check.names=TRUE, quote= \') test_sql_innerjoin - sqldf(select * from test_sql_psd inner join test_sql_tsf on test_sql_psd.prochi=test_sql_tsf.prochi) Please note that in my previous email I said that I had used union and it had worked. In fact it did not. test_sql_union-sqldf(select * from test_sql_tsf union select * from test_sql_psd) did not work because of the following error: Error in sqliteExecStatement(con, statement, bind.data) : RS-DBI driver: (error in statement: SELECTs to the left and right of UNION do not have the same number of result columns) Please let me know if this works otherwise I'll amend the code again. Thanks, natalie -- View this message in context: http://n4.nabble.com/inner-join-sqldf-tp1593282p1593451.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-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 line graphics, labels and legend
Dear users, I think my questions are pretty simple, but I got lost in the hundreds of par() and plot() arguments and plot functions, so I don't know in which direction I should go. Here is my sample dataset: test - structure(list(DIET = structure(c(1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L), .Label = c(G, GG, L, LG), class = factor), SILIKATG = c(0.0152, 0.0161, 0.0141, 0.0131, 0.0108, 0, 0, 0, 0, 1e-04, 0.0056, 0.0078, 0.0072, 0.0047, 0.0091, 3e-04, 5e-04, 0, 0.0013, 0.0012)), .Names = c(DIET, SILIKATG), row.names = c(1L, 2L, 3L, 4L, 5L, 31L, 32L, 33L, 34L, 35L, 61L, 62L, 63L, 64L, 65L, 101L, 102L, 103L, 104L, 105L), class = data.frame) 1. The first plot I want to do is: plot(test$SILIKATG, ylim=c(0,0.02), type=l) It looks the way I want to, but my question is:* How to change the labels on the x-axis? I would like to have the groups (G, GG, L, LG) labeled on the x-axis instead of the 5, 10, 15, 20 of Index. And if possible with ticks to delimit the groups. * I've tried:plot(test$SILIKATG~test$DIET, ylim=c(0,0.02), type=l)But I get boxplots... 2. The second graph is an alternative, and I would like to use both for now: I first modify the data: selectG - test[test$DIET==G,]; selectG$DIET - factor(selectG$DIET, levels=G) I do it for each group and: plot(selectG$SILIKATG, type=p, ylim=c(0,0.02), pch=1, col=black); points(selectGG$SILIKATG, type=p, ylim=c(0,0.02), pch=2, col=red) And so on for each group, and then add the legend with: legend(x=topright, legend=c(G, GG, L, LG), pch=1:4, col=c(black, red, green, blue)) My question here is: * Isn't there an easier way to do all of it?! I'm quite sure there's a way where I don't have to select each group and plot it separately. And I guess something more automatic also exists (e.g. the legend so that I don't have to give the names of the groups and the colors and symbols used etc). *Thank you all in advance for your help. Regards, Ivan -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[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] Changing global variables from functions
On Mar 16, 2010, at 11:04 AM, jtouyz wrote: Hey all, I'm relatively new to the R-environment. I'm having a bit of trouble with encapsulation. I have a globally declared variable that doesn't update it when I change it in a function. For example when I run the following function deckn-NULL deck1-1 #52 card deck deck-function() { #Creating a standard deck deck1-c(1:52) deckn-deck1 #Creating n decks for (i in 2:num_decks) # could be wrong but it appears that you are expecting the act of putting num_ in front of decks to be interpreted by R as returning the length of deckn or deck1. That is a higher level of abstraction than is yet available in any computer language with which I am familiar. Or perhaps you were intending to use Greg Snow's soon to be released mind-reading package so that R could know that you wanted it to be 6?. Perhaps instead (depending on what the real problem (unstated as yet) might be: for (i in 2:length(deck1) ) # or some other object or function that returns a numeric value. { deckn-c(deckn,52*i+deck1-1) } } deckn You would have needed to assign a return-ed value to deckn in the outer environment. The deckn object would have disappeared at the end of the function call, and it would not have needed to be named deckn, either. Try instead: deckn-NULL deck-function(num_decks=6) { #Creating a standard deck deck1-c(1:52) deckn-deck1 #Creating n decks for (i in 2:num_decks) { deckn-c(deckn,52*i+deck1-1) }; return(deckn) } deckn - deck() deckn Which has a gap between 52 and 104 because of your logic, not mine. NULL it returns NULL for deckn instead of a vector of values. Is there an easy fix to update deckn in the function so that it outputs a vector of values ( I don't wish the function to return a value just update the current one)? You could, of course, explain what you are trying to do. Thanks in advance, Josh Elliott -- David Winsemius, MD West Hartford, CT __ 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] an ordinal regression MCMC run high correlation
I am trying to model a clusterd ordinal response data (either 1, 2 or 3) called , the correponding physician of the patient is also in the data. Since it is ordinal, I used the ordinal logit model topbox[i]~discrete with probability P[j,1],p[j,2], p[j,3], j is the corresponding physician of the ith patient C[j] is the physician effect , a1 and a1+theta is the common cutpoints for all physicians I generate 10,000 iteration and there are still high autocorrelation of a1 and tau. I thought 10,000 is a pretty big number and the chain converges really slow. I am a new MCMC user and don't know other ways to solve this problem. Will someone please give some suggestions that may apply to this specific modeling? model { for ( i in 1:N) { response[i]~dcat( p[physician[i], ] ) } for (j in 1:Nt) { p[j,1]-1-Q[j,1] p[j,2]-Q[j,1]-Q[j,2] p[j,3]-Q[j,2] logit(Q[j,1])--c[j] logit(Q[j,2])--(c[j]+theta) score[j]-0.5*p[j,2]+p[j,3] c[j]~dnorm(a1, tau) } a1~dnorm(0, 1.0E-06) theta~dnorm(0, 1.0E-06)I(0,) tau~dgamma(0.001,0.001) } list(N=667,Nt=50) Thanks, Ping __ 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] Changing global variables from functions
Hi David, Thank you for your response. Yes, num_decks was previously defined in my program, I apologize for the confusion as it is an integral value. This is only one portion of my program that is being used to simulate card counting in blackjack. The basic idea was to modify deckn without having to return a value from the function deck(). That is whenever deck() was run it would write over whatever was in deckn (instead of having to input deckn-deck().) It seems from your response that this may not be possible and return is always required. If I have erred, please let me know. Thanks once again, Josh Elliott David Winsemius wrote: On Mar 16, 2010, at 11:04 AM, jtouyz wrote: Hey all, I'm relatively new to the R-environment. I'm having a bit of trouble with encapsulation. I have a globally declared variable that doesn't update it when I change it in a function. For example when I run the following function deckn-NULL deck1-1 #52 card deck deck-function() { #Creating a standard deck deck1-c(1:52) deckn-deck1 #Creating n decks for (i in 2:num_decks) # could be wrong but it appears that you are expecting the act of putting num_ in front of decks to be interpreted by R as returning the length of deckn or deck1. That is a higher level of abstraction than is yet available in any computer language with which I am familiar. Or perhaps you were intending to use Greg Snow's soon to be released mind-reading package so that R could know that you wanted it to be 6?. Perhaps instead (depending on what the real problem (unstated as yet) might be: for (i in 2:length(deck1) ) # or some other object or function that returns a numeric value. { deckn-c(deckn,52*i+deck1-1) } } deckn You would have needed to assign a return-ed value to deckn in the outer environment. The deckn object would have disappeared at the end of the function call, and it would not have needed to be named deckn, either. Try instead: deckn-NULL deck-function(num_decks=6) { #Creating a standard deck deck1-c(1:52) deckn-deck1 #Creating n decks for (i in 2:num_decks) { deckn-c(deckn,52*i+deck1-1) }; return(deckn) } deckn - deck() deckn Which has a gap between 52 and 104 because of your logic, not mine. NULL it returns NULL for deckn instead of a vector of values. Is there an easy fix to update deckn in the function so that it outputs a vector of values ( I don't wish the function to return a value just update the current one)? You could, of course, explain what you are trying to do. Thanks in advance, Josh Elliott -- David Winsemius, MD West Hartford, CT __ 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. -- View this message in context: http://n4.nabble.com/Changing-global-variables-from-functions-tp1595002p1595356.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] Constrained non linear regression using ML
Dear R users, I have to fit the non linear regression: y~1-exp(-(k0+k1*p1+k2*p2+ +kn*pn)) where ki=0 for each i in [1 n] and pi are on R+. I am using, at the moment, nls, but I would rather use a Maximum Likelhood based algorithm. The error is not necessarily normally distributed. y is approximately beta distributed, and the volume of data is medium to large (the y,pi may have ~ 40,000 elements). I have studied the packages in the task views Optimisation and Robust Statistical Methods, but I did look like what I was looking for was there. Maybe I am wrong. The nearest thing was nlrob, but even that does not allow for constraints, as far as I can understand. Any suggestion? Regards -- Corrado Topi PhD Researcher Global Climate Change and Biodiversity Area 18,Department of Biology University of York, York, YO10 5YW, UK Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk __ 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] Problems with loading arm
Hello, I recently updated to R 2.10 on my 64 bit Dell Precision T7400 running Enterprise Linux and now I can't get the arm library to load when I run R using Wine. Prior to the update I was able to use arm without any trouble. My main goal is to use arm with WinBUGS on this machine, calling it from R for Windows, which is executed with wine. After the update, when I try to load the arm library, I get the following: library(arm) Loading required package: MASS Loading required package: Matrix Loading required package: lattice Loading required package: lme4 Loading required package: R2WinBUGS Loading required package: coda Attaching package: 'coda' The following object(s) are masked from package:lme4 : HPDinterval Loading required package: abind Loading required package: car Error in packageDescription(arm, lib = mylib)$Version : $ operator is invalid for atomic vectors In addition: Warning message: In packageDescription(arm, lib = mylib) : no package 'arm' was found Error : .onAttach failed in 'attachNamespace' Error: package/namespace load failed for 'arm' I tried reinstalling arm (and updating all packages), but I still get the same error. I've tried loading arm in R running under linux pointing to the library location that R for Windows is reading from and it loads fine. I've tried loading arm in R for Windows referencing the library location where I've installed arm for R for linux, and get the following: library(arm) Loading required package: MASS Loading required package: Matrix Loading required package: lattice Loading required package: lme4 Error in library.dynam(lib, package, package.lib) : shared library 'lme4' not found Error: package 'lme4' could not be loaded I installed lme4 in the same directory as arm (i.e., myrlibrary/), but R claims it can't find it, even though it shows up in the window when I click on Load Packages I'm assuming this has something to do with a shared library problem. I've spent the past two days googling, reading manuals and standard references, and I'm stumped. Does anyone have any suggestions about how I might fix this problem. Best, Greg . Gregory Wawro gj...@columbia.edu Associate Professor phone: 212-854-8540 Dept. of Political Science fax:212-222-0598 741 International Affairs http://www.columbia.edu/~gjw10/ Columbia University New York, NY 10027 . __ 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] Changing global variables from functions
On Mar 16, 2010, at 2:43 PM, jtouyz wrote: Hi David, Thank you for your response. Yes, num_decks was previously defined in my program, I apologize for the confusion as it is an integral value. This is only one portion of my program that is being used to simulate card counting in blackjack. The basic idea was to modify deckn without having to return a value from the function deck(). That is whenever deck() was run it would write over whatever was in deckn (instead of having to input deckn-deck().) It seems from your response that this may not be possible and return is always required. If I have erred, please let me know. R is supposed to be used as a functional language. The use of the - operator is deprecated, so I did not mention that strategy. You could also have simply run the loop without the functional wrapper. -- david. Thanks once again, Josh Elliott David Winsemius wrote: On Mar 16, 2010, at 11:04 AM, jtouyz wrote: Hey all, I'm relatively new to the R-environment. I'm having a bit of trouble with encapsulation. I have a globally declared variable that doesn't update it when I change it in a function. For example when I run the following function deckn-NULL deck1-1 #52 card deck deck-function() { #Creating a standard deck deck1-c(1:52) deckn-deck1 #Creating n decks for (i in 2:num_decks) # could be wrong but it appears that you are expecting the act of putting num_ in front of decks to be interpreted by R as returning the length of deckn or deck1. That is a higher level of abstraction than is yet available in any computer language with which I am familiar. Or perhaps you were intending to use Greg Snow's soon to be released mind-reading package so that R could know that you wanted it to be 6?. Perhaps instead (depending on what the real problem (unstated as yet) might be: for (i in 2:length(deck1) ) # or some other object or function that returns a numeric value. { deckn-c(deckn,52*i+deck1-1) } } deckn You would have needed to assign a return-ed value to deckn in the outer environment. The deckn object would have disappeared at the end of the function call, and it would not have needed to be named deckn, either. Try instead: deckn-NULL deck-function(num_decks=6) { #Creating a standard deck deck1-c(1:52) deckn-deck1 #Creating n decks for (i in 2:num_decks) { deckn-c(deckn,52*i+deck1-1) }; return(deckn) } deckn - deck() deckn Which has a gap between 52 and 104 because of your logic, not mine. NULL it returns NULL for deckn instead of a vector of values. Is there an easy fix to update deckn in the function so that it outputs a vector of values ( I don't wish the function to return a value just update the current one)? You could, of course, explain what you are trying to do. Thanks in advance, Josh Elliott -- David Winsemius, MD West Hartford, CT __ 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. -- View this message in context: http://n4.nabble.com/Changing-global-variables-from-functions-tp1595002p1595356.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. David Winsemius, MD West Hartford, CT __ 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] How can I save the result for goodness of fit test
Dear All, I run the goodness of fit test using goodfit() in vcd package. The result is as follow: Goodness-of-fit test for poisson distribution X^2 df P( X^2) Pearson 1.053348 2 0.5905661 Warning message: In summary.goodfit(gf) : Chi-squared approximation may be incorrect I want to save the the test statistics(X^2), df, and p-value. How can I save the result. Actually, I want to make a table. In addition, there is warning message In summary.goodfit(gf) : Chi-squared approximation may be incorrect. How can I interpret this result. Have a nice day. -- View this message in context: http://n4.nabble.com/How-can-I-save-the-result-for-goodness-of-fit-test-tp1595429p1595429.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.
Re: [R] OT Really: Odds Are, It's Wrong...
Dieter Menne schrieb: Marc Schwartz-3 wrote: I thought that readers of R-Help might find the following article at ScienceNews of interest: Odds Are, It's Wrong Science fails to face the shortcomings of statistics By Tom Siegfried March 27th, 2010; Vol.177 #7 (p. 26) http://www.sciencenews.org/view/feature/id/57091/title/Odds_are,_its_wrong Too bad the article is so long that all my p-value-greedy colleagues from the medical faculty won't read it. Journals should apply a post-hoc Bonferroni-correction by the number of p-values cited in an article. The main problem is the multitude of p-value not cited. I have little problems with scientists publishing all their findings with p-values (or confidence intervals) but big problems with people who use them as a filter. __ 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] Changing global variables from functions
On Mar 16, 2010, at 3:11 PM, David Winsemius wrote: On Mar 16, 2010, at 2:43 PM, jtouyz wrote: Hi David, Thank you for your response. Yes, num_decks was previously defined in my program, I apologize for the confusion as it is an integral value. This is only one portion of my program that is being used to simulate card counting in blackjack. The basic idea was to modify deckn without having to return a value from the function deck(). That is whenever deck() was run it would write over whatever was in deckn (instead of having to input deckn-deck().) It seems from your response that this may not be possible and return is always required. If I have erred, please let me know. R is supposed to be used as a functional language. The use of the - operator is deprecated, so I did not mention that strategy. You could also have simply run the loop without the functional wrapper. I wondered if a sampling without replacement strategy might work to provide with indexing: num_deck # what fills shoes these days. ( table((1:52)[sample(1:(52*num_decks), 52*num_decks) %% 52]) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 -- David. -- david. Thanks once again, Josh Elliott David Winsemius wrote: On Mar 16, 2010, at 11:04 AM, jtouyz wrote: Hey all, I'm relatively new to the R-environment. I'm having a bit of trouble with encapsulation. I have a globally declared variable that doesn't update it when I change it in a function. For example when I run the following function deckn-NULL deck1-1 #52 card deck deck-function() { #Creating a standard deck deck1-c(1:52) deckn-deck1 #Creating n decks for (i in 2:num_decks) # could be wrong but it appears that you are expecting the act of putting num_ in front of decks to be interpreted by R as returning the length of deckn or deck1. That is a higher level of abstraction than is yet available in any computer language with which I am familiar. Or perhaps you were intending to use Greg Snow's soon to be released mind-reading package so that R could know that you wanted it to be 6?. Perhaps instead (depending on what the real problem (unstated as yet) might be: for (i in 2:length(deck1) ) # or some other object or function that returns a numeric value. { deckn-c(deckn,52*i+deck1-1) } } deckn You would have needed to assign a return-ed value to deckn in the outer environment. The deckn object would have disappeared at the end of the function call, and it would not have needed to be named deckn, either. Try instead: deckn-NULL deck-function(num_decks=6) { #Creating a standard deck deck1-c(1:52) deckn-deck1 #Creating n decks for (i in 2:num_decks) { deckn-c(deckn,52*i+deck1-1) }; return(deckn) } deckn - deck() deckn Which has a gap between 52 and 104 because of your logic, not mine. NULL it returns NULL for deckn instead of a vector of values. Is there an easy fix to update deckn in the function so that it outputs a vector of values ( I don't wish the function to return a value just update the current one)? You could, of course, explain what you are trying to do. Thanks in advance, Josh Elliott -- David Winsemius, MD West Hartford, CT __ 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. -- View this message in context: http://n4.nabble.com/Changing-global-variables-from-functions-tp1595002p1595356.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. David Winsemius, MD West Hartford, CT __ 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. David Winsemius, MD West Hartford, CT __ 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] Retrieving latitude and longitude via Google Maps API
Does anyone have any experience retrieving latitutde and longitude for an address from the Google Maps API? I'd like to have an R script that submits a street address, city, state, and zip code and returns the coordinates. So far, I've been submitting the coordinates from another program, then loading the coordinates in R and merging them back into the data frame I want to use. It'd be nice to be able to do it all in one script, but I'm not comprehending the API thing very well. I'm using R 2.9.1 on Windows XP. Any suggestions or pointers? Benjamin Benjamin Nutter | Biostatistician | Quantitative Health Sciences Cleveland Clinic | 9500 Euclid Ave. | Cleveland, OH 44195 | (216) 445-1365 === P Please consider the environment before printing this e-mail Cleveland Clinic is ranked one of the top hospitals in America by U.S.News World Report (2009). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use\...{{dropped:13}} __ 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] Fw: an ordinal regression MCMC run high correlation
I tried thinning of the mcmc run with 500,000 iteration. It looks like 100 or 200 is enough to remove the autocorrelation of a1 and tau. Is that too much thining? --- On Tue, 3/16/10, ping chen chen1984...@yahoo.com.cn wrote: From: ping chen chen1984...@yahoo.com.cn Subject: an ordinal regression MCMC run high correlation To: r-help@r-project.org Cc: chen1984...@yahoo.com.cn Date: Tuesday, March 16, 2010, 12:19 PM I am trying to model a clusterd ordinal response data (either 1, 2 or 3) called , the correponding physician of the patient is also in the data. Since it is ordinal, I used the ordinal logit model topbox[i]~discrete with probability P[j,1],p[j,2], p[j,3], j is the corresponding physician of the ith patient C[j] is the physician effect , a1 and a1+theta is the common cutpoints for all physicians I generate 10,000 iteration and there are still high autocorrelation of a1 and tau. I thought 10,000 is a pretty big number and the chain converges really slow. I am a new MCMC user and don't know other ways to solve this problem. Will someone please give some suggestions that may apply to this specific modeling? model { for ( i in 1:N) { response[i]~dcat( p[physician[i], ] ) } for (j in 1:Nt) { p[j,1]-1-Q[j,1] p[j,2]-Q[j,1]-Q[j,2] p[j,3]-Q[j,2] logit(Q[j,1])--c[j] logit(Q[j,2])--(c[j]+theta) score[j]-0.5*p[j,2]+p[j,3] c[j]~dnorm(a1, tau) } a1~dnorm(0, 1.0E-06) theta~dnorm(0, 1.0E-06)I(0,) tau~dgamma(0.001,0.001) } list(N=667,Nt=50) Thanks, Ping __ 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 pruning hclust object using maptree package
My bad. I did read the help. However, I didn't pay enough attention to the data argument, and it seems it doesn't need to use data argument in the earlier version. I also noticed this argument afterwards. Now it works for me as well. Thanks a lot. Uwe Ligges wrote: On 15.03.2010 16:37, Keith wrote: Dear R users, Due to too many children in my clustering result, I would like to prune the tree-like hclust object into a certain groups. However, an error: clip.clust: no data provided for hclust object always shows up. Firstly, I tried the example in the maptree package, and it worked well. Then, I tried to used the example in stats package to generate a hclust object and tried the clip.clust method again, and the error still occurred. Here is the example: hc - hclust(dist(USArrests), ave) pr - clip.clust(hc, k=4) Error in clip.clust(hc, k = 4) : clip.clust: no data provided for hclust object Have you read ?clip.clust ?? It says for argument data: data clustered dataset for hclust application. whic means you need to provide data as the error message suggests as well. pr - clip.clust(hc, k=4, data=USArrests) pr$membership works for me. Uwe Ligges Does anyone have the idea? My environment is R version 2.10.1 (2009-12-14) x86_64-pc-linux-gnu [1] maptree_1.4-6 Best regards, Keith __ 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] Conditional variable assignment
On Mar 16, 2010, at 3:44 PM, Hosack, Michael wrote: Hi everyone, Once again I am stuck with a problem I can't seem to figure out. I suppose this learning curve levels off eventually, lol. I am learning on my own with absolutely no background in programming, so if I seem to request help a lot it's not because I am seeking others to do the work for me. I need to assign one of two arrival times to the 'ARRIVE' variable of my dataframe, and I want a value assigned only to the first element of each 'MM' by 'DD' variable grouping. The value used (either 0700 or 1430) will be conditional on the value in the 'TOD' variable, such that if 'TOD' == 1, 'ARRIVE'-0700, and if 'TOD'==2, 'ARRIVE'-1430. I want the remaining three 'MM' by 'DD' values for each unique grouping to remain NA for now, because I intend to calculate them later. I have tried ifelse statements with ddply, for loops, etc. to no avail. Any help would be greatly appreciated. Logical indexing; dfrm[!duplicated(paste(dfrm$MM, dfrm$DD)), ARRIVE] - 0700 dfrm$ARRIVE[dfrm$ARRIVE == 0700 dfrm$TOD==2] - 1430 -- David Winsemius, MD West Hartford, CT __ 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] Constrained non linear regression using ML
I have an algorithm that can perform nonlinear optimization, with linear/nonlinear, equality and/or inequality constraints. From your description, it seems like this algorithm would work for your problem. Contact me if you are interested and I will send you the code. Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Corrado Sent: Tuesday, March 16, 2010 2:59 PM To: r-help@r-project.org Subject: [R] Constrained non linear regression using ML Dear R users, I have to fit the non linear regression: y~1-exp(-(k0+k1*p1+k2*p2+ +kn*pn)) where ki=0 for each i in [1 n] and pi are on R+. I am using, at the moment, nls, but I would rather use a Maximum Likelhood based algorithm. The error is not necessarily normally distributed. y is approximately beta distributed, and the volume of data is medium to large (the y,pi may have ~ 40,000 elements). I have studied the packages in the task views Optimisation and Robust Statistical Methods, but I did look like what I was looking for was there. Maybe I am wrong. The nearest thing was nlrob, but even that does not allow for constraints, as far as I can understand. Any suggestion? Regards -- Corrado Topi PhD Researcher Global Climate Change and Biodiversity Area 18,Department of Biology University of York, York, YO10 5YW, UK Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk __ 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] OT Really: Odds Are, It's Wrong...
Johannes Huesing wrote: I have little problems with scientists publishing all their findings with p-values (or confidence intervals) but big problems with people who use them as a filter. While I am aware that CI and p-values have a common root, I do not to throw both into one pot for the average medical end-user. When two treatments for blood pressure show a significant differences, this only tells you that the sponsor had a lot of money to show his expensive new product is worth the money. When you tell the medical doctor that the CI of the difference has a range 1.1 mmHg , she would say: I don't care, it's not relevant, both products are good enough for me. I tend to strongly stress the difference between relevance (medically weighted CI) and significance (pure numerics) in lectures. After all, it's difficult enough when doing sample size estimation to get something like a medically relevant difference. So I have to pay back by giving them a medically-to-be-weighted difference after study end. Dieter -- View this message in context: http://n4.nabble.com/OT-Sorta-Odds-Are-It-s-Wrong-tp1593626p1595554.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.
Re: [R] Retrieving latitude and longitude via Google Maps API
Benjamin - Perhaps this will get you started: addr = '1600 Pennsylvania Avenue, Washington, DC' url = paste('http://maps.google.com/maps/api/geocode/xml?address=', + addr,'sensor=false',sep='') library(XML) doc = xmlTreeParse(url) root = xmlRoot(doc) lat = xmlValue(root[['result']][['geometry']][['location']][['lat']]) long = xmlValue(root[['result']][['geometry']][['location']][['lng']]) lat [1] 38.8976500 long [1] -77.0356669 - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Tue, 16 Mar 2010, Nutter, Benjamin wrote: Does anyone have any experience retrieving latitutde and longitude for an address from the Google Maps API? I'd like to have an R script that submits a street address, city, state, and zip code and returns the coordinates. So far, I've been submitting the coordinates from another program, then loading the coordinates in R and merging them back into the data frame I want to use. It'd be nice to be able to do it all in one script, but I'm not comprehending the API thing very well. I'm using R 2.9.1 on Windows XP. Any suggestions or pointers? Benjamin Benjamin Nutter | Biostatistician | Quantitative Health Sciences Cleveland Clinic | 9500 Euclid Ave. | Cleveland, OH 44195 | (216) 445-1365 === P Please consider the environment before printing this e-mail Cleveland Clinic is ranked one of the top hospitals in America by U.S.News World Report (2009). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use\...{{dropped:13}} __ 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] Constrained non linear regression using ML
Check out the betareg package. On Tue, Mar 16, 2010 at 2:58 PM, Corrado ct...@york.ac.uk wrote: Dear R users, I have to fit the non linear regression: y~1-exp(-(k0+k1*p1+k2*p2+ +kn*pn)) where ki=0 for each i in [1 n] and pi are on R+. I am using, at the moment, nls, but I would rather use a Maximum Likelhood based algorithm. The error is not necessarily normally distributed. y is approximately beta distributed, and the volume of data is medium to large (the y,pi may have ~ 40,000 elements). I have studied the packages in the task views Optimisation and Robust Statistical Methods, but I did look like what I was looking for was there. Maybe I am wrong. The nearest thing was nlrob, but even that does not allow for constraints, as far as I can understand. Any suggestion? Regards -- Corrado Topi PhD Researcher Global Climate Change and Biodiversity Area 18,Department of Biology University of York, York, YO10 5YW, UK Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk __ 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] Retrieving latitude and longitude via Google Maps API
Hi Benjamin, On Tue, 16 Mar 2010, Nutter, Benjamin wrote: Does anyone have any experience retrieving latitutde and longitude for an address from the Google Maps API? This thread from r-sig-geo may be of interest: https://stat.ethz.ch/pipermail/r-sig-geo/2010-March/thread.html#7788 Hope this helps, Michael I'd like to have an R script that submits a street address, city, state, and zip code and returns the coordinates. So far, I've been submitting the coordinates from another program, then loading the coordinates in R and merging them back into the data frame I want to use. It'd be nice to be able to do it all in one script, but I'm not comprehending the API thing very well. I'm using R 2.9.1 on Windows XP. Any suggestions or pointers? Benjamin Benjamin Nutter | Biostatistician | Quantitative Health Sciences Cleveland Clinic | 9500 Euclid Ave. | Cleveland, OH 44195 | (216) 445-1365 === P Please consider the environment before printing this e-mail Cleveland Clinic is ranked one of the top hospitals in America by U.S.News World Report (2009). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use\...{{dropped:13}} __ 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. -- Michael Denslow I.W. Carpenter Jr. Herbarium [BOON] Department of Biology Appalachian State University Boone, North Carolina U.S.A. -- AND -- Communications Manager Southeast Regional Network of Expertise and Collections sernec.org 36.214177, -81.681480 +/- 3103 meters __ 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] Re : Eliminate border in wireframe plot
Scott: This may work for you. Just include the statement par.settings - par.set1 in your wire graph statement par.set1 -list( axis.line=list(col=transparent), # Get rid of box around fig? clip=list(panel=FALSE), # disarm lurking panel settings? ) Dr. Seth W. Bigelow Biologist, USDA-FS Pacific Southwest Research Station 1731 Research Park Drive, Davis California sbige...@fs.fed.us / ph. 530 759 1718 [[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] Is there a way to edit a specific line in a function (e.g: doing function-text-edit-function) ?
Hello, Let's say we have the following function: foo - function(x) { line1 - x line2 - 0 line3 - line1 + line2 return(line3) } And that we want to change the second line to be: line2 - 2 How would you do that? The two ways I know of are either to use fix(foo) And change the function. Or to just write the function again. Is there another way? *What I would like* is for some way to represent the function as a vector of strings (well, characters), then change one of it's values, and then turn it into a function again. The reason I am asking is that I just published a post online where I used a function to which I did a minor tweak (so to improve it's output for my particular case). This tweaking was just adding one line of code, to a function who's length is 187 lines of code. So instead of repasting all the function on my blog, I decided to just explain how to edit it. But I would rather have a simple code that edited the function for the reader. Thanks, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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] Is there a way to edit a specific line in a function (e.g: doing function-text-edit-function) ?
Try this: body(foo)[[grep('^line2', body(foo))]][[3]] - 2 On Tue, Mar 16, 2010 at 6:31 PM, Tal Galili tal.gal...@gmail.com wrote: Hello, Let's say we have the following function: foo - function(x) { line1 - x line2 - 0 line3 - line1 + line2 return(line3) } And that we want to change the second line to be: line2 - 2 How would you do that? The two ways I know of are either to use fix(foo) And change the function. Or to just write the function again. Is there another way? *What I would like* is for some way to represent the function as a vector of strings (well, characters), then change one of it's values, and then turn it into a function again. The reason I am asking is that I just published a post online where I used a function to which I did a minor tweak (so to improve it's output for my particular case). This tweaking was just adding one line of code, to a function who's length is 187 lines of code. So instead of repasting all the function on my blog, I decided to just explain how to edit it. But I would rather have a simple code that edited the function for the reader. Thanks, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ 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] R on Linux - a primer
Le dimanche 14 mars 2010 à 18:04 -0400, Axel Urbiz a écrit : Hi, I'm looking to move from Windows into a 64-bit Linux environment. Which is the best Linux Flavor to use within R? To install R on this environment, do I need to do any compiling? I'd like to add two cents of folly to the (wise) advice you've received already. Indeed , Ubuntu is one very good distribution whose management system has made the care and feeding of a Linux system a *lot* easier for the not-so-system-oriented people like yours truly. Whereas my first contacts with a Unix-like system were about 30 years ago (Oh my, how time flies, and how far away are Xenix and our 68000 systems ...), I'm *still* not fond of system maintenance for it's own sake. Ubuntu added an (almost) fool-proof maintenance system to an excellent distribution called Debian, thus lowering the Linux entry bar to as low as it can be humanely made. Some pretended that Ubuntu was a code word for I'm too stupid to configure Debian ; quite untrue ! It only means I'm too busy|lazy to configure Debian, which is a Good Thing (TM). But Debian has its strong points, and one of them is *extremely* strong for an R user : Dirk Eddelbuettel (whose name I'm almost surely misspelling (sorry, Dirk !)) has created a marvelous system called cran2deb which routinely creates binary Debian packages from (almost) the 2000+ R packages available nowadays. That might look small change : the basic tools used for developing/compiling most R packages are small beer (at least by today's standards).But some of them might depend on fiendishly difficult-to-maintain foreign libraries. Dirk's cran2deb takes care of that and creates any information that Debian's dpkg maintenance system needs to automate *your* R maintenance chores by integrating them in Debian's maintenance scheme, which is as automatic as you can get without becoming an incomprehensible beast. In fact, cran2deb is so good that Im seriously tempted to go back to Debian (after almost 8 years of Debian use, Ubuntu's ease-of-use, easy access to no-so-exotic hardware drivers (and the then-incessant politically correct yack-yacking on some Debian mailing lists...) made me switch to an early Ubuntu distribution). I did not yet switch back (mostly for not-so-superficial hardware support reasons), but I maintain a backup Debian installation for the hell of it and to test waters. So far, they have been a lot less rough than they used to be, but there are still occasional rows (e. g. a recent gotcha with openoffice.org, which would have render myself unable to work with those d*mn Word files for about a month, or forced me to do a maual repair (which I hate...)). So consider Debian as a (desirable) alternative to Ubuntu. HTH, Emmanuel Charpentier, DDS, MSc affiliation withdrawn, notwithstanding Frank Harrell's whims... __ 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] using RKWard for a function plot
Is it possible to use the RKWard GUI to just plot a function? I will have some exponential function, I need to plot u as a function of y where u= -2yg exp(-y^2/beta) - f where everything else other than u and y are various constants. *--* Kayven Riese, BSCS, MS (Physiology and Biophysics) (415) 902 5513 cellular http://kayve.net Webmaster http://ChessYoga.org __ 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] using RKWard for a function plot
On Tue, 16 Mar 2010, KAYVEN RIESE wrote: Is it possible to use the RKWard GUI to just plot a function? I will have some exponential function, I need to plot u as a function of y where u= -2yg exp(-y^2/beta) - f where everything else other than u and y are various constants. *--* Kayven Riese, BSCS, MS (Physiology and Biophysics) (415) 902 5513 cellular http://kayve.net Webmaster http://ChessYoga.org *--* *--* Kayven Riese, BSCS, MS (Physiology and Biophysics) (415) 902 5513 cellular http://kayve.net Webmaster http://ChessYoga.org __ 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] [R-pkgs] New package: ordinal
This is to announce the new R-package ‘ordinal’ that implements cumulative link (mixed) models for ordinal (ordered categorical) data (http://www.cran.r-project.org/package=ordinal/). The main features are: - scale (multiplicative) as well as location (additive) effects - nominal effects for a subset of the predictors (denoted partial proportional odds when the link is the logistic) - structured thresholds, e.g. assuming symmetry or equidistant thresholds - random effects via the Laplace approximation and adaptive Gauss-Hermite quadrature in the location-part of the model. - a range of standard link functions - flexible link functions where an extra link function-parameter bridges the log-log, probit and c-loglog links (log-gamma), and cloglog and logistic links (Aranda-Ordaz) - a suite of optimizers including an efficient Newton scheme. - works for binomial observations (a special case of ordinal data). - a suite of methods including anova, addterm, dropterm, profile, confint, plot.profile, predict, in addition to the standard print and summary methods. - an important special case is the proportional odds model (with random effects). - a range of examples illustrates how to use the functions. Future additions will include: - more general random effect structures: multiple (crossed and nested) and vector-valued random effects. - profile methods for variance parameters in mixed effect models. - helpful package vignettes. - implementation of core functions in C. Comments, critique, suggestions, wishes and contributions are always highly appreciated. Kind regards Rune -- Rune Haubo Bojesen Christensen PhD student, M.Sc. Eng. Phone: (+45) 45 25 33 63 Mail: rhbc at imm.dtu.dk DTU Informatics, Section for Statistics Technical University of Denmark, Build. 305, Room 122, DK-2800 Kgs. Lyngby, Denmark ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] Is there a way to edit a specific line in a function (e.g: doing function-text-edit-function) ?
That did it. Thanks Henrique! Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Tue, Mar 16, 2010 at 11:34 PM, Henrique Dallazuanna www...@gmail.comwrote: Try this: body(foo)[[grep('^line2', body(foo))]][[3]] - 2 On Tue, Mar 16, 2010 at 6:31 PM, Tal Galili tal.gal...@gmail.com wrote: Hello, Let's say we have the following function: foo - function(x) { line1 - x line2 - 0 line3 - line1 + line2 return(line3) } And that we want to change the second line to be: line2 - 2 How would you do that? The two ways I know of are either to use fix(foo) And change the function. Or to just write the function again. Is there another way? *What I would like* is for some way to represent the function as a vector of strings (well, characters), then change one of it's values, and then turn it into a function again. The reason I am asking is that I just published a post online where I used a function to which I did a minor tweak (so to improve it's output for my particular case). This tweaking was just adding one line of code, to a function who's length is 187 lines of code. So instead of repasting all the function on my blog, I decided to just explain how to edit it. But I would rather have a simple code that edited the function for the reader. Thanks, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] Is there a way to edit a specific line in a function (e.g: doing function-text-edit-function) ?
On 16/03/2010 5:31 PM, Tal Galili wrote: Hello, Let's say we have the following function: foo - function(x) { line1 - x line2 - 0 line3 - line1 + line2 return(line3) } And that we want to change the second line to be: line2 - 2 How would you do that? The two ways I know of are either to use fix(foo) And change the function. Or to just write the function again. That's the best way. Is there another way? You can use findLineNum to find where that line of source appears in your workspace. For example, if I source your input from the above, the line that interests you is line 9 of my foo.R input file. Then source(c:/temp/foo.R) findLineNum(foo.R#9) c:\temp\foo.R#9: foo step 3 in environment: R_GlobalEnv body(foo)[[3]] line2 - 0 Now I can replace step 3 using body(foo)[[3]] - quote(line2 - 2) If the line you want is nested deep within a block structure, you might need to use a vector index to get to it, e.g. after wrapping that line in an if() { }, I see findLineNum(foo.R#10) c:\temp\foo.R#10: foo step 3,3,2 in environment: R_GlobalEnv body(foo)[[c(3,3,2)]] - quote(line2 - 2) foo function (x) { line1 - x if (x 0) { line2 - 2 } line3 - line1 + line2 return(line3) } The findLineNum() function depends on having source references in the function, so it won't work on functions in packages unless you build them with the option to keep package source refs. (And then you need special contortions to tell it to look in the namespace for the function, and to edit a function in the namespace. Better not to do that.) Duncan Murdoch *What I would like* is for some way to represent the function as a vector of strings (well, characters), then change one of it's values, and then turn it into a function again. The reason I am asking is that I just published a post online where I used a function to which I did a minor tweak (so to improve it's output for my particular case). This tweaking was just adding one line of code, to a function who's length is 187 lines of code. So instead of repasting all the function on my blog, I decided to just explain how to edit it. But I would rather have a simple code that edited the function for the reader. Thanks, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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] How can I save the result for goodness of fit test
Hi pinusan, If it is possible, please add the code you used and output so to help people here help you. In general, take the object you got, put it inside str and see where you statistic is (but for us to write the code, it would help if you where to add it to your massage) Best, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Tue, Mar 16, 2010 at 9:31 PM, pinusan anh...@msu.edu wrote: Dear All, I run the goodness of fit test using goodfit() in vcd package. The result is as follow: Goodness-of-fit test for poisson distribution X^2 df P( X^2) Pearson 1.053348 2 0.5905661 Warning message: In summary.goodfit(gf) : Chi-squared approximation may be incorrect I want to save the the test statistics(X^2), df, and p-value. How can I save the result. Actually, I want to make a table. In addition, there is warning message In summary.goodfit(gf) : Chi-squared approximation may be incorrect. How can I interpret this result. Have a nice day. -- View this message in context: http://n4.nabble.com/How-can-I-save-the-result-for-goodness-of-fit-test-tp1595429p1595429.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. [[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.