Re: [R] Filling empty List in a FOR LOOP
Ok. I appreciate your help. i don't understand what you guys mean by reproducible example, if you explained better, I will be more than glad to post it. Regards, -- View this message in context: http://r.789695.n4.nabble.com/Filling-empty-List-in-a-FOR-LOOP-tp4522694p4524532.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] Filling empty List in a FOR LOOP
Hello, michaelyb wrote Ok. I appreciate your help. i don't understand what you guys mean by reproducible example, if you explained better, I will be more than glad to post it. Regards, Try this: R A - list(a=NULL, b=NULL) R A R dput(A) Now, the output of 'dput' is a reproducible data example, just copy/paste/assign with '-' R X - structure(list(a = NULL, b = NULL), .Names = c(a, b)) And test the suggestions above. (Just the first.) R lapply(X, function(ll) ifelse(is.null(ll),NA,ll)) # works Use 'dput' and copypaste it's output here, in your post, for us to have an exact example of your data. Clear enough? Rui Barradas. -- View this message in context: http://r.789695.n4.nabble.com/Filling-empty-List-in-a-FOR-LOOP-tp4522694p4524695.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] simulate correlated binary, categorical and continuous variable
Hello David Duffy-2, I see that you just proved using rmvnorm and then dichotomize/categorize them should work. Thanks but please take a look at this link; http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/CatContinuous and this article; Analysis by Categorizing or Dichotomizing Continuous Variables Is Inadvisable: An Example from the Natural History of Unruptured Aneurysms by O. Naggaraa,b, J. Raymonda, F. Guilberta, D. Roya, A. Weilla and D.G. Altmanc 2011. Plus; here is my explanatory code. require(mvtnorm) sigm=matrix(c(0.12, 0.05, 0.02, 0.00, 0.05, 1.24, 0.38,0.00, 0.02, 0.38, 2.38, 0.03, 0.00, 0.00,0.03, 0.16), ncol=4, byrow=T) mu=rep(0,4) #simulated data dat1 = rmvnorm(1000,mean=mu,sigma=sigm) #difference between sigmas before dichotimize/categorize sigm-cov(dat1) #difference between means before dichotimize/categorize means1=apply(dat1,2,mean) mu-means1 #dichotimization and categorization #lets dichotimize the third variable #I wantto keep mean the same (0.50) dat2=dat1 dat2[,3]=ifelse(dat1[,3]0.0,0,1) means2=apply(dat2,2,mean) mu-means2 # I kept the mean same, but look at the difference in cov matricies sigm-cov(dat2) -- View this message in context: http://r.789695.n4.nabble.com/simulate-correlated-binary-categorical-and-continuous-variable-tp4516433p4524882.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] Selecting files with a particular string in filename
I am trying to find an efficient way to select certain text files from a folder with thousands of text files. I used file.list function with a specific pattern to obtain 70 files for each of the i's in 1:100. Next, I need to select some files from this list of 70 files. The files to be selected do have a unique pattern in their file name. However, I cannot use list.files function because it looks for a specific path. Any help is appreciated. Thanks in advance. - Kumar for (i in 1:100) { name_rep = paste(rep_,i,_,sep=) files - list.files(path=C:\\Users\\Binn\\Desktop\\script_output, pattern= name_rep, full.names=TRUE ) natfiles - list.files(path=files, pattern= _natrain.csv, full.names=TRUE ) OPERATIONS HERE } -- Section of Integrative Biology University of Texas at Austin Austin, Texas 78712, USA [[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 export plot outputs as gif
Hi, I really need to export plot image as gif. I know that other image forms are available with functions like png(), jpeg() etc. However, The reason that I only need the gif form is gimage function in gWidgetstcltk library only works with gif or pnm. I want to load some plot images to gwindow. Is there a way to solve this problem? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/How-to-export-plot-outputs-as-gif-tp4525168p4525168.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] Degrees of Freedom for lme.
thanks. well, basically. i ran this analysis once before, with just general linear model, but nothing stuck after multiple comparisons. the question is: do reading scores predict volume change over time (in canonical reading regions). so i tried again, using linear mixed effects, adding subjects with only 1 time point, and with UID as the random effect--so it increased my sample size so to speak. but i find nothing significant. no slopes are significant, and if they are, they won't stick with MC. but the degrees of freedom are odd, i think, for the data i have, and i wondered if that was skewing results. i don't know. feeling officially discouraged because it's odd that there is NOTHING there...given what we know about brain maturation and how it relates to emerging cognitive skill (i.e., reading). and maybe i'm just not accepting that there is nothing there, and trying to blame on the analysis i'm running. On Sun, Apr 1, 2012 at 10:40 AM, bbolker [via R] ml-node+s789695n4523974...@n4.nabble.com wrote: SHouston suzannehouston at gmail.com writes: I am trying to run a linear mixed effect model on data. I have 17 longitudinal subjects and 36 single subjects, and this is the code I'm using (below). So, INDEX1 is the column with brain volumns, and the predictors are gort and age, by time ID (time they were seen). I believe my data is set up the right way, but when I run it, I get DF for Intercept is 49, and DF for slope is 13? Why? lme.gort=lme(Volume ~ GORT_FLUENCY+AGE, random = ~ 1 | TIMEID, data = subset(vol_data, INDEX1=='LH_FUSIFORM'), na.action=na.omit) fit_vol_model1 - function(df){ tryCatch(lme.gort - lme(Volume ~ GORT_FLUENCY+AGE, random = ~ 1 | UID, data=df, na.action=na.omit), error=function(err) tag -1) data.frame(Term = rownames(anova(lme.gort)), anova(lme.gort)) + } models = list() models$anova = ddply(vol_data, c(INDEX1), fit_vol_model1) summary(lme.gort) The rules according to which lme calculates degress of freedom are on p. 91 of Pinheiro and Bates 2000 (also on Google Books, http://tinyurl.com/ntygq3). You should be able to work it out from there ... (It's not actually clear what your question was -- are you wondering why you have different df for different effects?) Follow-ups should probably go to r-sig-mixed-models at r-project.org __ [hidden email] http://user/SendEmail.jtp?type=nodenode=4523974i=0mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Degrees-of-Freedom-for-lme-tp4522671p4523974.html To unsubscribe from Degrees of Freedom for lme., click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4522671code=c3V6YW5uZWhvdXN0b25AZ21haWwuY29tfDQ1MjI2NzF8LTEwMDY2NTU1Mjc= . NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- View this message in context: http://r.789695.n4.nabble.com/Degrees-of-Freedom-for-lme-tp4522671p4524668.html Sent from the R help mailing list archive at Nabble.com. [[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] get data from Perl arrays
Hi, a very simple doubt, but I do not know how to manage this. I want to plot a histogram for all data in 'datos.txt'. a) by using R: datos-scan(datos.txt) pdf(xh.pdf) hist(datos) dev.off() b) How could I invoke R inside Perl to do the same?? #!/usr/bin/perl open(DAT,datos.txt); while (DAT) { chomp; push(@datos,$_); } #now I want a histogram of values in @datos Thanks!! JR -- José Ramón Blas - PhD Dept. Biochemistry - Medicine School University of Castilla-La Mancha C Almansa, 14 02006 Albacete (Spain) Phone: +34 967599200 ext. 2958 [[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] NaN - trouble fixing NaN
Hi R-listers, I am using the package plyr. I am just trying to get the hatching success mean of each nesting event and have typed in the following and received the below results: tapply(HSuccess, Aeventexhumed, mean) AB C 0.2156265 0.1288559 NaN What can I do about NaN? I should be able to get a result for event C because I was able to make a boxplot graph with this information showing all three nesting events (A, B, and C). Please advise, Jean -- View this message in context: http://r.789695.n4.nabble.com/NaN-trouble-fixing-NaN-tp4524713p4524713.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] Non-linear least squares
Greetings, I am having some troubles with the nls() function in R V 2.14.2. I am doing some modelling where I want to predict the mass of leaf litter on the forest floor (X) as a function of time since fire (t). Fortunately, I have a differential equation that I can fit to the data which is acceptable on theoretical grounds. It is: X(t) = (L/k)[1-exp(-kt)], where L is the litter fall rate (t/ha/yr) and k is the decomposition rate (/yr). I have two problems: (1) I have experimental error in both X and t. Is there a way to take this into account with nls? (2) Is there a way to constrain the parameter estimates from nls? For example, for a data snippet: X = 4.6 4.1 4.7 11.0 t = 1.5 4.5 7.0 8.0 After I run nls I get: L = 0.873 k = -0.059 The estimate for L is ok, but k (by definition) should be greater than 0. Is there a way around this? Many thanks, Nic Surawski. -- View this message in context: http://r.789695.n4.nabble.com/Non-linear-least-squares-tp4524812p4524812.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] simulate correlated binary, categorical and continuous variable
Hello Greg, Sorry for the confusion. Lets say, I have a population. I have 6 variables. They are correlated to each other. I can get you pearson correlation, tetrachoric or polychoric correlation coefficients. 2 of them continuous, 2 binary, 2 categorical. Lets assume following conditions; Co1 and Co2 are normally distributed continuous random variables. Co1-- N (0,1), Co2--N(100,15) Ca1 and Ca2 are categorical variables. Ca1 probabilities =c(.02,.18,.28,.22,.30), Ca2 probs =c(.06,.18,.76) Bi1 and Bi2 are binaries, Marginal probabilities Bi1 p= 0.4, Bi2 p=0.5. And , again, I have the correlations. When I try to simulate this population I fail. If I keep the means and probabilities same I lost the correct correlations. When I keep correlations, I loose precision on means and frequencies/probabilities. See these links please http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/copulademo.html http://stats.stackexchange.com/questions/22856/how-to-generate-correlated-test-data-that-has-bernoulli-categorical-and-contin http://www.springerlink.com/content/011x633m554u843g/ -- View this message in context: http://r.789695.n4.nabble.com/simulate-correlated-binary-categorical-and-continuous-variable-tp4516433p4524863.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 adjust the stack size of R
On Mon, 2 Apr 2012, Xiaobo Gu wrote: You would need do compile your own copy of R and increase the stack size, Can we do this at runtime? That depends on your unstated OS. Uwe gave you an answer for Windows. On many other OSes, the stack size is set up by the OS when the process is started, and your OS documentation will tell you how to increase it. You need at least 76252 obs and that means the design matrix needs 46 Gbyte! Hence a sensible calculation is not really possible unless you have really big machines around. We do have big machines, but we don't have more obs for this data, so we will revise the algorithm to try less combinations data set size. He didn't say 'big machine'! I doubt it you could do anything useful with less than 512GB RAM. But more seriously, fitting a GLM (this message gives no context, but I think that was the task) is a O(p^3) calculation, so you would also need a great deal of patience. Regards, Xiaobo Gu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] linear-by-linear association model in R?
Dear all, can somebody give me some pointer how I can fit a linear-by-linear association model (i.e. loglinear model for the ordinal variables) in R? A brief description can be found here 'https://onlinecourses.science.psu.edu/stat504/node/141'. Thanks for your help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 adjust the stack size of R
Hi Uwe, you said 'You need at least 76252 obs and that means the design matrix needs 46 Gbyte! ' Can you please explain me how you come up with these 2 numbers? Is the number '76252 = 76251 + 1 (1 for the intercept in the model)' somehow related with the Saturated model? Thanks, On Sun, Apr 1, 2012 at 10:46 PM, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 01.04.2012 08:46, Xiaobo Gu wrote: 2012/3/31 Uwe Liggeslig...@statistik.tu-dortmund.de On 30.03.2012 03:16, Xiaobo Gu wrote: Hi, I got a stack overflow error when training a glm model with a very long formula. I just tried with a formula of length 1000. How long was yours? Which version of R? Where is the repdroducible example? We have a glm formula with 76251 terms, the text of the formula is about 150K, we are using R 2.14.2 Xiaobo Gu You would need do compile your own copy of R and increase the stack size, on the slow machines around here, it takes even hours just to parse the formula. Aynway, I canmnot believe you have a sufficient number of observations in the end: You need at least 76252 obs and that means the design matrix needs 46 Gbyte! Hence a sensible calculation is not really possible unless you have really big machines around. Best, Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to adjust fontsize of direct.label annotations in ggplot2?
Hello! I'm using direct.label() to annotate a ggplot, but I can't get it to change fontsize of annotations even tho I'm running the example from ?directlabels::dlcompare. Like this: library(lattice) library(ggplot2) oldopt - lattice.options(panel.error=NULL) dts - cbind(male=mdeaths,female=fdeaths,time=1:length(mdeaths)) require(reshape2) ddf - melt(as.data.frame(dts),id=time) names(ddf) - c(time,sex,deaths) plots - list(lattice= xyplot(deaths~time,ddf,groups=sex,type=l,xlim=c(-15,80)), ggplot2= qplot(time,deaths,data=ddf,colour=sex,geom=line)+xlim(-10,80)) if(names(dev.cur())!=postscript){##to avoid error on pkg check ## Try some more exotic labeling options. exotic - list(last.points, rot=c(0,180), fontsize=c(10,20), fontface=c(bold,italic), fontfamily=c(mono,serif), alpha=c(0.25,1)) dlcompare(plots,list(exotic)) } This will change fontface, fontfamily etc but not fontsize. Is it broke, or is there some other way to change fontsize? I'm using RStudio 0.95.262. Best regards, Kristoffer Magnusson __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 get AIC value for AR model
attached file:- http://r.789695.n4.nabble.com/file/n4525253/1A1I_A.txt 1A1I_A.txt arr-ar(t$V1) str(arr) arr$aic 0 1 2 3 4 5 6 4.273791 4.397484 2.258405 3.008703 1.884487 0.00 1.476055 7 8 910111213 3.204865 3.544783 5.474194 3.787079 3.873081 5.872812 7.085577 141516171819 8.762945 10.758352 11.484045 12.837440 7.465485 8.729661 but which is perfect aic value to take ? ? ? ? ? -- View this message in context: http://r.789695.n4.nabble.com/how-can-i-get-AIC-value-for-AR-model-tp4525253p4525253.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] [R-pkgs] New package joineR
Dear All, The 'joineR' package for the joint analysis of repeated measurements and time-to-event outcomes is now available on CRAN. The package contains utilities for creating and manipulating 'jointdata' objects, graphical summaries, a variogram function for estimating correlation structure, and maximum likelihood estimation for a class of random effects joint models. Best wishes, Pete. Pete Philipson Lecturer in Statistics School of Computing, Engineering and Information Sciences Northumbria University email: pete.philip...@northumbria.ac.uk [[alternative HTML version deleted]] ___ 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] get data from Perl arrays
On 4/2/2012 8:20 AM, José Ramón Blas Pastor wrote: Hi, a very simple doubt, but I do not know how to manage this. I want to plot a histogram for all data in 'datos.txt'. b) How could I invoke R inside Perl to do the same?? #!/usr/bin/perl open(DAT,datos.txt); while (DAT) { chomp; push(@datos,$_); } #now I want a histogram of values in @datos You can use Statistics::R for that, for example: use Statistics::R; my $R = Statistics::R-new(); $R-set( 'data', \@datos ); $R-run( q`d-hist(data)` ); $R-run( qq`png(histogram.png)` ); $R-run( qq`plot(d, main=Histogram)` ); $R-run( q`dev.off()` ); Cheers, Till __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 adjust the stack size of R
You would need do compile your own copy of R and increase the stack size, Can we do this at runtime? That depends on your unstated OS. Uwe gave you an answer for Windows. On many other OSes, the stack size is set up by the OS when the process is started, and your OS documentation will tell you how to increase it. We are running R on Windows 7 64bit Home basic and Windows Server 2003 64bit Xiaobo Gu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] date-time series plot
Hi all, i have a date-time series plot like this : Datum-Ura;padavine;P-kum-15dni;BLPV-1N;T-BLPV-1N;BLPV-4N;T-BLPV-4N;BLPV-5N;T-BLPV-5N;pretok;N-min;N-max 1.1.2011 18:00;0.0;0.0;174.62;14.60;174.56;14.10;174.64;14.20;299.26;174.18;181.78 2.1.2011 0:00;0.0;0.0;174.60;14.60;174.60;14.10;174.64;14.20;285.16;174.26;181.71 2.1.2011 6:00;0.0;0.0;174.60;14.60;174.64;13.90;174.64;14.20;313.82;174.4;182.07 2.1.2011 12:00;0.0;0.0;174.60;14.60;174.61;14.10;174.59;14.20;254;174.31;181.95 2.1.2011 18:00;0.0;0.0;174.59;14.60;174.57;14.10;174.63;14.20;265.25;174.23;182.01 3.1.2011 0:00;0.9;0.0;174.58;14.60;174.58;14.10;174.57;14.20;275.41;174.26;181.86 3.1.2011 6:00;0.0;0.0;174.57;14.60;174.60;14.00;174.62;14.20;300.21;174.37;181.9 3.1.2011 12:00;0.0;0.0;174.57;14.60;174.50;14.10;174.45;14.20;257.65;174.03;181.76 3.1.2011 18:00;0.0;0.0;174.54;14.60;174.51;14.10;174.59;14.20;274.9;174.23;182.06 I would like to create a multiple time series plot of all columns on the same chart. I have tried ts.plot command, which works for one axis. In the data frame i have different values, so I would also need secondary axis. My code for ts.plot is : ts.plot(DF2[,1:3], gpars=list(xlab=dan/4, ylab=, lty=c(1:4), col=c(1:4))) Can someone tell me how to create a secondary axis ? thank you -- View this message in context: http://r.789695.n4.nabble.com/date-time-series-plot-tp4525574p4525574.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] R2wd: Insert MS Word field
Hello Everyone, the basic idea is to generate an initial (MS Word) report by R (plots, tables and outline structure), pass this document around so everyone can add / change content (except plots and tables) and later to be able to update the R plot / table logic and update the already modified word file. I was toying around with the R2wd [1] package to test whether it is a viable way of writing the initial report from within R. Again, the idea is to generate a template from R with R2wd, and distribute that document to our co-students. They can then edit this file, i.e. add text, captions etc., but the tables and plots should be reproducible from within Word with the SWord [2] package. Now R2wd and SWord have some nice features and already work, but for the task described above a little bit is missing: SWord expects (noweb-like) code snippets to be in a Word `field'. So as the subject states, I need a way of inserting this word field from R2wd - something along the lines of: wdField(results = hide, fig = TRUE= plot(1:100)) sadly, I did not find that in the documentation. Any ideas or hints? Best Regards, Michael Bach [1] http://cran.r-project.org/web/packages/R2wd/index.html [2] http://cran.r-project.org/web/packages/SWordInstaller/index.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] Selecting files with a particular string in filename
Doesn't grep() solve your problem? cheers, Rolf Turner On 02/04/12 10:51, Kumar Mainali wrote: I am trying to find an efficient way to select certain text files from a folder with thousands of text files. I used file.list function with a specific pattern to obtain 70 files for each of the i's in 1:100. Next, I need to select some files from this list of 70 files. The files to be selected do have a unique pattern in their file name. However, I cannot use list.files function because it looks for a specific path. Any help is appreciated. Thanks in advance. - Kumar for (i in 1:100) { name_rep = paste(rep_,i,_,sep=) files- list.files(path=C:\\Users\\Binn\\Desktop\\script_output, pattern= name_rep, full.names=TRUE ) natfiles- list.files(path=files, pattern= _natrain.csv, full.names=TRUE ) OPERATIONS HERE } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Make package out of own function
Hello, I already posted that on stackoverflow[1], but although it's crossposting, I think this question can probably easier to be answered by other R-users on this list, which maintain packages etc. I would like to make a package out of a function. The function is working in a script, but when I install and load it as library() I get an error. The example-function is: #Make generic function f - function(x,...) UseMethod(f) #Default method f.default - function(a,b=5,c=3,...){ out - a+b+c class(out) - f out } # Print method print.f - function(x,...){ cat(Result for f: ) print(unclass(x)) } In the NAMESPACE for export I set f. When I try to run the function from the package I get: Error in UseMethod(f) : no applicable method for 'f' applied to an object of class c('double', 'numeric') here some additional info: sessionInfo() R version 2.14.2 (2012-02-29) Platform: i386-apple-darwin9.8.0/i386 (32-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] fishmove_0.0-1 plyr_1.7.1 ggplot2_0.9.0 loaded via a namespace (and not attached): [1] colorspace_1.1-1 dichromat_1.2-4digest_0.5.1 grid_2.14.2 MASS_7.3-17 [6] memoise_0.1munsell_0.3proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1 [11] scales_0.2.0 stringr_0.6 Can anyone explain me how to solve that resp. how to make my own function into a package? Best regards, Johannes [1]: http://stackoverflow.com/questions/8430178/arguments-and-classes-for-writing-generic-functions-in-r -- Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] partial likelihood device
Hello, I would like to get the partial likelihood device. fit - coxph(Surv(stop,event)~rx+size+number,data=bladder) Does fit$loglik give the partial likelihood device? Many thanks, Dunia [[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 model check in cozigam
Hi to all, I'd like to check my cozigam model with a continuous response. If I only had a GAM I could do gam.check(b), but with cozigam I'm not getting a way to check for residuals, fitted values, qq plot.. Even if I have to do it separately for zeros and non-zeros part, how can I assure that the family (and/or the data transformation) I chose is the best one? Does anyone knows how to do it? thanks a lot, barbara [[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] table: output: all variables in rows
Dear people, I would like to create a table out of a data.frame. How can I determine, which variables are put in the rows and which in the columns? I would like to get all the variables in the ROWS: I am including a simple example: D-data.frame(age=c(8,9,10),county=c(B,W,W)) the output should have the following structure: 8 B 1 8 W 0 9 B 0 9 W 1 10 B 0 10 W 1 Thank you very much for your help in advance! Marion [[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 put latex mdframed side by side (separated by space) ?
Hi, I have one query regarding latex. I am working on latex and i need to put two mdframes side (separated by space) on A4 paper size. How can i implement it? Thanks -- View this message in context: http://r.789695.n4.nabble.com/How-to-put-latex-mdframed-side-by-side-separated-by-space-tp4525415p4525415.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] how to read netcdf file in R
Dear R Users, I am using R 2.14.1 on windows How to read netcdf files in R ? Which packeges do we need to install for this, and what commands are used for reading netcdf files. Thanks, Best Regards, Yogesh Tiwari -- Yogesh K. Tiwari (Dr.rer.nat), Scientist, Centre for Climate Change Research, Indian Institute of Tropical Meteorology, Homi Bhabha Road, Pashan, Pune-411008 INDIA Phone: 0091-99 2273 9513 (Cell) : 0091-20-25904452 (O) Fax: 0091-20-258 93 825 [[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] Bootstrapped Tobit regression - get standard error 0...
I am trying to work out a bootstrapped Tobit regression model. I get the coefficients all right, but they all have standard error zero. And I am unable to figure out why. I know the coefficients are correct because that's what I get when do a Tobit (without bootstrapping). Here's my code: # Bootstrap 95% CI for Tobit regression coefficients? library(boot) library(AER) # for the Affairs dataset data(Affairs) # function to obtain regression weights bs - function(formula, data, indices) { d - data[indices,] fit - tobit(formula, data=Affairs) return(coef(fit)) } # bootstrapping with 1000 replications results - boot(data=Affairs, statistic=bs, R=1000, formula=affairs~age+yearsmarried+religiousness+occupation+rating) # view results results That gives me the right coefficients, but the SEs are all zero, so I cannot get 95% confidence intervals... Any help is welcome... Ravi -- View this message in context: http://r.789695.n4.nabble.com/Bootstrapped-Tobit-regression-get-standard-error-0-tp4525760p4525760.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] Bootstrapped Tobit regression - get standard error 0...
On Mon, 2 Apr 2012, Ravi Kulkarni wrote: I am trying to work out a bootstrapped Tobit regression model. I get the coefficients all right, but they all have standard error zero. And I am unable to figure out why. I know the coefficients are correct because that's what I get when do a Tobit (without bootstrapping). Here's my code: # Bootstrap 95% CI for Tobit regression coefficients? library(boot) library(AER) # for the Affairs dataset data(Affairs) # function to obtain regression weights bs - function(formula, data, indices) { d - data[indices,] fit - tobit(formula, data=Affairs) return(coef(fit)) } # bootstrapping with 1000 replications results - boot(data=Affairs, statistic=bs, R=1000, formula=affairs~age+yearsmarried+religiousness+occupation+rating) # view results results That gives me the right coefficients, but the SEs are all zero, so I cannot get 95% confidence intervals... In the AER book in Chapter 7.2 we have an example for a linear regression where boot() is used on an lm() model. This can easily be adapted here: ## refit function and bootstrap refit - function(data, i) coef(tobit( affairs ~ age + yearsmarried + religiousness + occupation + rating, data = data[i,])) m1 - boot(Affairs, refit, R = 1000) ## original model m2 - tobit(affairs ~ age + yearsmarried + religiousness + occupation + rating, data = Affairs) ## compare results m1 coeftest(m2) Hope that helps, Z Any help is welcome... Ravi -- View this message in context: http://r.789695.n4.nabble.com/Bootstrapped-Tobit-regression-get-standard-error-0-tp4525760p4525760.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.
Re: [R] linear-by-linear association model in R?
On 4/2/2012 3:34 AM, Christofer Bogaso wrote: Dear all, can somebody give me some pointer how I can fit a linear-by-linear association model (i.e. loglinear model for the ordinal variables) in R? A brief description can be found here 'https://onlinecourses.science.psu.edu/stat504/node/141'. Thanks for your help See my short course, http://www.datavis.ca/courses/VCD/ in particular, http://www.datavis.ca/courses/VCD/R/mental-glm.R # fit linear x linear (uniform) association. Use integer scores for rows/cols Cscore - as.numeric(Mental$ses) Rscore - as.numeric(Mental$mental) linlin - glm(Freq ~ mental + ses + Rscore:Cscore, family = poisson, data = Mental) -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca 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] how to read netcdf file in R
Yogesh, The package I most commonly use for reading and working with netcdfs is called ncdf. It has a collection of commands for working with netcdf files, but the open command is open.ncdf in this package Adrienne -- Adrienne Wootten Graduate Research Assistant State Climate Office of North Carolina Department of Marine, Earth and Atmospheric Sciences North Carolina State University On Mon, Apr 2, 2012 at 4:54 AM, Yogesh Tiwari yogesh@googlemail.com wrote: Dear R Users, I am using R 2.14.1 on windows How to read netcdf files in R ? Which packeges do we need to install for this, and what commands are used for reading netcdf files. Thanks, Best Regards, Yogesh Tiwari -- Yogesh K. Tiwari (Dr.rer.nat), Scientist, Centre for Climate Change Research, Indian Institute of Tropical Meteorology, Homi Bhabha Road, Pashan, Pune-411008 INDIA Phone: 0091-99 2273 9513 (Cell) : 0091-20-25904452 (O) Fax : 0091-20-258 93 825 [[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] ff usage for glm
Thomas, I tried biglm and it does not work see http://r.789695.n4.nabble.com/unable-to-get-bigglm-working-ATTN-Thomas-Lumley-td2276524.html#a2278381 . There are other posts from people who cannot get biglm working and others who get strange results. Please, advise if you can help. I have row based native code which works, but it is inconvenient as it does not produce an R object, which can be fed to anova etc. offered it to the developer forum, but message is still waiting for mod approval. regards Stephen B -Original Message- From: Thomas Lumley [mailto:tlum...@uw.edu] Sent: Friday, March 30, 2012 7:32 PM To: Bond, Stephen Cc: r-help@r-project.org Subject: Re: [R] ff usage for glm On Sat, Mar 31, 2012 at 9:05 AM, Bond, Stephen stephen.b...@cibc.com wrote: Greetings useRs, Can anyone provide an example how to use ff to feed a very large data frame to glm? The data.frame cannot be loaded in R using conventional read.csv as it is too big. glm(...,data=ff.file) ?? I shouldn't think glm() will work on data that are too big to read into R. However, bigglm() from the biglm package should work. You just need to write a function that supplies chunks of data from ff.file as requested (see the example on ?bigglm). I haven't used ff, but it looks from the documentation as though chunk() will do all the difficult parts. -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] NaN - trouble fixing NaN
Without seeing data, it's only a guess, but you should pass na.rm = TRUE to mean() so it will pass over NaNs in the data : tapply(HSuccess, Aeventexhumed, mean, na.rm=TRUE) Cheers, Michael On Sun, Apr 1, 2012 at 7:27 PM, Jhope jeanwaij...@gmail.com wrote: Hi R-listers, I am using the package plyr. I am just trying to get the hatching success mean of each nesting event and have typed in the following and received the below results: tapply(HSuccess, Aeventexhumed, mean) A B C 0.2156265 0.1288559 NaN What can I do about NaN? I should be able to get a result for event C because I was able to make a boxplot graph with this information showing all three nesting events (A, B, and C). Please advise, Jean -- View this message in context: http://r.789695.n4.nabble.com/NaN-trouble-fixing-NaN-tp4524713p4524713.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.
Re: [R] How to export plot outputs as gif
caTools::write.gif() Michael On Mon, Apr 2, 2012 at 12:41 AM, mrzung mrzun...@gmail.com wrote: Hi, I really need to export plot image as gif. I know that other image forms are available with functions like png(), jpeg() etc. However, The reason that I only need the gif form is gimage function in gWidgetstcltk library only works with gif or pnm. I want to load some plot images to gwindow. Is there a way to solve this problem? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/How-to-export-plot-outputs-as-gif-tp4525168p4525168.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.
Re: [R] ff usage for glm
Did you try the example described on the ff man page? On Monday, April 2, 2012, Bond, Stephen wrote: Thomas, I tried biglm and it does not work see http://r.789695.n4.nabble.com/unable-to-get-bigglm-working-ATTN-Thomas-Lumley-td2276524.html#a2278381 . There are other posts from people who cannot get biglm working and others who get strange results. Please, advise if you can help. I have row based native code which works, but it is inconvenient as it does not produce an R object, which can be fed to anova etc. offered it to the developer forum, but message is still waiting for mod approval. regards Stephen B -Original Message- From: Thomas Lumley [mailto:tlum...@uw.edu javascript:;] Sent: Friday, March 30, 2012 7:32 PM To: Bond, Stephen Cc: r-help@r-project.org javascript:; Subject: Re: [R] ff usage for glm On Sat, Mar 31, 2012 at 9:05 AM, Bond, Stephen stephen.b...@cibc.comjavascript:; wrote: Greetings useRs, Can anyone provide an example how to use ff to feed a very large data frame to glm? The data.frame cannot be loaded in R using conventional read.csv as it is too big. glm(...,data=ff.file) ?? I shouldn't think glm() will work on data that are too big to read into R. However, bigglm() from the biglm package should work. You just need to write a function that supplies chunks of data from ff.file as requested (see the example on ?bigglm). I haven't used ff, but it looks from the documentation as though chunk() will do all the difficult parts. -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ R-help@r-project.org javascript:; mailing list https://stat.ethz.ch/mailman/listinfo/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] How do I get a rough quick utility plot of a time series?
Thanks much for the reply. I did the ?ts and it seems to be for equal interval time series. Our time series are hardly ever equal interval. The time is in the first column used for the abscissa. Probably need the easiest simplest tier plot. When I say plot, it wants limits and stuff. I guess it can't figure it out by itself from the data. -- View this message in context: http://r.789695.n4.nabble.com/How-do-I-get-a-rough-quick-utility-plot-of-a-time-series-tp4522709p4526070.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] linear-by-linear association model in R?
dear Christofer, Try the following d-expand.grid(a=1:3,b=1:4) d$freq-rpois(12,5) o-glm(freq~factor(a)+factor(b)+I(a*b), family=poisson, data=d) vito Il 02/04/2012 9.34, Christofer Bogaso ha scritto: Dear all, can somebody give me some pointer how I can fit a linear-by-linear association model (i.e. loglinear model for the ordinal variables) in R? A brief description can be found here 'https://onlinecourses.science.psu.edu/stat504/node/141'. Thanks for your help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Università di Palermo viale delle Scienze, edificio 13 90128 Palermo - ITALY tel: 091 23895240 fax: 091 485726 http://dssm.unipa.it/vmuggeo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do I get a rough quick utility plot of a time series?
Hi, On Mon, Apr 2, 2012 at 9:49 AM, Hurr hill0...@umn.edu wrote: Thanks much for the reply. I did the ?ts and it seems to be for equal interval time series. Our time series are hardly ever equal interval. The time is in the first column used for the abscissa. Probably need the easiest simplest tier plot. When I say plot, it wants limits and stuff. I guess it can't figure it out by itself from the data. This is somewhat incomprehensible. Did you ever provide the requested reproducible example so we can see what's going on? It wants - does that mean you are getting error messages? Warnings? Your computer is talking to you? Please provide a full explanation, and include context. Most of the R-help participants receive this list by email. Sarah Sent from the R help mailing list archive at Nabble.com. Of course it was. -- Sarah Goslee http://www.functionaldiversity.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] How do I get a rough quick utility plot of a time series?
Convert your data to a zoo object and plot() that. ?zoo There's a whole bunch of documentation for plot.zoo available. Michael On Mon, Apr 2, 2012 at 9:49 AM, Hurr hill0...@umn.edu wrote: Thanks much for the reply. I did the ?ts and it seems to be for equal interval time series. Our time series are hardly ever equal interval. The time is in the first column used for the abscissa. Probably need the easiest simplest tier plot. When I say plot, it wants limits and stuff. I guess it can't figure it out by itself from the data. -- View this message in context: http://r.789695.n4.nabble.com/How-do-I-get-a-rough-quick-utility-plot-of-a-time-series-tp4522709p4526070.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] Unwanted page break in Rd2pdf
Hi, I want to create a pdf of my Man-pages from my package. Therefore I run in the terminal Rd2pdf on the package and a pdf of all the pages is created. After the titlepage there is the general package page, which includes Description and Details etc. Unfortunately after the Subtitle Details there is a pagebreak (and 3/4 white page) which I did not set there... Any recommendation how I can avoid this? best regards, /Johannes -- Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] A function like sum but with functions other than '+'
Michael Sumner mdsumner at gmail.com writes: Try ?Reduce Thanks Michael! --Sergio. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Unwanted page break in Rd2pdf
On 02/04/2012 9:57 AM, Johannes Radinger wrote: Hi, I want to create a pdf of my Man-pages from my package. Therefore I run in the terminal Rd2pdf on the package and a pdf of all the pages is created. After the titlepage there is the general package page, which includes Description and Details etc. Unfortunately after the Subtitle Details there is a pagebreak (and 3/4 white page) which I did not set there... Any recommendation how I can avoid this? I don't see this, so I can't offer any help without some details: what version of R are you using? Do you get the page break if you try Rd2pdf on that one file? What is in the file that gives the page break? 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.
[R] comparison of stochastic matrices
Dear List Members, i am looking for a statistical method or test wich helps me to verify the equality of two stochastic matrices (the sums in the rows = 1). Could you help me? Thanks! regards, galla -- View this message in context: http://r.789695.n4.nabble.com/comparison-of-stochastic-matrices-tp4525965p4525965.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 with fa.poly in psych package
I am attempting to use the psych package to do EFA on a set of data that mixes dichotomous and 5-value ordinal variables. I tried using fa.poly with disappointing results. When I use a data subset that consists solely of dichotomous or solely of 5-value variables, fa.poly works. However, when I have both variable types in the input, I always get the error Error in tab * log(P) : non-conformable arrays. It doesn't matter how I subset or slice the data. I rescale the dichotomous data to be 0=1, 1=4 (4 is the highest value of the ordinal set). No dice. The problem only occurs, and always occurs, when I mix structurally dichotomous data with structurally ordinal data. I have tried making the data ordered--psych didn't like that at all, it wants numbers. My command has always been fa.poly(foo,nfactors=1) So, why does it work for only dichotomous data and only ordinal data, but not a mixture of dichotomous and ordinal data? I have tried to sidestep this issue by generating a polychoric correlation matrix with the polycor package, but the same quirk appears. It works only when the 2-value and 5-value data are not combined. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] gamm: tensor product and interaction
Hi list, I'm working with gamm models of this sort, using Simon Wood's mgcv library: gm- gamm(Z~te(x,y),data=DATA,random=list(Group=~1)) gm1-gamm(Z~te(x,y,by=Factor)+Factor,data=DATA,random=list(Group=~1)) with a dataset of about 7 rows and 110 levels for Group in order to test whether tensor product smooths vary across factor levels. I was wondering if comparing those two models would be enough to conclude? I saw a preceding post on similar issues http://r.789695.n4.nabble.com/Comparing-and-Interpreting-GAMMs-td2234209.html but that example used simple s() smooths instead of tensor product smooths. In this case, the person was comparing between model A and model A1 like: A-gamm4(Z~factor+s(x)+s(x,by=factor) ,data=DATA, random=~(1|Group)) A1- gamm4(Z~factor+s(x) ,data=DATA, random=~(1|Group)) I thus also tried to compare my model gm1, with another gm2 model of that sort: gm2-gamm(Z~te(x,y)+te(x,y,by=Factor)+Factor,data=DATA,random=list(Group=~1)) but this type of models never converge and I obtain error messages of that sort: Error in MEestimate(lmeSt, grps) : Singularity in backsolve at level 0, block 1 2 questions from that: 1) Keeping in mind that my main question is to check whether tensor products smooths vary across factor levels, would the comparison of models gm and gm1 be sufficient for me? 2) Otherwise, is there something wrong in my gm2 model that make it impossible to converge?? Also, side question that I already posted a few days ago but didn't get an answer for: 3)I don't manage to use vis.gam() to print 3 different 2D-contour plots for the three levels of factors I have in model gm1. It works well with model gm (when only one plot is generated) but not gm1 (3 plots should be generated) Here is the error message I obtain: vis.gam(gm1$gam,plot.type=contour,n.grid=200,color=heat,zlim=c(0,4)) Error in predict.gam(x, newdata = newd, se.fit = TRUE, type = type) : number of items to replace is not a multiple of replacement length Thanks a lot if someone can help with that, Geraldine [[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] Limitation on number of variables and data points in clustering
Hi All, Is there a limit on number of variables and the number of data points for clustering in R? Thanks for your help in advance! -- View this message in context: http://r.789695.n4.nabble.com/Limitation-on-number-of-variables-and-data-points-in-clustering-tp4525874p4525874.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 can i get AIC value for AR model
If you look at the documentation for ar, you will find the following description of aic: aic The differences in AIC between each model and the best-fitting model So this means that your model order is 5 (look at the pacf). If you want the actual AIC of your model: (I call your datafile A.txt) d1 = read.table(A.txt, header=F) d1.ts = ts(d1$V1) pacf(d1.ts) d1.ar = arma(d1.ts, order = c(5,0)) summary(d1.ar) The summary tells you that your AIC is -226.87 Hope that helps, Ravi -- View this message in context: http://r.789695.n4.nabble.com/how-can-i-get-AIC-value-for-AR-model-tp4525253p4526042.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 do I get a rough quick utility plot of a time series?
I tried ?zoo, but it's not available. Do I do something to make it available? Thanks Sarah, it's incomprehensible to me too. That's why I showed you the data and asked. -- View this message in context: http://r.789695.n4.nabble.com/How-do-I-get-a-rough-quick-utility-plot-of-a-time-series-tp4522709p4526183.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 do I get a rough quick utility plot of a time series?
Yes, zoo is a package for irregular time series but it needs to be installed (only once) and loaded (again every new session) install.packages(zoo) # Will install library(zoo) # Do this every session Michael On Mon, Apr 2, 2012 at 10:31 AM, Hurr hill0...@umn.edu wrote: I tried ?zoo, but it's not available. Do I do something to make it available? Thanks Sarah, it's incomprehensible to me too. That's why I showed you the data and asked. -- View this message in context: http://r.789695.n4.nabble.com/How-do-I-get-a-rough-quick-utility-plot-of-a-time-series-tp4522709p4526183.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.
Re: [R] table: output: all variables in rows
On Apr 2, 2012, at 7:11 AM, Marion Wenty wrote: Dear people, I would like to create a table out of a data.frame. How can I determine, which variables are put in the rows and which in the columns? I would like to get all the variables in the ROWS: I am including a simple example: D-data.frame(age=c(8,9,10),county=c(B,W,W)) the output should have the following structure: 8 B 1 8 W 0 9 B 0 9 W 1 10 B 0 10 W 1 You can use the order() function with [ to rearrange this to suit you needs: as.data.frame(xtabs(~age+county, data=D)) age county Freq 1 8 B1 2 9 B0 3 10 B0 4 8 W0 5 9 W1 6 10 W1 [[alternative HTML version deleted]] Posting in HTML is considered impolite on Rhelp. -- 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] Limitation on number of variables and data points in clustering
You should probably read the posting guide, but the answer is Yes. -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Krati Agarwal Sent: Monday, April 02, 2012 7:31 AM To: r-help@r-project.org Subject: [R] Limitation on number of variables and data points in clustering Hi All, Is there a limit on number of variables and the number of data points for clustering in R? Thanks for your help in advance! -- View this message in context: http://r.789695.n4.nabble.com/Limitation-on-number-of-variables-and-data-poi nts-in-clustering-tp4525874p4525874.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.
Re: [R] How do I get a rough quick utility plot of a time series?
Thanks Michael, sounds right, will try later today when I have time. -- View this message in context: http://r.789695.n4.nabble.com/How-do-I-get-a-rough-quick-utility-plot-of-a-time-series-tp4522709p4526310.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] fatal error prevents multi-line functions or loop to run
Dear all, I have written some function that can go up to many lines. Two of the lines give warning errors like: Error in print()[c(1, : error in evaluating the argument 'x' in selecting a method for function 'print': Error in ... regions with no neighbours found now obviously this kind of error will halt the execution of the function. I tried *try()* or *tryCatch()* and many other selections in the *options()*but still this error by all means stops the execution of the function or any other multi-line code. I would appreciate if you could give me a clue. Ebrahim [[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] \Sexpr{}
Did anyone know whether the problem it doesn't evaluate \Sexpr{} in Sweave has been fixed? I checked r help page and realized it was asked a couple of years ago. But I didn't find solutions. Thanks for your help in advance! Hua [[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] gnm and gnlr3
Hi, I am quite new to R and would like to do nonlinear regressions with Poisson distributed data. I would like to estimate paramters of an equation of this type: FR = [c*NO * exp(a+b*NO)] / [(c+NO)*(1+exp(a+b*NO))] a,b and c are parameters, NO are input values I found both the gnm and gnlr3 function which should be able to do this regression but I can't manage to make it work. How can I write my equation to fit into these functions? If I understand it correct I have to split my equation in a mu, a shape and a family part for the gnlr function, but don't have a clue how to do this. Is there maybe a different function that is better for my purpose? A version of nls where I can choose a different distribution? Kind Regards Joachim Don't waste paper! Think about the environment before printing this e-mail __ Joachim Audenaert Adviesdienst Gewasbescherming Proefcentrum voor Sierteelt Schaessestraat 18 B-9070 Destelbergen Tel. +32 9 353 94 71 Fax +32 9 353 94 95 E-mail: joachim.audena...@pcsierteelt.be www.pcsierteelt.be __ [[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] Non-linear least squares
On 2012-04-01 17:31, n.surawski wrote: Greetings, I am having some troubles with the nls() function in R V 2.14.2. I am doing some modelling where I want to predict the mass of leaf litter on the forest floor (X) as a function of time since fire (t). Fortunately, I have a differential equation that I can fit to the data which is acceptable on theoretical grounds. It is: X(t) = (L/k)[1-exp(-kt)], where L is the litter fall rate (t/ha/yr) and k is the decomposition rate (/yr). I have two problems: (1) I have experimental error in both X and t. Is there a way to take this into account with nls? (2) Is there a way to constrain the parameter estimates from nls? For example, for a data snippet: X = 4.6 4.1 4.7 11.0 t = 1.5 4.5 7.0 8.0 After I run nls I get: L = 0.873 k = -0.059 The estimate for L is ok, but k (by definition) should be greater than 0. Is there a way around this? Yes. Plot your data, decide which you trust more: your data or theory. There is no way to use the given data to help substantiate the proposed theory. As to your other questions above: (1) If the uncertainty in your t values is small compared with that in the X values, then I would just ignore it. (2) To force a parameter to be positive, see ?SSasymp or for your case, perhaps ?SSasympOrig. Peter Ehlers Many thanks, Nic Surawski. -- View this message in context: http://r.789695.n4.nabble.com/Non-linear-least-squares-tp4524812p4524812.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.
Re: [R] NaN - trouble fixing NaN
Also, mean(x) will generate NaN's if both Inf and -Inf are in x. E.g., group - c(A,A,A, B,B,B, C,C, D,D) when - c( 1,2,3, -Inf,4,Inf, NA,5,NaN,6) tapply(when, group, mean) A B C D 2 NaN NA NaN tapply(when, group, mean, na.rm=TRUE) A B C D 2 NaN 5 6 boxplot() tosses out the +-Inf's. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of R. Michael Weylandt Sent: Monday, April 02, 2012 6:19 AM To: Jhope Cc: r-help@r-project.org Subject: Re: [R] NaN - trouble fixing NaN Without seeing data, it's only a guess, but you should pass na.rm = TRUE to mean() so it will pass over NaNs in the data : tapply(HSuccess, Aeventexhumed, mean, na.rm=TRUE) Cheers, Michael On Sun, Apr 1, 2012 at 7:27 PM, Jhope jeanwaij...@gmail.com wrote: Hi R-listers, I am using the package plyr. I am just trying to get the hatching success mean of each nesting event and have typed in the following and received the below results: tapply(HSuccess, Aeventexhumed, mean) A B C 0.2156265 0.1288559 NaN What can I do about NaN? I should be able to get a result for event C because I was able to make a boxplot graph with this information showing all three nesting events (A, B, and C). Please advise, Jean -- View this message in context: http://r.789695.n4.nabble.com/NaN-trouble-fixing-NaN- tp4524713p4524713.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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] rgl package broke with R 2.14.2
On Mar 28, 2012, at 10:15 AM, Duncan Murdoch wrote: On 12-03-27 6:31 PM, Grimes Mark wrote: Dear People I can't figure out how to fix this problem: rgl won't run under R 2.14.2 (it was working for me before under 2.14.0). The error message is: rgl is currently changing fairly rapidly. I'd suggest trying to install again (the current version, as of yesterday, is 0.92.861). If that's not enough, I'd install a binary build (which may be a little old, but at least it built successfully...). Duncan Murdoch Thanks for your continued efforts Duncan. I had tried compiling that version from source and gotten an error but when I attempted to install from the current binary image which is now rgl_0.92.861.tgz, I got apparent success, it loads without error, and the example in ?rgl runs. -- 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] how to read netcdf file in R
On Mon, Apr 2, 2012 at 1:54 AM, Yogesh Tiwari yogesh@googlemail.com wrote: How to read netcdf files in R ? Which packeges do we need to install for this, and what commands are used for reading netcdf files. Typical code would look something like this: library('ncdf'') filename - 'data.nc' varname - 'Temperature' ncid - open.ncdf( filename ) data - get.var.ncdf( ncid, varname ) If you need to see what variables the file contains to get the variable names, just do a print(ncid) after you open it. If it is a very large file, too large for the data to fit in memory all at once, you can step through and read each timestep in the file separately using the start= and count= arguments to the get.var.ncdf() call. Regards, --Dave -- David W. Pierce Division of Climate, Atmospheric Science, and Physical Oceanography Scripps Institution of Oceanography, La Jolla, California, USA (858) 534-8276 (voice) / (858) 534-8561 (fax) dpie...@ucsd.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error: (subscript) logical subscript too long
Hello, I am trying to perform a logistic regression using counts. For example: cedegren - read.table(http://www.cloudstat.org/index.php?do=/attachment/download/id_95 /, header=T) attach(cedegren) ced.del - cbind(sDel, sNoDel) ced.logr - glm(ced.del ~ cat + follows + factor(class), family=binomial(logit)) This works. However, if I change the family to Gaussian: ced.logr - glm(ced.del ~ cat + follows + factor(class), family=gaussian) I get the error: Error: (subscript) logical subscript too long I would like to use the probit function. Is this possible? Best regards, Ioanna __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] summaryBy: transformed variable on RHS of formula?
Hi Folks, I'm trying to cut my data inside the summaryBy function. Perhaps formulas don't work that way? I'd like to avoid adding another column if possible, but if I have to, I have to. Any ideas? Thanks, Allie require(doBy) df = dataframe(a - rnorm(100), b -rnorm(100)) summaryBy(a ~ cut(b,c(-100,-1,1,100)), data=df) # preferred solution, but it throws an error # Error in `[.data.frame`(data, , rh.var, drop = FALSE) : undefined columns selected df$c = cut(b,c(-100,-1,1,100)) summaryBy(a ~ c, data=df) # works fine __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] \Sexpr{}
Hi Hua, try options(SweaveSyntax=SweaveSyntaxNoweb) before sweaving your file (see A.14 in the FAQ section of the manual). In most cases R2HTML interferes with Sweave, causing your problem hth. Am 02.04.2012 15:12, schrieb Liang, Hua: Did anyone know whether the problem it doesn't evaluate \Sexpr{} in Sweave has been fixed? I checked r help page and realized it was asked a couple of years ago. But I didn't find solutions. Thanks for your help in advance! Hua [[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 -- Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] summaryBy: transformed variable on RHS of formula?
Sorry, no - you will have to do something like the latter suggestion. Regards Søren -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alexander Shenkin Sent: 2. april 2012 17:59 To: r-help@r-project.org Subject: [R] summaryBy: transformed variable on RHS of formula? Hi Folks, I'm trying to cut my data inside the summaryBy function. Perhaps formulas don't work that way? I'd like to avoid adding another column if possible, but if I have to, I have to. Any ideas? Thanks, Allie require(doBy) df = dataframe(a - rnorm(100), b -rnorm(100)) summaryBy(a ~ cut(b,c(-100,-1,1,100)), data=df) # preferred solution, but it throws an error # Error in `[.data.frame`(data, , rh.var, drop = FALSE) : undefined columns selected df$c = cut(b,c(-100,-1,1,100)) summaryBy(a ~ c, data=df) # works fine __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] summaryBy: transformed variable on RHS of formula?
On Mon, Apr 2, 2012 at 11:58 AM, Alexander Shenkin ashen...@ufl.edu wrote: Hi Folks, I'm trying to cut my data inside the summaryBy function. Perhaps formulas don't work that way? I'd like to avoid adding another column if possible, but if I have to, I have to. Any ideas? Thanks, Allie require(doBy) df = dataframe(a - rnorm(100), b -rnorm(100)) summaryBy(a ~ cut(b,c(-100,-1,1,100)), data=df) # preferred solution, but it throws an error # Error in `[.data.frame`(data, , rh.var, drop = FALSE) : undefined columns selected df$c = cut(b,c(-100,-1,1,100)) summaryBy(a ~ c, data=df) # works fine Try this: summaryBy(a ~ b, data = transform(df, b = cut(b, c(-100, -1, 1, 100 -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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 put latex mdframed side by side (separated by space) ?
Hi, as long as you don't want to stetch the frames across a page break, would minipges do? \documentclass[12pt]{article} \usepackage{lipsum} \begin{document} \begin{minipage}[t]{0.45\textwidth} \lipsum[1] \end{minipage} \hfill \begin{minipage}[t]{0.45\textwidth} \lipsum[2] \end{minipage} \end{document} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] simulate correlated binary, categorical and continuous variable
On Sun, Apr 01, 2012 at 06:00:43PM -0700, Burak Aydin wrote: Hello Greg, Sorry for the confusion. Lets say, I have a population. I have 6 variables. They are correlated to each other. I can get you pearson correlation, tetrachoric or polychoric correlation coefficients. 2 of them continuous, 2 binary, 2 categorical. Lets assume following conditions; Co1 and Co2 are normally distributed continuous random variables. Co1-- N (0,1), Co2--N(100,15) Ca1 and Ca2 are categorical variables. Ca1 probabilities =c(.02,.18,.28,.22,.30), Ca2 probs =c(.06,.18,.76) Bi1 and Bi2 are binaries, Marginal probabilities Bi1 p= 0.4, Bi2 p=0.5. And , again, I have the correlations. When I try to simulate this population I fail. If I keep the means and probabilities same I lost the correct correlations. When I keep correlations, I loose precision on means and frequencies/probabilities. Hi. One idea, which occured to me, is the following. Formulate a model of the joint distribution with some parameters and a criterion function, which measures how much the data generated from the model differ from the required marginal distributions and the required correlations. Then run an optimization of the parameters to minimize the difference. If you have enough data, then the model can be a table of estimated probabilities for all 5*3*2*2 = 60 combinations of the discrete variables and for each of these combinations the parameters of the conditional distribution on the 2 continuous variables, which can be a bivariate normal distribution. However, you probably do not have enough data for this. Another approach starts from the distribution of the continuous variables and the model for the discrete variables can be a logistic model using the continuous variables as input. Another type of a model, which may be suitable, is a Bayesian network. For this, you need to choose only a subset of the most important dependencies, so that the selected dependencies can be represented by a directed acyclic graph. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 brew call yields Error in .brew.cat(26, 28) : unused argument(s) (26, 28)
Many thanks for this. I have a follow-up question. The output that I have from the nested brew call includes output like this: NANANANANANANANAN ... then a graph or a table ... then more NANANANANANANANANNANANANANANANANANNANANANANANANANANNANANANANANANANAN ... etc. It only occurs in the nested brew calls, not in the top level document, which is absolutely fine. There are functions defined in the top level file which the lower level files make use of. I assumed the problem was caused by my not understanding the documentation to do with nested brew calls; evidently this is not the case. I have several functions within the top file, one for drawing graphs, one for tables, another for wordclouds, etc. They all generate this NANANANANANANA behaviour, I have tested by putting them in and out of the code. I tried to produce a minimal self contained example containing a function defined in the top level file used by a file called in a nested brew: however this file worked fine. I realise this isn't a lot to go on, but the functions are fairly long and it clearly isn't a specific issue with a particular function because they all do it. Has anyone else ever had this happen to them? If so did you find a solution (other than manually removing the NAs using a final piece of code, which admittedly is not too arduous). Many thanks, Chris Beeley, Institute of Mental Health, UK On 30/03/2012 02:27, Matt Shotwell wrote: On Wed, 2012-03-28 at 11:40 +0100, Chris Beeley wrote: I am writing several webpages using the brew package and R2HTML. I would like to work off one script so I am using nested brew calls. The documentation for brew states that: NOTE: brew calls can be nested and rely on placing a function named ’.brew.cat’ in the environment in which it is passed. Each time brew is called, a check for the existence of this function is made. If it exists, then it is replaced with a new copy that is lexically scoped to the current brew frame. Once the brew call is done, the function is replaced with the previous function. The function is finally removed from the environment once all brew calls return. I'm afraid I can't quite figure out what it is I'm supposed to do here. I've tried loading the brew library within the script which I pass to brew, and I've tried defining brew cat like this: The paragraph above describes what brew is doing behind the scenes. It's not necessary to modify or set the .brew.cat function. A nested (or recursive) brew call occurs when brew() is called from a document currently being processed by brew(). To illustrate further, suppose there are two brew documents, example-1.brew and example-2.brew, where example-1.brew contains the following text (delimited by '''): ''' This text is in example-1.brew. %= brew::brew(example-2.brew) % ''' and the example-2.brew contains ''' This text is in example-2.brew. %= date() -% ''' Then from the R prompt we have: Rbrew::brew(example-1.brew) This text is in example-1.brew. This text is in example-2.brew. Thu Mar 29 20:24:52 2012 .brew.cat=function(){} This generates the following error message: Error in .brew.cat(26, 28) : unused argument(s) (26, 28) I think perhaps it is more likely that I need to insert into the script the actual content of .brew.cat, but I can't seem to get R to tell me what it is and Googling throws up a lot of stuff about beer and not much else (drew a blank also from RSiteSearch(Nested brew)) Any help gratefully received. Chris Beeley Institute of Mental Health, 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] How to adjust the stack size of R
On 02.04.2012 10:04, Christofer Bogaso wrote: Hi Uwe, you said 'You need at least 76252 obs and that means the design matrix needs 46 Gbyte! ' Can you please explain me how you come up with these 2 numbers? Is the number '76252 = 76251 + 1 (1 for the intercept in the model)' somehow related with the Saturated model? If you want to estimate 76252 coefficients, you will need *at least* as many observations. hence I took at as a lower limit and calculated 76252*76252*8 for the required amount of storage given we expect floats in double precision as input. Is these are factors with more than 2 levels, there are even more parameters o estimate. Uwe Ligges Thanks, On Sun, Apr 1, 2012 at 10:46 PM, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 01.04.2012 08:46, Xiaobo Gu wrote: 2012/3/31 Uwe Liggeslig...@statistik.tu-dortmund.de On 30.03.2012 03:16, Xiaobo Gu wrote: Hi, I got a stack overflow error when training a glm model with a very long formula. I just tried with a formula of length 1000. How long was yours? Which version of R? Where is the repdroducible example? We have a glm formula with 76251 terms, the text of the formula is about 150K, we are using R 2.14.2 Xiaobo Gu You would need do compile your own copy of R and increase the stack size, on the slow machines around here, it takes even hours just to parse the formula. Aynway, I canmnot believe you have a sufficient number of observations in the end: You need at least 76252 obs and that means the design matrix needs 46 Gbyte! Hence a sensible calculation is not really possible unless you have really big machines around. Best, Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error: (subscript) logical subscript too long
On 2012-04-02 08:52, IOANNA wrote: Hello, I am trying to perform a logistic regression using counts. For example: cedegren- read.table(http://www.cloudstat.org/index.php?do=/attachment/download/id_95 /, header=T) attach(cedegren) ced.del- cbind(sDel, sNoDel) ced.logr- glm(ced.del ~ cat + follows + factor(class), family=binomial(logit)) This works. However, if I change the family to Gaussian: ced.logr- glm(ced.del ~ cat + follows + factor(class), family=gaussian) I get the error: Error: (subscript) logical subscript too long I would like to use the probit function. Is this possible? I think that you don't understand the 'family=' argument in glm (nor, perhaps, generalized linear models as such). Hint: check ?family. Peter Ehlers Best regards, Ioanna __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Prediction on link- and responselevel for glm
Dear R-ers, We are doing prediction of risk for aortic aneurysm in screened subjects based on different riskfactors. When we do the prediction on the linklevel and transform the prediction and the limits of the 95%- confidence intervall (with exponentiation and then transformation from odds to probability) we get asymmetric intervalls which seem reasonable. When we use prediction on the responselevel (which is be on the probability level) the intervalls are completely symmetric. The figures are also different. Is something wrong with the prediction or with my use of the glm program? Any help much appreciated! Sincerely yours Fredrik Lundgren This is for an individual with certain riskfactors Formation of confidence interval with linklevel (prob transforms from odds to probability) fit = -4.7513497 and se.fit = 0.2474956 point value lower limit upper limit prob(exp(-4.7513497)) prob(exp(-4.7513497-1.96*0.2474956)) prob(exp(-4.7513497+1.96*0.2474956)) Formation of confidence interval with responselevel fit = 0.008566015 and se.fit= 0.002101891 point value lower limit upper limit 0.008566015 p0.008566015-1.96*0.002101891 0.008566015+1.96*0.002101891 Fredrik Lundgren fredrik.bg.lundg...@gmail.com Engelbrektsgatan 31 582 21 Linköping tel 013 - 47 30 117 mob 0706 - 86 39 29 Sommarhus: Ljungnäs 158 380 30 Rockneby 0480 - 650 98 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 process taking over memory
Oops, yes, I am using CentOS Linux 6.0, R 2.14.1 and nlme 3.1-103 I looked at the problem more carefully. For some datasets applied to nlme, nlme gets stuck in one of the iterations and the memory usage just grows and grows. nlme works by alternating between solving two conditional optimizations. And the number of iterations and parameters for each of those steps can be modified. I can reduce the number of iterations but even then it seems that difficult cases in my simulation eventually appear. I am trying to stop the program after it trespasses certain memory limit. However, that might mean going into the nlme code myself and making some modifications. I will also try making the change in the shell so that no processes can go beyond a certain amount of memory. Anybody has experience with nlme getting out of control in terms of memory usage? Thanks, Ramiro _ ___ From: Prof Brian Ripley [rip...@stats.ox.ac.uk] Sent: Sunday, April 01, 2012 4:04 PM To: Ramiro Barrantes Cc: r-help@r-project.org Subject: Re: [R] R process taking over memory You haven't even told us your OS (see the posting guide). But the usual way is to get your OS to set a memory limit for a process (usually via your shell), and to run things under try/tryCatch. Then the OS will stop R allocating more than the limit, the current task in R will fail, and the loop can move on to the next. I would just caution that these OS facilities do not always work as advertised. E.g. the current man pages on Fedora 16 are not actually up-to-date. On Sun, 1 Apr 2012, Ramiro Barrantes wrote: Hello, I have a general question on the possibility of how to catch and stop a function when it uses too much memory. The problem is that some datasets, when applied to nlme (a relatively older version), cause the nlme function to just hang forever and start taking over memory (this afternoon one of those calls was about 40GB!) and not returning an answer. Other datasets work fine. I am trying to debug nlme by varying its parameters but I have a general question in the interim. I have the following situation: for i in (1:N) { dataset - createDataset(i) try(nlme(dataset, otherParameters)) } If one of those datasets starts using, say more than 2GB of memory I would like to just stop nlme, get an error, record it, and move on with the next dataset. Right now with some datasets nlme takes over the computer memory and the system ends up killing the entire process. Any suggestions appreciated. Thank you, Ramiro [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Cox model approximaions (was comparing SAS and R survival....)
I have a question about Cox's partial likelihood approximations in coxph function of survival package (and in SAS as well) in the presence of tied events generated by grouping continuous event times into intervals. I am processing estimations for recurrent events with time-dependent covariates in the Andersen and Gill approach of Cox's model. If I have understood Breslow's and Efron's approximations correctly, they consist in modifying the denominators of the contributing likelihood term when we do not know the order of occurrence of the events. This order is important only if the tied events are associated to a diferent value of the covariate. I would like to know if the breslow and efron options still modify the initial denominators of the terms when they correspond to the same covariate. Especially, whithin the same trajectory of the observed process (the same individual), the covariate is measured once for each tied events. To my mind, we would introduce a useless bias in this case since the initial partial likelihood is true. Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Re-Cox-model-approximaions-was-comparing-SAS-and-R-survival-tp3686543p4526443.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] unable to move temporary installation
OK - so I followed the following steps, which I think rule out those causes 1) I uninstalled all remaining versions of R, and then deleted all the directories in c:\progra~1\R 2) I restarted the computer 3) I installed 2.14.2, and attempted to install the Rcmdr package. Same error message for both the cars package and the Rcmdr package. 4) I then exited and confirmed that I have write permission to C:\progra~1\R\R-2.14.2\libraries both by looking at the permissions, and by creating a directory in there. I appear to have full control, and I could create the directory. note that R is able to create the temporary directory to install the package, but not the correct, final directory. 5) I then uninstalled 2.14.2, and installed 2.15.0, hoping for a fix. No luck. Same error message. 6) I then tried installing the packages to a different directory, one that I created, c:\test, using install.packages(Rcmdr,c:\\test) This time, the car package installed correctly, but Rcmdr still had the same warning message Warning: unable to move temporary installation c:\test\file136c67c337b3\Rcmdr to c:\test\Rcmdr There is clearly something messed up on this computer, but I'm at a loss for how to get around it. Thanks for the suggestions, and I guess I have to work on a different computer! 2012/3/31 Uwe Ligges lig...@statistik.tu-dortmund.de On 31.03.2012 16:15, Drew Tyre wrote: Hi all, I'm having a strange error that prevents me from installing new packages, or updating packages after reinstalling. The error message is Warning: unable to move temporary installation C:\Program Files\R\R-2.14.2\library\**file15045004ac2\sandwich to C:\Program Files\R\R-2.14.2\library\**sandwich for one of the packages that is failing to install/update. This error started happening after I attempted installing lme4Eigen from the R-Forge repositories - that installation failed too. Any suggestions for fixes welcome. I don't want to upgrade to 2.15 just yet because I'm in the middle of a project (although if that's the solution I guess I'll have to do it). Probably the package is in use by another instance of R. Otherwise, check permissions. Best, Uwe Ligges R version 2.14.2 (2012-02-29) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.14.2 __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drew Tyre School of Natural Resources University of Nebraska-Lincoln 416 Hardin Hall, East Campus 3310 Holdrege Street Lincoln, NE 68583-0974 phone: +1 402 472 4054 fax: +1 402 472 2946 email: aty...@unl.edu http://snr.unl.edu/tyre http://aminpractice.blogspot.com http://www.flickr.com/photos/atiretoo [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error, Variable is missing
Thanks Michael , its works perfectly now. -- View this message in context: http://r.789695.n4.nabble.com/Error-Variable-is-missing-tp4515418p4526683.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] lattice: multiple plots on the same page across pages
Dear All, I have two sets of plots: plot.1 is a set of qqplots that contains 3 pages and 1 panel per page; plot.2 is a set of xyplot that also contains 3 pages and 1 panel per page. These two sets of plots are conditioning on the same variable so I want to generate a display that shows both the qqplot and xyplot on the same page across all 3 pages. I googled a few options and they appeared to work with one page only. Could someone help me out? Thanks a lot. Cheers Jeff [[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] Error in gamma(delta + (complex(0, 0, 1) * (x - mu))/alpha) : unimplemented complex function
I am trying to obtain the grafic of a pdf . but this error keeps showing . Here is the code MXN.fd = function(x,alpha,beta,mu,delta) { A = (2*cos(beta/2))^(2*delta) B = 2*alpha*pi*gamma(2*delta) C = (beta*(x-mu))/alpha D = abs(gamma(delta + (complex(0,0,1)*(x-mu))/alpha)^2) M = A/B*exp(C)*D M plot(x,M,type=l,lwd=2,col=red) } alpha = 0.02612297 beta = -0.50801886 mu = 0.00575829917 delta = 0.67395 x = x=seq(-0.04,0.04,length=200) MXN.fd(x,alpha,beta,mu,delta) i think the problem is the gamma function, does anyone know how to compute gamma with imaginary numbers? thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/Error-in-gamma-delta-complex-0-0-1-x-mu-alpha-unimplemented-complex-function-tp4526695p4526695.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] Requirement for Java Developer [REQ:104605]
[1]Click here to unsubscribe if you no longer wish to receive our emails Dear Partner, Here is our Direct client requirement which can be filled immediately. Kindly respond to this requirement with your consultant resume, contact and current location info to speed up the interview process. [2]Click here to submit for this position online and to speed up the process. Job Title: Java Developer Primary Skills: JAVA Location: Boston,MA Duration: 6 Months Skills Required: 5+ years of J2EE + Oracle experience Strong knowledge in Java/J2EE technologies (JMS, Struts 1.1, Spring 2.5, Hibernate 3.2, JSF, XJS, EJB 6.1, MQ 7 etc.) Excellent design and development experience in J2EE Good knowledge of Oracle 10.2, SQL/PLSQL Knowledge of UNIX Knowledge of ClearCase/ClearQuest-UCM Rebase/Delivery for code-merge with other parallel releases Knowledge of build tools - TeamCity and Rational BuildForge will be an added advantage Handling application queries from business users and resolving them with minimal help of SME Highly time-effective/multi-task working to meet deadlines for short cycle releases and planning with client's SLA [for environment + Deployment + Database related tickets] Excellent communication and interpersonal skills and should be a self-starter Effective interaction/coordination with multiple client teams in different geos (US + China) and with offshore team. Should be able to work independently and capable to lead a team of resources [3]Click here to submit for this position online and to speed up the process. Please respond with you consultant resume, contact, rate and current location info to speed up the interview process. I will contact you if I need further details. Regards, ALI SoftHQ Inc. 858 658 9200 x 620 [4]a...@softhq.com [5]Click here to unsubscribe from our mailing list and your name will be removed immediately. _ This email is generated using [6]CONREP software. [7][8011234857.jpg] G5540 References Visible links 1. http://adso.conrep.com/conrep/actions/mail/unsubscribe.php?param=QVBSSUQ9MTEwMTAwODczMjc4JkFQTUlEPTQyNCZDTVBDRD01NTQwJkZST009YWxpQHNvZnRocS5jb20mVE89ci1oZWxwQHItcHJvamVjdC5vcmcmSk9CSUQ9MTEwMTAwOTkzMzQ5JlNVQko9UmVxdWlyZW1lbnQgZm9yIEphdmEgRGV2ZWxvcGVyICBbUkVROjEwNDYwNV0mdXNyaWQ9MTEwMTAwMDU1NjE5JkpCQ0lEPTYxMDAwMjE3NjcyNw== 2. http://adso.conrep.com/conrep/web/parse/resumeparsing/screen1.php?CUSID=5540110100010341weblinkflg=1REQID=110105474332apmid=412APMID=412RECTR=110100054755CPFID=VENID=JOBID=610002176727Source=JobPortalLEAID=110100873278SOURC=VM 3. http://adso.conrep.com/conrep/web/parse/resumeparsing/screen1.php?CUSID=5540110100010341weblinkflg=1REQID=110105474332apmid=412APMID=412RECTR=110100054755CPFID=VENID=JOBID=610002176727Source=JobPortalLEAID=110100873278SOURC=VM 4. mailto:a...@softhq.com 5. http:///conrep/actions/mail/unsubscribe.php?param=QVBSSUQ9MTEwMTAwODczMjc4JkFQTUlEPTQyNCZDTVBDRD01NTQwJkZST009YWxpQHNvZnRocS5jb20mVE89ci1oZWxwQHItcHJvamVjdC5vcmcmSk9CSUQ9MTEwMTAwOTkzMzQ5JlNVQko9UmVxdWlyZW1lbnQgZm9yIEphdmEgRGV2ZWxvcGVyICBbUkVROjEwNDYwNV0mdXNyaWQ9MTEwMTAwMDU1NjE5JkpCQ0lEPTYxMDAwMjE3NjcyNw== 6. http://www.conrep.com/?emlsrc=-110100055619emailed=r-help@r-project.orgT=MM 7. http://www.conrep.com/?emlsrc=-110100055619emailed=r-help@r-project.orgT=MM Hidden links: 8. mailto:a...@softhq.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] nls() error
Hello, I am running a simple nls model (which a friend ran OK) but I get the following error: Error in nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, : object 'R_nls_iter' not found Does anyone know what the 'R_nls_iter' error is? The data are: x=1:8 ; y=c(14,19,25,34,43,56,69,76) # starting values: R=.3, K=94 Thanks in advance. Jeff __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] nls() error
On 02-04-2012, at 20:48, Jeff Breiwick wrote: Hello, I am running a simple nls model (which a friend ran OK) but I get the following error: Error in nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, : object 'R_nls_iter' not found Does anyone know what the 'R_nls_iter' error is? The data are: x=1:8 ; y=c(14,19,25,34,43,56,69,76) # starting values: R=.3, K=94 No Os, no R version, no context, no reproducible example. So I tried this: x - 1:8 y - c(14,19,25,34,43,56,69,76) # starting values: R - .3 K - 94 nls.dat - data.frame(x=x, y=y) nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=94)) and got this nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=94)) Error in nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, : RMate stopped at line 0 singular gradient Execution halted Berend R2.15.0, Mac OS X 10.6.8 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] \Sexpr{}
just FYI: the knitr package supports HTML as well and will not be interfered by R2HTML. See http://yihui.name/knitr/demo/minimal/ Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Mon, Apr 2, 2012 at 11:00 AM, Eik Vettorazzi e.vettora...@uke.de wrote: Hi Hua, try options(SweaveSyntax=SweaveSyntaxNoweb) before sweaving your file (see A.14 in the FAQ section of the manual). In most cases R2HTML interferes with Sweave, causing your problem hth. Am 02.04.2012 15:12, schrieb Liang, Hua: Did anyone know whether the problem it doesn't evaluate \Sexpr{} in Sweave has been fixed? I checked r help page and realized it was asked a couple of years ago. But I didn't find solutions. Thanks for your help in advance! Hua __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Parallel writes in R
R-helpers: I'm curious what support R has for parallel writes to a binary file? If I want to use snow to have each node write different rows of a flat binary file (possibly out of sequence), are there any tricks/issues I should be aware of? --j -- Jonathan A. Greenberg, PhD Assistant Professor Department of Geography University of Illinois at Urbana-Champaign 607 South Mathews Avenue, MC 150 Urbana, IL 61801 Phone: 415-763-5476 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007 http://www.geog.illinois.edu/people/JonathanGreenberg.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] nls() error
On 02-04-2012, at 21:20, Jeff Breiwick wrote: Thanks for that. Sorry, I did forget to give some basics: You should also reply to the list so that other can follow the thread. I am also sending this the list. Running R-1.15.0 (x64) on Windows 7. I assume you mean R2.15.0 The data I gave I now realize were the untransformed data: y (tran) = y[2:8]/y[1:7] - 1 and x (tran) = y[1:7]. Are you sure that x (tran) = y[1:7]? I still get the same error though about couldn't find 'R_nls_iter'. Try a clean environment. I now did this: nls.dat - data.frame(x=y[1:7], y=y[2:8]/y[1:7]) nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=1)) and got this answer nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=1)) Nonlinear regression model model: y ~ R * (1 - (x/K)^2) data: nls.dat R K 1.363 164.616 residual sum-of-squares: 0.005536 Number of iterations to convergence: 15 Achieved convergence tolerance: 6.173e-09 I also did this (just in case; see above) nls.dat - data.frame(x=x[1:7], y=y[2:8]/y[1:7]) nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=1)) and got this nls.dat - data.frame(x=x[1:7], y=y[2:8]/y[1:7]) nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=1)) Nonlinear regression model model: y ~ R * (1 - (x/K)^2) data: nls.dat R K 1.369 17.191 residual sum-of-squares: 0.008188 Number of iterations to convergence: 9 Achieved convergence tolerance: 7.046e-08 Berend Jeff Breiwick On Mon, Apr 2, 2012 at 12:06 PM, Berend Hasselman b...@xs4all.nl wrote: On 02-04-2012, at 20:48, Jeff Breiwick wrote: Hello, I am running a simple nls model (which a friend ran OK) but I get the following error: Error in nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, : object 'R_nls_iter' not found Does anyone know what the 'R_nls_iter' error is? The data are: x=1:8 ; y=c(14,19,25,34,43,56,69,76) # starting values: R=.3, K=94 No Os, no R version, no context, no reproducible example. So I tried this: x - 1:8 y - c(14,19,25,34,43,56,69,76) # starting values: R - .3 K - 94 nls.dat - data.frame(x=x, y=y) nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=94)) and got this nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, K=94)) Error in nls(y ~ R * (1 - (x/K)^2), data = nls.dat, start = list(R = 0.3, : RMate stopped at line 0 singular gradient Execution halted Berend R2.15.0, Mac OS X 10.6.8 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 hide console window
Hi, all I'm wondering the code that hides or minimizes console window. What I'm making is gui for some function and that is saved as gui.RData that is started with gui window when I open the gui.RData. In this sitiuation I don't want to see console window but just gui window. How can I solve my problem. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/How-to-hide-console-window-tp4526850p4526850.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] sampling rows from a list
Hi: I'm sure this seems like a rudimentary question, but I am not well versed with R syntax for lists. I have a ragged array from which I've removed records (entire rows) with missing data. The functions I used to remove the missing cases resulted in the generation of an R list class object, that looks something like this; mydata [[1]] [,1] [,2] [,3] [1,]123 [2,]456 [3,]789 [[2]] [,1] [,2] [,3] [1,] 10 11 12 [2,] 13 14 15 [[3]] [,1] [,2] [,3] [1,] 16 17 18 [2,] 19 20 21 [3,] 22 23 24 [4,] 25 26 27 [5,] 28 29 30 Part1 What I would like to do is draw an equal number of random row samples from[[1]],[[2]] and [[3]] (to preserve the structure of [,1][,2],[,3]. Part2 Then I would like to cocerce the list object into something like an array. Help scripting out part 1 or 2 would be much appreciated. Brian Campbell -- View this message in context: http://r.789695.n4.nabble.com/sampling-rows-from-a-list-tp4526831p4526831.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] STL decomposition of time series with multiple seasonalities
Hi all, I have a time series that contains double seasonal components (48 and 336) and I would like to decompose the series into the following time series components (trend, seasonal component 1, seasonal component 2 and irregular component). As far as I know, the STL procedure for decomposing a series in R only allows one seasonal component, so I have tried decomposing the series twice. First, by setting the frequency to be the first seasonal component using the following code: ser = ts(data, freq=48) dec_1 = stl(ser, s.window=per) Then, I decomposed the irregular component of the decomposed series (dec_1) by setting the frequency to be the second seasonal component, such that: ser2 = ts(dec_1$time.series[,3], freq=336) dec_2 = stl(ser2, s.window=per) I'm not very confident with this approach. And I would like to know if there are any other ways to decompose a series that has multiple seasonalities. Also,I have noticed that the tbats() function in the R forecasthttp://cran.r-project.org/web/packages/forecast/index.html package () allows one to fit a model to a series with multiple seasonalities. Basically, i would like the STL result to be components of Figure 5 on Page 28 of this article (http://robjhyndman.com/papers/complex-seasonality/). However, it doesn't say how to implement (the decomposition in R. Does anyone know how to apply the tbats() function in R for decomposition? Regards [[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] sampling rows from a list
?? Something like: lapply(mydata, function(x){ nr - nrow(x) x[sample(seq_len(nr),nr,rep=TRUE),] }) maybe. The idea is to use the sampled rows as your row index. -- Bert On Mon, Apr 2, 2012 at 11:24 AM, Bcampbell99 briand.campb...@ec.gc.ca wrote: Hi: I'm sure this seems like a rudimentary question, but I am not well versed with R syntax for lists. I have a ragged array from which I've removed records (entire rows) with missing data. The functions I used to remove the missing cases resulted in the generation of an R list class object, that looks something like this; mydata [[1]] [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 [3,] 7 8 9 [[2]] [,1] [,2] [,3] [1,] 10 11 12 [2,] 13 14 15 [[3]] [,1] [,2] [,3] [1,] 16 17 18 [2,] 19 20 21 [3,] 22 23 24 [4,] 25 26 27 [5,] 28 29 30 Part1 What I would like to do is draw an equal number of random row samples from[[1]],[[2]] and [[3]] (to preserve the structure of [,1][,2],[,3]. Part2 Then I would like to cocerce the list object into something like an array. Help scripting out part 1 or 2 would be much appreciated. Brian Campbell -- View this message in context: http://r.789695.n4.nabble.com/sampling-rows-from-a-list-tp4526831p4526831.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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sampling rows from a list
## recreating your data mydata-list(matrix(1:9, nrow=3, byrow=T), matrix(10:15, nrow=2, byrow=T), matrix(16:30, nrow=5, byrow=T)) ## get the shortest matrix in your list n - min(unlist(lapply(mydata, nrow))) ## subset the list into random samples of length n out - lapply(mydata, function(x, n) x[sample(1:nrow(x), n),], n=n) ## this structure is still a list though... ## converting directly to an array: out.array - array(unlist(out), dim=c(dim(out[[1]]), length(out))) not totally sure about what structure you're wanting in the last step, so if i missed i apologize... Hope that helps, Justin On Mon, Apr 2, 2012 at 11:24 AM, Bcampbell99 briand.campb...@ec.gc.ca wrote: Hi: I'm sure this seems like a rudimentary question, but I am not well versed with R syntax for lists. I have a ragged array from which I've removed records (entire rows) with missing data. The functions I used to remove the missing cases resulted in the generation of an R list class object, that looks something like this; mydata [[1]] [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 [3,] 7 8 9 [[2]] [,1] [,2] [,3] [1,] 10 11 12 [2,] 13 14 15 [[3]] [,1] [,2] [,3] [1,] 16 17 18 [2,] 19 20 21 [3,] 22 23 24 [4,] 25 26 27 [5,] 28 29 30 Part1 What I would like to do is draw an equal number of random row samples from[[1]],[[2]] and [[3]] (to preserve the structure of [,1][,2],[,3]. Part2 Then I would like to cocerce the list object into something like an array. Help scripting out part 1 or 2 would be much appreciated. Brian Campbell -- View this message in context: http://r.789695.n4.nabble.com/sampling-rows-from-a-list-tp4526831p4526831.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.
Re: [R] nls() error
Thanks to Berend for his help with this. The problems seems to have been due to an environment that wasn't clean. I also gave x y that were untransformed. But I am able to get results now. Jeff __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 gamma(delta + (complex(0, 0, 1) * (x - mu))/alpha) : unimplemented complex function
Guaramy Guaramy at hotmail.com writes: [SNIP] i think the problem is the gamma function, does anyone know how to compute gamma with imaginary numbers? Try lngamma_complex() in the gsl package? Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 it possible to de-select with sqlQuery from the RODBC library?
I've never heard of a an SQL de-select, but if there is such a thing it shouldn't be too hard to find via some web searches. In the meantime, I would probably just do a select * to get all the fields from the database tables, and then drop the unwanted ones afterwards in R. I think this will give you simpler code, thus easier to understand and check. And, unless the tables are huge, I doubt you'll see any performance problem. One way would be: data - sqlQuery(mdbConnect, select * from someTable) data - subset(data, select=-c(V1010,V1o12)) Or, given your list of fields to exclude, something like the following (untested) should work. (hopefully my stupid email client won't shorten any of the lines of code) q.lookup - list(Table3 = c('V1010', 'V1012'), Table7 = c('V1040', 'V1052'), Table9 = 'ALL') mydat - q.lookup for (nm in names(q.lookup)) { sql - paste('select * from',nm) mydat[[nm]] - sqlQuery(mdbConnect, sql) mydat[[nm]] - mydat[[nm]][ , setdiff(names(mydat[[nm]]), q.lookup[[nm]] ] } You now have a list; each element contains one of your tables. Here is an example to show you what setdiff() is doing: setdiff(letters[1:10], c('b','d')) It's not necessary to test for 'ALL' in that loop, provided none of your input tables have a field named 'ALL'. See: setdiff(letters[1:10], 'ALL') And note: it's best to not use 'data' for the name of a data frame; it is the name of an R-suppled function. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 3/28/12 11:17 AM, Eric Fail eric.f...@gmx.us wrote: Thank you Bart for your idea, the thing is that I have a large number of tables and I would like to avoid having to pull them at all. I currently have a list that I use as a lookup table in a loop with an if else statement to sort between tables I want to sqlFetch (take everything) and tables where I sqlQuery (only want part of the table). The names of the list itself constitute a positive definition of what tables I want to pull. Here in a reduced illustrative example of what I am doing. My problem is still that I would like to make negative selection so I get everything except 'V1010' and 'V1012' in table 3, and so forth (please see below). ## illustrative R example ## q.lookup - list(Table3 = c('V1010', 'V1012'), Table7 = c('V1040', 'V1052'), Table9 = 'ALL') dfn - list() for(i in names(q.lookup)) { if (q.lookup[[i]][1]==ALL) { query - names(q.lookup[1]) table.n - sqlFetch(mdbConnect, query) } else if (q.lookup[[i]][1]!=ALL) { query - paste(select, paste(q.lookup[[i]], collapse=, ), from, names(q.lookup[i])) table.n - sqlQuery(mdbConnect, query) } else print(your SQL call is gone haywire, fix it in line 193-204) dfn[[i]] - table.n } ### end of illustrative R example I could use your solution, I think, but if at all possible I would prefer to figure out how to make a negative SQL statement (I still imagine that there is some reverse function of the SQL select statement somewhere out there). With hight hopes. Eric On Wed, Mar 28, 2012 at 2:24 AM, Bart Joosen bartjoo...@hotmail.com wrote: What you can do: SELECT top 1 * FROM your_table; Use this selection to find all your column names in R then paste everything together without the names you don't want and then run your query. Bart -- View this message in context: http://r.789695.n4.nabble.com/Is-it-possible-to-de-select-with-sqlQuery-f rom-the-RODBC-library-tp4511189p4511800.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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Default parameter values in R functions?
Hi all, I have a newbie question: If I have a function with the following documentation: ca.jo(x, type = c(eigen, trace), ecdet = c(none, const, trend), K = 2, spec=c(longrun, transitory), season = NULL, dumvar = NULL) Let's take type as an example... if I omit this parameter when calling the function, what's going to be the default value for this parameter? Amazingly the documentation didn't say which one is the default... Thank you! [[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] Default parameter values in R functions?
The first one -- this is implemented by match.arg(). Michael On Mon, Apr 2, 2012 at 5:30 PM, Michael comtech@gmail.com wrote: Hi all, I have a newbie question: If I have a function with the following documentation: ca.jo(x, type = c(eigen, trace), ecdet = c(none, const, trend), K = 2, spec=c(longrun, transitory), season = NULL, dumvar = NULL) Let's take type as an example... if I omit this parameter when calling the function, what's going to be the default value for this parameter? Amazingly the documentation didn't say which one is the default... Thank you! [[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] Default parameter values in R functions?
Yes, it's a bit subtle. Argument matching is usually done through match.arg(), so see ?match.arg for an explanation.. (the first chosen). -- Bert On Mon, Apr 2, 2012 at 2:30 PM, Michael comtech@gmail.com wrote: Hi all, I have a newbie question: If I have a function with the following documentation: ca.jo(x, type = c(eigen, trace), ecdet = c(none, const, trend), K = 2, spec=c(longrun, transitory), season = NULL, dumvar = NULL) Let's take type as an example... if I omit this parameter when calling the function, what's going to be the default value for this parameter? Amazingly the documentation didn't say which one is the default... Thank you! [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] fatal error prevents multi-line functions or loop to run
Sounds like you tried everything I know. However, I, and anyone else on this list whose mind-reading powers are undeveloped, really can't be sure because you didn't show us what you tried. Perhaps you should (re-)read the posting guidelines and try showing us reproducible sample code that doesn't do what you expect it to (along with some indication of what you expected it to do). --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Ebrahim Jahanshiri e.jahansh...@gmail.com wrote: Dear all, I have written some function that can go up to many lines. Two of the lines give warning errors like: Error in print()[c(1, : error in evaluating the argument 'x' in selecting a method for function 'print': Error in ... regions with no neighbours found now obviously this kind of error will halt the execution of the function. I tried *try()* or *tryCatch()* and many other selections in the *options()*but still this error by all means stops the execution of the function or any other multi-line code. I would appreciate if you could give me a clue. Ebrahim [[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] Default parameter values in R functions?
Okay! Thank you both for your help! So it chooses the 1st one by default... Thank you! On Mon, Apr 2, 2012 at 4:43 PM, Bert Gunter gunter.ber...@gene.com wrote: Yes, it's a bit subtle. Argument matching is usually done through match.arg(), so see ?match.arg for an explanation.. (the first chosen). -- Bert On Mon, Apr 2, 2012 at 2:30 PM, Michael comtech@gmail.com wrote: Hi all, I have a newbie question: If I have a function with the following documentation: ca.jo(x, type = c(eigen, trace), ecdet = c(none, const, trend), K = 2, spec=c(longrun, transitory), season = NULL, dumvar = NULL) Let's take type as an example... if I omit this parameter when calling the function, what's going to be the default value for this parameter? Amazingly the documentation didn't say which one is the default... Thank you! [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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 layout the output nicely into webpage?
How to layout the output nicely into webpage? Hi all, I have data which is about 6 x 1 divided into trunks and in the following for loop I am doing data analysis trunk by trunk. The goal is to layout the data and analysis summaries side-by-side in a clear manner. I guess the best way to present these is to put them on a HTML webpage (i.e. output results into HTML format). More specifically, I am looking for a nice formatter such that: 1. Within each trunk, the left side will be the data in that trunk itself; the right side will be the analysis summaries(Please see below for an example): 2. Trunk by trunk, the outputs are layed out vertically, i.e. the data (left) and summary (right) for trunk 2 are placed below those of trunk 1, etc. Here is the skeleton of the code: How to do it? Thanks a lot! -- n=length(x) for (i in seq(40, n, by=40)) { xtrunk=x[(i-40+1):i] t=1:40 bb=summary(lm(xtrunk~t)) #would like to output xtrunk on the left and bb on the right #and convert results into HTML format; the final results will be a big HTML file } -- summary(lm(xtrunk~t)) Call: lm(formula = xtrunk ~ t) Residuals: Min 1Q Median 3Q Max -1.9866 -0.8931 0.1681 0.7087 3.0392 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.154144 0.344039 0.4480.657 t -0.001237 0.014623 -0.0850.933 Residual standard error: 1.068 on 38 degrees of freedom Multiple R-squared: 0.0001884, Adjusted R-squared: -0.02612 F-statistic: 0.007159 on 1 and 38 DF, p-value: 0.933 [[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] Default parameter values in R functions?
Just to point out another reference, which is the R Language Definition, where in section 4.3.2: http://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching entitled Argument Matching, there are some pointers to the use of match.arg(), leading you to the help page pointed to by Bert and Michael. It also makes note that this applies to closures, but not to primitives where the handling of arguments is different. Regards, Marc Schwartz On Apr 2, 2012, at 4:59 PM, Michael wrote: Okay! Thank you both for your help! So it chooses the 1st one by default... Thank you! On Mon, Apr 2, 2012 at 4:43 PM, Bert Gunter gunter.ber...@gene.com wrote: Yes, it's a bit subtle. Argument matching is usually done through match.arg(), so see ?match.arg for an explanation.. (the first chosen). -- Bert On Mon, Apr 2, 2012 at 2:30 PM, Michael comtech@gmail.com wrote: Hi all, I have a newbie question: If I have a function with the following documentation: ca.jo(x, type = c(eigen, trace), ecdet = c(none, const, trend), K = 2, spec=c(longrun, transitory), season = NULL, dumvar = NULL) Let's take type as an example... if I omit this parameter when calling the function, what's going to be the default value for this parameter? Amazingly the documentation didn't say which one is the default... Thank you! [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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 to layout the output nicely into webpage?
Also, is there a way to add a plot onto each trunk, so it will become 3 parts: Left: data (xtrunk: 40 rows) Mid: plot of this data Right: lm summary outputs (around 10 rows) Any thoughts? Thanks a lot! On Mon, Apr 2, 2012 at 5:30 PM, Michael comtech@gmail.com wrote: How to layout the output nicely into webpage? Hi all, I have data which is about 6 x 1 divided into trunks and in the following for loop I am doing data analysis trunk by trunk. The goal is to layout the data and analysis summaries side-by-side in a clear manner. I guess the best way to present these is to put them on a HTML webpage (i.e. output results into HTML format). More specifically, I am looking for a nice formatter such that: 1. Within each trunk, the left side will be the data in that trunk itself; the right side will be the analysis summaries(Please see below for an example): 2. Trunk by trunk, the outputs are layed out vertically, i.e. the data (left) and summary (right) for trunk 2 are placed below those of trunk 1, etc. Here is the skeleton of the code: How to do it? Thanks a lot! -- n=length(x) for (i in seq(40, n, by=40)) { xtrunk=x[(i-40+1):i] t=1:40 bb=summary(lm(xtrunk~t)) #would like to output xtrunk on the left and bb on the right #and convert results into HTML format; the final results will be a big HTML file } -- summary(lm(xtrunk~t)) Call: lm(formula = xtrunk ~ t) Residuals: Min 1Q Median 3Q Max -1.9866 -0.8931 0.1681 0.7087 3.0392 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.154144 0.344039 0.4480.657 t -0.001237 0.014623 -0.0850.933 Residual standard error: 1.068 on 38 degrees of freedom Multiple R-squared: 0.0001884, Adjusted R-squared: -0.02612 F-statistic: 0.007159 on 1 and 38 DF, p-value: 0.933 [[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] Calculating NOEL using R and logistic regression - Toxicology
Hello, I used the glm function in R to fit a dose-response relationship and then have been using dose.p to calculate the LC50, however I would like to calculate the NOEL (no observed effect level), ie the lowest dose above which responses start occurring. Does anyone know how to do this? [[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] Calculating NOEL using R and logistic regression - Toxicology
dear Danielle, The NOEL is a threshold value or breakpoint in the range of dose. Have a look to the package segmented to estimate a GLM with unknown breakpoints. The code (untested) should be something like library(segmented) o-glm(y~1, family=binomial) os-segmented(o, ~dose, psi=starting_psi) Also the package segmented includes the dataset down that can be useful as an example.. data(down) with(down, plot(age, cases/births)) There is a paper of mine on R news 2008 discussing the package.. hope this helps you, vito On Mon, 2 Apr 2012 14:45:06 -0800, Danielle Duncan wrote Hello, I used the glm function in R to fit a dose-response relationship and then have been using dose.p to calculate the LC50, however I would like to calculate the NOEL (no observed effect level), ie the lowest dose above which responses start occurring. Does anyone know how to do this? [[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. -- Open WebMail Project (http://openwebmail.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.