[R] Deleting Data Sets in R Commander
Hi. I have been making sample data sets to learn how to use R Commander, and now I have several useless data sets that are cluttering up the place where data sets are stored in R Commander. I want to get rid of these, but I can't seem to find out how to delete them, if I can at all. Is it possible to delete these data sets in R Commander? Sincerely, Lavida *Use caution:* Category: More info [[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] Deleting Data Sets in R Commander
Hello, On Thu, Aug 6, 2009 at 1:38 AM, Lavida Chavezchavez.lav...@gmail.com wrote: Hi. I have been making sample data sets to learn how to use R Commander, and now I have several useless data sets that are cluttering up the place where data sets are stored in R Commander. I want to get rid of these, but I can't seem to find out how to delete them, if I can at all. Is it possible to delete these data sets in R Commander? You can remove objects using rm(). You could remove objects by point-and-click if you were using Rcmdr started from within JGR; JGR provides an Object browser that allows to remove objects. Liviu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] overlap two graph
Hi, actually there are coding before plot(ellipsePoints(2,5, alpha = 30), asp=1) which i got it from this website http://www.biostat.wustl.edu/archives/html/s-news/2002-10/msg00186.html It only can draw one ellipse, Now I want to know how to add more ellipse in same diagram? thank you. On Wed, Aug 5, 2009 at 9:53 PM, Scott Sherrill-Mix shesc...@mail.med.upenn.edu wrote: Did you try already try: plot(ellipsePoints(2,5, alpha = 30), asp=1) points(ellipsePoints(2,5, alpha = 60), asp=1,col='red') ? Scott Scott Sherrill-Mix Department of Microbiology University of Pennsylvania 402B Johnson Pavilion 3610 Hamilton Walk Philadelphia, PA 19104-6076 On Wed, Aug 5, 2009 at 5:46 AM, Hemavathi Ramuluhema.ram...@gmail.com wrote: Hi everyone,I need you all help. I want to create few image in same diagram. For example, I wan draw two ellipse in same diagram. plot(ellipsePoints(2,5, alpha = 60), asp=1) and plot(ellipsePoints(2,5, alpha = 30), asp=1) How to display both ellipse together? both is different in angle. Thank you. -- Hemavathi Ramulu [[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. -- Hemavathi Ramulu [[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] Testing year effect in lm() ***failed first time, sending again
Le mercredi 05 août 2009 à 09:52 -0700, Mark Difford a écrit : Emmanuel, somewhat incomplete help pages : what in h*ll are valid arguments to mcp() beyond Tukey ??? Curently, you'll have to dig in the source to learn that...). Not so: they are clearly stated in ?contrMat. Oops.. I oversaw that. With my apologies, Emmanuel Charpentier __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using ddply but preserving some of the outside data
Hi, Apart from everything that's been answered already, it seems in your first mail that you were confusing merge and rbind. rbind is to append rows to a data set. merge performs joints, like in a relational database - Mail Original - De: Jarrett Byrnes byr...@msi.ucsb.edu À: R help r-h...@stat.math.ethz.ch Envoyé: Mercredi 5 Août 2009 21h00:40 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: [R] using ddply but preserving some of the outside data I have a bit of a quandy. I'm working with a data set for which I have sampled sites at a variety of dates. I want to use this data, and get a running average of the sampled values for the current and previous date. I originally thought something like ddply would be ideal for this, however, I cannot break up my data by date, and then apply a function that requires information about the previous dates. I had thought to use a for loop and merge, but that doesn't quite seem to be working. So, my questions are twofold 1) Is there a way to use something like the plyr library to do this efficiently 1a) Indeed, is there a way to use ddply or its ilk to have a function that returns a vector of values, and then assign the variables you are sorting by to the whole vector? Or maybe making each value it's own column in the new data frame, and then using reshape is the answer. Hrm. Seems clunky. 2) Or, can a for loop around a plyr-kind of statement do the trick (and if so, pointers on why the below code won't work) (also, it, too, seems clunkier than I would like) sites-c(a, b, c) dates-1:5 a.df-expand.grid(sites=sites, dates=dates) a.df$value-runif(15,0,100) a.df-as.data.frame(a.df) #now, I want to get the average of the mean2-function(df, date){ sub.df-subset(df, df$dates-date1 df$dates-date-1 ) return(mean(df$value)) } my.df-data.frame(sites=NA, dates=NA, V1=NA) for(a.date in a.df$dates){ new.df-ddply(a.df, sites, function(df) mean2 (df, a.date)) my.df-merge(my.df, new.df) #doesn't seem to work } my.df __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] acf Significance
Thanks for the pointer to the str function - very handy! The output for the acf object is below - it doesn't seem to contain anything that might tell me the significance level. List of 6 $ acf : num [1:27, 1, 1] 1 0.6309 0.2989 0.0612 -0.2105 ... $ type : chr correlation $ n.used: int 27 $ lag : num [1:27, 1, 1] 0 1 2 3 4 5 6 7 8 9 ... $ series: chr time_series $ snames: NULL - attr(*, class)= chr acf Does anyone have any more ideas? Steve. markle...@verizon.net wrote: hi: set the acf to an object and then do str(object). that should show if and where they are ? If I knew I would just tell you so I'm not trying to be socratic. it's been a while since I used acf(). On Aug 5, 2009, *Steve Jones* st...@squaregoldfish.co.uk wrote: Hi List, I'm trying to calculate the autocorrelation coefficients for a time series using acf at various lags. This is working well, and I can get the coefficients without any trouble. However, I don't seem to be able to obtain the significance of these coefficients from the returned acf object, largely because I don't know where I might find them. It's clear that the acf function knows the significance threshold of the autocorrelations, since it's shown in blue shown on the plot output from acf, but I can't figure out where to access it. Can anyone help? Thanks in advance, Steve. __ R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. signature.asc Description: OpenPGP digital signature __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] multiple lty on same panel in xyplot
On Wed, 05-Aug-2009 at 05:24PM -0400, Jacob Wegelin wrote: | | Dear Bill and Deepayan, | | Thanks. This is helpful. Where can one find a thorough | documentation of all these features like par.settings, simpleTheme, | the options for where to place the legend or key, auto.key, the | different locations besides top where one can place the | auto.key, etc.? I don't think this is all clearly laid out in | the R help files or latticeLab.pdf. It's not immediately obvious, but you can find a lot of information in the rather large help file for xyplot -- applicable even if you're using bwplot or dotplot or whatever. I often search for text in there such as key which leads a long way down to options for space which can take values of top, bottom, etc. There are many options and perhaps they're easier to find laid out in the book. HTH -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] array slice notation?
Hi, The do.call() version is likely slower than the vector version. To select multiple rows, just replace the 1 by the vector with the rows. The TRUEs in the list fail if the array happens to have 0 length in the corresponding dimension. You can build the list passed to do.call() first setting zeros instead of TRUE if that is the case: A - array(1:27, c(3, 3, 3)) v - c(1, 2) largs - lapply(dim(A)[-1L], function(y) if (y) TRUE else 0L) do.call([, c(list(A, v), largs)) Enrique -- Date: Tue, 4 Aug 2009 19:45:55 -0700 (PDT) From: Steve Jaffe sja...@riskspan.com Subject: Re: [R] array slice notation? To: r-help@r-project.org Message-ID: 24819883.p...@talk.nabble.com Content-Type: text/plain; charset=UTF-8 Very nice. Two questions: 1 Do you have any idea of the timing difference, if any, between this and the vector-subscripting method? 2 How do you generalize this to select multiple rows eg with indexes given by a vector 'v'? S?ren H?jsgaard wrote: You can do A - HairEyeColor do.call([, c(list(A),list(1,T,T))) Sex Eye Male Female Brown 32 36 Blue11 9 Hazel 10 5 Green3 2 Regards S?ren -- View this message in context: http://www.nabble.com/array-slice-notation--tp24814643p24819883.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] lme funcion in R
Dear Harry, You get different results because your model specification is different!. The specificication of your first model seems wrong to me. Having an intercept for each level is non-sense. You probably defined the random effects as (MH_D |TAZ) + (APT_D|TAZ) + (ResOth_D|TAZ) + (NonRes_D|TAZ) + (Vacant_noimp_D| TAZ ) + (Vacant_imp_D|TAZ). You should either use (1|TAZ) + (MH_D -1 |TAZ) + (APT_D - 1|TAZ) + (ResOth_D - 1|TAZ) + (NonRes_D - 1|TAZ) + (Vacant_noimp_D - 1| TAZ ) + (Vacant_imp_D - 1|TAZ) or (MH_D + APT_D + ResOth_D + NonRes_D + Vacant_noimp_D + Vacant_imp_D|TAZ) The last model is equivalent with (HousingType|TAZ) The difference between both models is the specication of the random effects The first model assumes that the levels of Housingtype are independent. The last model allows for correlation between those levels. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey Van: Hongwei Dong [mailto:pdxd...@gmail.com] Verzonden: woensdag 5 augustus 2009 21:12 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: Re: [R] lme funcion in R Thanks, Thierry and other R users. I estimate the model using the factor rather than the dummy variables I used previously. It still takes forever for the function lme to run. But lmer is much better with my large data size (about 60,000 observations). The interesting part is that the results from the model using factor are slightly different from what I got from the model using dummy variables, especially for the variables at random level. The estimated random effects by using dummy variable are like this (each dummy got one intercept): Random effects: Groups Name Variance Std.Dev. Corr TAZ (Intercept)0.059160 0.24323 MH_D 0.215210 0.46391 -0.583 TAZ (Intercept)0.212061 0.46050 APT_D 0.205028 0.45280 -0.992 TAZ (Intercept)0.086223 0.29364 ResOth_D 0.305678 0.55288 0.665 TAZ (Intercept)0.161892 0.40236 NonRes_D 0.537284 0.73300 -0.874 TAZ (Intercept)0.088684 0.29780 Vacant_noimp_D 0.501495 0.70816 -0.570 TAZ (Intercept)0.136630 0.36964 Vacant_imp_D 0.368722 0.60722 -0.850 Residual0.382439 0.61842 Number of obs: 55762, groups: TAZ, 739 The estimated random effects by using factor are like this (one intercept for all): Random effects: Groups Name Variance Std.Dev. Corr TAZ (Intercept)0.83894 0.91594 HousingType1MH_D 0.23214 0.48181 -0.375 HousingType1APT_D 0.28850 0.53712 -0.827 0.630 HousingType1ResOth_D 0.29392 0.54214 0.156 -0.251 -0.165 HousingType1NonRes_D 0.58169 0.76269 -0.572 0.155 0.656 -0.030 HousingType1Vacant_imp_D 0.45349 0.67342 -0.522 0.203 0.265 0.101 0.611 HousingType1Vacant_noimp_D 0.54146 0.73584 -0.286 0.251 0.265 0.390 0.313 0.475 Residual0.38228 0.61829 Number of obs: 55762, groups: TAZ, 739 The fixed coefficients for each group are also slightly different. I'm wondering which one makes more sense. Thanks. Harry Harry R still report error On Wed, Aug 5, 2009 at 1:22 AM, ONKELINX, Thierry thierry.onkel...@inbo.be wrote: Harry, I you use dummy variables, then you can only use (n-1) dummy variables if your variable has n levels. Otherwise you introduce multicollinearity! If you use n dummy variable then you can express one dummy variable as a linear combination of the others. Make use of a factor variable. That is much easier to work with that dummy variables. The model itself will create the necessary dummy variables. lusdrdata$HousingType - factor(lusdrdata$HousingType, levels = 1:6, labels = c(Reference, MH_D, APT_D, ResOth_D, NonRes_D, Vacant_D)) lme(fixed = LN_unitlandval ~
Re: [R] creating MS Access query objects using RODBC
Tim Calkins-2 wrote: I'm trying to use R to create an MS Access query object. In particular, I would like to pass a given sql statement to a variety of Access files and have that sql statement saved as an Access Query in each db. Is this possible using R? I'm aware that I could use RODBC sqlQuery and write sql to make a table or that I could run the sql, extract it to R, and then use sqlSave to save the dataframe as a table in the db. To my knowledge, this is not possible using RODBC, because ODBC is the least common denominator for many databases, and adding a query (~view) to Access is not within that standard. It should be possible with COM, but I believe it will only work if you have Access installed, not with mdb files alone. Dieter -- View this message in context: http://www.nabble.com/creating-MS-Access-query-objects-using-RODBC-tp24838858p24840834.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 r import data
Good moorning, yesterday, i asked for how we can import data into R i found that it is necessary to make the file in csv format then use L- read.csv2(path of file) now i see that the dimension of my table importing into R is 1 colonne (i have realy 20) and (65) the number of all my lines in the excel file (i want to have only the 2600 lines in my table) Also, when i say to do this L[c(1,2,5)] it is not work coluns not define someone have an idea? thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] K-means clustering with NA
I am running a k-means clustering code in R : mydata_kmeans5 - kmeans(mydata, centers=5).. But the problem is that the data is having some NA in it. So R is showing me a message :Error in switch(nmeth, { : NA/NaN/Inf in foreign function call (arg 1) In addition: Warning messages: 1: In switch(nmeth, { : NAs introduced by coercion 2: In switch(nmeth, { : NAs introduced by coercion... my objective is to find out the customers id who are falling in particular cluster say clst 1, clst2 etc...If I want to get a data like that where I will have customer id on one column and cluster number on the other..what code should I use exactly? Thanks in advance... Arup -- View this message in context: http://www.nabble.com/K-means-clustering-with-NA-tp24840626p24840626.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] acf Significance
Steve Jones wrote: Thanks for the pointer to the str function - very handy! The output for the acf object is below - it doesn't seem to contain anything that might tell me the significance level. List of 6 $ acf : num [1:27, 1, 1] 1 0.6309 0.2989 0.0612 -0.2105 ... $ type : chr correlation $ n.used: int 27 $ lag : num [1:27, 1, 1] 0 1 2 3 4 5 6 7 8 9 ... $ series: chr time_series $ snames: NULL - attr(*, class)= chr acf Does anyone have any more ideas? Well, yes, but it is kind of a long story. I assume you want the limits as are plotted by the acf function, usually in blue. Possibly you actually want the p-value for a given observed autocorrelation, but you will have to get that yourself working from my answer. The short answer to your question that the confidence limits are not returned by the acf function, they are in fact calculated in plot.acf. You have to look at the actual code. The beauty of R is that you can look at the code and hopefully in doing so, learn more about programming in R. First up, you decide to look in the obvious place, the code of acf. Print that out and have a look at it and you find that the plotting is done by plot.acf. When you try to print out plot.acf you get plot.acf Error: object plot.acf not found The reason is this function is non-visible as seen by methods(plot) [1] plot.acf* plot.data.frame*plot.Date* [4] plot.decomposed.ts* plot.defaultplot.dendrogram* [7] plot.densityplot.ecdf plot.factor* [10] plot.formula* plot.hclust*plot.histogram* [13] plot.HoltWinters* plot.isoreg*plot.lm [16] plot.medpolish* plot.mlmplot.POSIXct* [19] plot.POSIXlt* plot.ppr* plot.prcomp* [22] plot.princomp* plot.profile.nls* plot.spec [25] plot.spec.coherency plot.spec.phase plot.stepfun [28] plot.stl* plot.table* plot.ts [31] plot.tskernel* plot.TukeyHSD Non-visible functions are asterisked You can get it with getAnywhere(plot.acf) however. So look through plot.acf. You will need to look at the help for it to see that it allows for two different types of limit, one assuming white noise and one assuming an MA model. Most likely you want the white noise case. The place where the confidence limit is calculated is not too hard to find, it is clim0 - if (with.ci) qnorm((1 + ci)/2)/sqrt(x$n.used) This where x is an object of class acf with structure you saw when you used str. So that is it. If your acf is called x, and your confidence level is ci, then the limit is given by qnorm((1 + ci)/2)/sqrt(x$n.used) The steps needed to access R code including underlying C and Fortran are explained in the article by Uwe Ligges: Uwe Ligges. R Help Desk: Accessing the sources. R News, 6(4):43-45, October 2006. This article is essential reading for anyone contemplating much use of R. David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] hi, i have a problem in R
Hi vie, I've inserted comments within your message below. Gina Liao wrote: Hi, I'm new to R language. There is a problem I couldn't understand. Hope you can answer my question. when i type for (i in 1:10){ + print(sample(9,4,replace=T)) +} The above produces 10 vectors, each containing four numbers between 1 and 9. and it shows ten of four numbers and how do I do to calculate the frequencies in each list? table(sample(9,4)) I know there is a hint; list10-vector(mode=list,length=4) What you probably want to do is to make each vector an element of a list. If you really want a list containing four vectors with ten integers in each vector, you want: mysamplelist-vector(list,4) for(i in 1:4) mysamplelist[[i]]-sample(9,10,TRUE) sapply(mysamplelist,table) But I don't know how to use it. How do I name each list? names(mysamplelist)-c(Allan,Bertrand,Cicero,Dracula) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] opration / dates in R
Hi, how can i use operation + , - , / with veriable format DATES? for example i have two variable a - 18/08/2008 and b - 18/09/2010 and i want to calculate a-b ?? 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] R User Group listings
On Sat, 01 Aug 2009 08:30:50 -0400, Prof John C Nash (PJCN) wrote: Better ideas should prevail. There is now a wiki page at http://wiki.r-project.org/rwiki/doku.php?id=rugs:r_user_groups. It is not yet fully populated. (David Smith's blog at REvolution Computing mentions more groups.) Excellent, thanks a lot. I'll add a link to the menu of the R homepage. Best, Fritz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 User Group listings
FrL == Friedrich Leisch friedrich.lei...@stat.uni-muenchen.de on Thu, 6 Aug 2009 11:38:03 +0200 writes: On Sat, 01 Aug 2009 08:30:50 -0400, Prof John C Nash (PJCN) wrote: Better ideas should prevail. There is now a wiki page at http://wiki.r-project.org/rwiki/doku.php?id=rugs:r_user_groups. It is not yet fully populated. (David Smith's blog at REvolution Computing mentions more groups.) FrL Excellent, thanks a lot. I'll add a link to the menu of FrL the R homepage. Really? Should this be more than mailing lists? I can see that, but then also the point of two many entries in the top-level r-project.org web page. Why should a local user's group be mentioned more dominantly than a virtual group such as the R Mac Users, R-SIG-Mac ? Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] why is 0 not an integer?
On Wed, Aug 5, 2009 at 11:28 PM, Erik Iverson eiver...@nmdp.org wrote: First, this has nothing to do with 0. Assigning 1000 to an element of v would also have this effect. Two, the first element of a vector is indexed by 1, not 0. While what you wrote isn't a syntax error (v[0] - 0), it may be not doing what you think, but I don't know. According to R Language Definition, foo[0] always returns an empty vector. No idea why this is useful but it is a bit confusing that one can actually assign to foo[0] (and even foo[NULL] ) with some effect: foo - 1:10 class(foo) # integer foo[NULL] - une souris verte foo # all the same numbers there class(foo) # changed to character!! k Finally, the answer to your question. Try typing class(0) to see that it is in fact numeric. So you may want v[1] - as.integer(0) to get what you are expecting. HTH. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steve Jaffe Sent: Wednesday, August 05, 2009 3:16 PM To: r-help@r-project.org Subject: [R] why is 0 not an integer? Why when I assign 0 to an element of an integer vector does the type change to numeric? Here is a particularly perplexing example: v - 0:10 v [1] 0 1 2 3 4 5 6 7 8 9 10 class(v) [1] integer v[0] - 0 class(v) [1] numeric #!! -- View this message in context: http://www.nabble.com/why-is-0-not-an-integer--tp24835423p24835423.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. [[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] R User Group listings
On Thu, 6 Aug 2009 11:54:26 +0200, Martin Maechler (MM) wrote: FrL == Friedrich Leisch friedrich.lei...@stat.uni-muenchen.de on Thu, 6 Aug 2009 11:38:03 +0200 writes: FrL Excellent, thanks a lot. I'll add a link to the menu of FrL the R homepage. Really? Should this be more than mailing lists? I can see that, but then also the point of two many entries in the top-level r-project.org web page. Why should a local user's group be mentioned more dominantly than a virtual group such as the R Mac Users, R-SIG-Mac ? Hmm, not more dominantly, but on par? And note that I entered User Groups under Misc on bottom of the menu bar, while mailing lists are far more up the list. But the web pages need a serious re-organization anyway, especially the Related Projects part is a big mess. Best, Fritz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re : opration / dates in R (it is ok thanks)
i found it it is the function difftime(date1,date2) thank you gays!!! De : Peter Konings peter.l.e.koni...@gmail.com Envoyé le : Jeudi, 6 Août 2009, 11h44mn 09s Objet : Re: [R] opration / dates in R Hi, There are a number of possibilities. Check out the R wiki for an overview of the available manuals, articles, etc. on working with dates: http://wiki.r-project.org/rwiki/doku.php?id=guides:times-datess=dates also, consider reading a book or manual to get started - this will save you a lot of time in the end. See for example the R website for a list of contributed documentation: http://cran.r-project.org/other-docs.html HTH Peter. wrote: Hi, how can i use operation + , - , / with veriable format DATES? for example i have two variable a - 18/08/2008 and b - 18/09/2010 and i want to calculate a-b ?? 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. [[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] Fitting Mixture of Non-Central Student's t Distributions
Dear Ingmar Dave, Thanks a lot for your help and sorry for the late reply. Finally, I've found a way to separate the mixture of distributions (empirically). But the gamlss package looks great, I'm sure it will help me during my further studies. Kind regards, Susanne On 15 Jun 2009, at 20:09, Ingmar Visser wrote: Dear Susanne Dave, The gamlss package family has an enormous variety of distributions and a function to combine them into mixtures. In particular, the 3 parameter student's t and the 4 parameter generalized t distribution. Hth, Ingmar On 15 Jun 2009, at 17:12, David Hunter wrote: Hi Susanne. The mixtools package does not do this automatically and I would be surprised if there were any package that does. However, it's not in principle too difficult to write code to implement an EM algorithm to search for a maximum likelihood estimator in a finite mixture model. Check out a reference on finite mixture models that discusses EM algorithms (e.g., Section 2.2 of http://www.stat.psu.edu/~dhunter/papers/mixtools.pdf although there are undoubtedly better references out there for this purpose). In the case of components that are assumed to be noncentral Student t distributions, you may have a bit of trouble since if I remember correctly, it is not easy to do MLE even for the non-mixture case here. That said, in general, writing an EM algorithm for the finite- mixture-model case is not much more difficult computationally than writing code for MLE in the non-mixture case. This means that you could try expanding your search to include other packages that might do MLE for the (non-mixture) case of noncentral t distributions. If such a package exists, then it shouldn't be too hard to write your own mixture-model EM wrapper. Hope this helps. Good luck! Dave David Hunter Associate professor Department of Statistics Penn State University Phone: (814) 863-0979 Fax: (814) 863-7114 www.stat.psu.edu/~dhunter On Jun 13, 2009, at 7:54 AM, Balzer Susanne wrote: Dear all, I am attempting to model some one-dimensional data using a mixture model of non-central Student's t distributions. However, I haven't been able to find any R package that provides this functionality. Could there be a way to manipulate the EM algorithms from the mixdist or mixtools package to fit the model, or do you have any other suggestions? If anyone could help me out, I would be extremely grateful. Kind regards, Susanne Balzer Susanne Balzer PhD Student Institute of Marine Research N-5073 Bergen, Norway Phone: +47 55 23 69 45 susanne.balzer at imr.no www.imr.no __ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] opration / dates in R
Try this: as.Date(18/08/2008, %d/%m/%Y) - as.Date(18/09/2010, %d/%m/%Y) On Thu, Aug 6, 2009 at 6:27 AM, Inchallah Yarab inchallahya...@yahoo.frwrote: Hi, how can i use operation + , - , / with veriable format DATES? for example i have two variable a - 18/08/2008 and b - 18/09/2010 and i want to calculate a-b ?? 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] solving system of equations involving non-linearities
Hi, I would appreciate if someone could help me on track with this problem. I want to compute some parameters from a system of equations given a number of sample observations. The system looks like this: sum_i( A+b_i0 A+b_iC+d_i) = x sum_i( C+d_i0 C+d_iA+b_i) = y sum_i( exp(E+f_i) * ( A+b_i0 A+b_iC+d_i) = z A, C, E are free variables while the other letters represent values given from sample observations. The equations involve counts of the number of fulfilled conditions and therefore non-linearities. Furthermore, since I have many observations i, the equations will unlikely hold exactly and solving will require some closeness measure like the sum of the squared deviations or so. Is there any function in R suitable for solving this problem? Thanks so much for your help, Werner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] looking for a function to plot the distribution of values (not sure of the name)
Hello, I have a dataframe of two columns : A (with values A1, A2, ..., Ai, ... A2) and B (with values B1, B2, ..., Bi, ... B2) and I would like to plot a graph like this : X=A Y= (the density of B as a function of A) * (the value of B as a function of A) I think it must already exist a function in R calculating Y but as I'm really not used to use (and talk of) statistics (especially in english), I don't know how to call this kind of function and then I didn't manage to find a solution in some posts (what to use as keywords ?). Thanks in advance for your help (and your tolerance), Have a good day, Ptit Bleu. -- View this message in context: http://www.nabble.com/looking-for-a-function-to-plot-the-distribution-of-values-%28not-sure-of-the-name%29-tp24845160p24845160.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] problem with r import data
On Thu, 2009-08-06 at 08:37 +, Inchallah Yarab wrote: Good moorning, yesterday, i asked for how we can import data into R i found that it is necessary to make the file in csv format then use L- read.csv2(path of file) Does read.csv() work instead? How is your csv file delimited? columns separated by ; or by ,? now i see that the dimension of my table importing into R is 1 colonne (i have realy 20) and (65) the number of all my lines in the excel file (i want to have only the 2600 lines in my table) So you failed to import your data correctly. Also, when i say to do this L[c(1,2,5)] it is not work coluns not define That isn't how you select columns from a matrix-like object: [r,c] is the usual format, you just specified elements 1,2,5. E.g. dat - data.frame(X = 1:10) # 1 column data frame dat[c(1,2,5)] Error in `[.data.frame`(dat, c(1, 2, 5)) : undefined columns selected Sort out getting your data into R correctly first, then you can worry about subsetting it. HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] S4 method dispatch: coercion of arguments with setAs defined
Hi Renaud -- Renaud Gaujoux ren...@mancala.cbio.uct.ac.za writes: Hi list, I've got a class B that contains a slot obj of class A. I'd like to be able to call all the methods of class A directly on objects of class B as if I had called the method on slot obj. This without overloading all methods of class A to work on class B. I don't define B as an extension of A, because I want class B to also work with objects of classes that inherit from class A and that I don't know the names. So I tried to dispatch the methods of class A to slot obj using function setAs as follows: setClass('A', representation(number='numeric')) setGeneric('getNumber', function(object) standardGeneric('getNumber')) setMethod('getNumber', 'A', function(object) obj...@number) setClass('B', representation(obj='A', extra='list')) setAs('B', 'A', def= function(from) f...@obj ) objB - new('B', obj=new('A', number=10)) getNumber(objB) But get the error: Error in function (classes, fdef, mtable) : unable to find an inherited method for function getNumber, for signature B I thought the dispatch procedure in S4 would try to find a way to coerce objects of class 'B' into the closest class usable with the given method (in that case into an object of class 'A'). I expected it to internally do: getNumber(as(objB, 'A')) Am I thinking wrong or do I need to do another thing to make it work? setAs defines a method for coercing from one object to another, without defining an inheritance. You can use 'setIs' setClass('A', representation(number='numeric')) setGeneric('number', function(object) standardGeneric('number')) setMethod('number', 'A', function(object) obj...@number) setClass('B', representation(obj='A', extra='list')) setIs(B, A, test=function(object) TRUE, coerce=function(object) slot(object, obj), replace=function(object, value) { slot(object, obj) - value object }) to define an inheritance relationship: objB - new('B', obj=new('A', number=10)) number(objB) [1] 10 This is not something I usually do (are all A methods appropriate for B's slot 'obj'?) and at least in my hands there seem to be some rough edges setGeneric(number-, function(object, value) standardGeneric(number-)) setReplaceMethod(number, A, function(object, value) { slot(object, number) - value object }) number(objB) - 20 is(objB, B) [1] FALSE Martin Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] delete lines
Hi , I need to write a function to delete a row if the value of one element of the row is negatif!!! I have a big file of data and i will check every lines!!! Any ideas 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] R User Group listings
Fritz, Thanks for link in News! Looking forward to link in Misc. (I agree with on par concept) John, To address how do we get started questions - how about a sub-page on R wiki where we can post what we've learned some of issues encountered? Best, Jim Porzak Ancestry.com San Francisco, CA www.linkedin.com/in/jimporzak use R! Group SF: www.meetup.com/R-Users/ On Thu, Aug 6, 2009 at 3:19 AM, Friedrich Leischfriedrich.lei...@stat.uni-muenchen.de wrote: On Thu, 6 Aug 2009 11:54:26 +0200, Martin Maechler (MM) wrote: FrL == Friedrich Leisch friedrich.lei...@stat.uni-muenchen.de on Thu, 6 Aug 2009 11:38:03 +0200 writes: FrL Excellent, thanks a lot. I'll add a link to the menu of FrL the R homepage. Really? Should this be more than mailing lists? I can see that, but then also the point of two many entries in the top-level r-project.org web page. Why should a local user's group be mentioned more dominantly than a virtual group such as the R Mac Users, R-SIG-Mac ? Hmm, not more dominantly, but on par? And note that I entered User Groups under Misc on bottom of the menu bar, while mailing lists are far more up the list. But the web pages need a serious re-organization anyway, especially the Related Projects part is a big mess. Best, Fritz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] delete lines
# identify rows with only positive values mydata.index - apply(mydata, 1, function(x)all(x = 0)) # create a new data frame/matrix with only those rows mydata.pos - mydata[mydata.index,] Sarah On Thu, Aug 6, 2009 at 8:57 AM, Inchallah Yarabinchallahya...@yahoo.fr wrote: Hi , I need to write a function to delete a row if the value of one element of the row is negatif!!! I have a big file of data and i will check every lines!!! Any ideas Thank you !! -- 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] Stacked plots with common x-axis and different y-axis
Gabor, Thanks a ton for your insights. Two questions - Here is the code I tried to run: z - with(airquality, zoo(cbind(Wind, Temp), Month + (Day - 1)/31)) plot(z, ylab=c(Wind (mph), Temp (Deg F)), col=c(royalblue1, red3), xlab = c(Month Index, col=dark red)) grid() The grid does not appear to fit within the x-axis and y-axis limits, and also the Month Index text appears to be corrupted. Is there a way to fix this? Thanks again for the insights. --- On Wed, 8/5/09, Gabor Grothendieck ggrothendi...@gmail.com wrote: From: Gabor Grothendieck ggrothendi...@gmail.com Subject: Re: [R] Stacked plots with common x-axis and different y-axis To: Jason Rupert jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Wednesday, August 5, 2009, 8:09 PM Try this: library(zoo) # ignore the fact that months have different lengths z - with(airquality, zoo(cbind(Wind, Temp), Month + (Day - 1)/31)) plot(z) # each on separate plot stacked above each other plot(z, screen = 1) # both on same plot library(lattice) xyplot(z) xyplot(z, screen = 1) ?plot.zoo has examples of using two y axes on the same plot On Tue, Aug 4, 2009 at 5:33 PM, Jason Rupertjasonkrup...@yahoo.com wrote: Is there a place that shows how to create two plots that are stacked on top of each other where they share a common x-axis scale, but have differnt y-axis scale? Say have the following data: airquality Stack plot(airquality$Day, airquality$Wind) on top of plot(airquality$Day, airquality$Temp). I am interested in stacking the two on top of each other with no seam, or plotting the two lines with two different y-axis scales on the same plot. Thanks for any feedback and insights. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] calasification table under conditions
hi, i have a file with 49000 lines i want to do a classification in two tables suppose data - read.csv2(c:/total.csv, sep=,) if the second colonne contains ( A,B,C,D) tab1 if the second colonne contains ( E,F,G,H) tab2 How can do this ? Thank you for your help [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stacked plots with common x-axis and different y-axis
In multipanel displays this sort of customization must be done in the panel function: pnl - function(...) { lines(...); grid() } library(zoo) z - with(airquality, zoo(cbind(Wind, Temp), Month + (Day - 1)/31)) plot(z, col = c(royalblue1, red3), panel = pnl, xlab = , ylab=c(Wind (mph), Temp (Deg F))) or use the panel function below, instead, if you also want the dark red X Axis label. The first three lines of the function body get the panel number, the number of panels and test whether we are at the bottom panel. There are more examples of panel functions in the Examples section of ?plot.zoo pnl - function(...) { panel.number - parent.frame()$panel.number nser - parent.frame()$nser # if bottom panel if (panel.number == nser) { mtext(Month Index, side = 1, line = 3, col = dark red) } lines(...) grid() } On Thu, Aug 6, 2009 at 9:20 AM, Jason Rupertjasonkrup...@yahoo.com wrote: Gabor, Thanks a ton for your insights. Two questions - Here is the code I tried to run: z - with(airquality, zoo(cbind(Wind, Temp), Month + (Day - 1)/31)) plot(z, ylab=c(Wind (mph), Temp (Deg F)), col=c(royalblue1, red3), xlab = c(Month Index, col=dark red)) grid() The grid does not appear to fit within the x-axis and y-axis limits, and also the Month Index text appears to be corrupted. Is there a way to fix this? Thanks again for the insights. --- On Wed, 8/5/09, Gabor Grothendieck ggrothendi...@gmail.com wrote: From: Gabor Grothendieck ggrothendi...@gmail.com Subject: Re: [R] Stacked plots with common x-axis and different y-axis To: Jason Rupert jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Wednesday, August 5, 2009, 8:09 PM Try this: library(zoo) # ignore the fact that months have different lengths z - with(airquality, zoo(cbind(Wind, Temp), Month + (Day - 1)/31)) plot(z) # each on separate plot stacked above each other plot(z, screen = 1) # both on same plot library(lattice) xyplot(z) xyplot(z, screen = 1) ?plot.zoo has examples of using two y axes on the same plot On Tue, Aug 4, 2009 at 5:33 PM, Jason Rupertjasonkrup...@yahoo.com wrote: Is there a place that shows how to create two plots that are stacked on top of each other where they share a common x-axis scale, but have differnt y-axis scale? Say have the following data: airquality Stack plot(airquality$Day, airquality$Wind) on top of plot(airquality$Day, airquality$Temp). I am interested in stacking the two on top of each other with no seam, or plotting the two lines with two different y-axis scales on the same plot. Thanks for any feedback and insights. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] calasification table under conditions
Hi, On Aug 6, 2009, at 9:26 AM, Inchallah Yarab wrote: hi, i have a file with 49000 lines i want to do a classification in two tables suppose data - read.csv2(c:/total.csv, sep=,) if the second colonne contains ( A,B,C,D) tab1 if the second colonne contains ( E,F,G,H) tab2 How can do this ? One easy way is to read the data into a table first, then split it in two after loading. I'm going to take you literally when you say you want the column to contain, rather than the column be equal to, so I'll use some regular expression mojo: dat - read.csv2(...) tab1 - dat[grep('[ABCD]', dat[,2], ] tab2 - dat[grep('[EFGH]', dat[,2]), ] optionally rm the dat variable if you're hurting for RAM. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] making scatter plot points fill semi-transparent
You can also use ggplot2: library(ggplot2) x - rnorm(1);y - rnorm(x);myplot - data.frame(x,y) qplot(x,y,data= myplot,colour=I(alpha(blue,1/25))) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA --- On Wed, 8/5/09, Gabor Grothendieck ggrothendi...@gmail.com wrote: From: Gabor Grothendieck ggrothendi...@gmail.com Subject: Re: [R] making scatter plot points fill semi-transparent To: per freem perfr...@gmail.com Cc: r-help@r-project.org Date: Wednesday, August 5, 2009, 9:13 PM Lattice graphics can do that: library(lattice) xyplot(0:20 ~ 0:20, alpha = 0:20/20, col = red, pch = 19, cex = 5) Google for HTML colors to find out more about the hex codes you are referring to. On Wed, Aug 5, 2009 at 11:48 PM, per freemperfr...@gmail.com wrote: hi all, i have a simple scatter plot, and i'd like to make it so the scatter plot colors are slightly transparent. i see in a previous post that someone mentioned the alpha parameter, but i am not sure how it can be used with the 'plot' function [*]. for example, suppose i have: plot(mydata$column1, mydata$column2, col=red, cex=1) i now want to make it so the color of these points (in this case red) is slightly transparent, which will make overlap between them very obvious. i realize that hexbin and other density plot methods are used to make this, but i am using it for a different purpose, and so i just want the points to be transparent without any binning or shading. a previous poster suggested: plot( rnorm(1000), rnorm(1000), col=#ff22, pch=16,cex=3) but i don't understand this color notation. is there any way to pass in the usual col=colorname argument and then tweak that color's transparency? thank you. https://stat.ethz.ch/pipermail/r-help/2007-October/142934.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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Some SQL Challenges
Don't understand what this has to do with SQL, or why you're asking for SQL solutions in an R mailing list, but here are some R suggestions. (abbreviating COLUMN with C) At 11:40 AM -0700 8/3/09, JoK LoQ wrote: Hi, Im trying to complete a list of jobs using SQL Querries and some if else commands but im stucked in some steps. Could any of you give me some help? -in COLUMN1 change the format 20JAN2000:00:00:00 to 20JAN2000 and exclude every row that date is different from 20. Assuming C1 contains character strings: C1 - substring( C1, 1, 9) C1 - C1[ substring(C1,1,2) == '20' ] -extract the first character in COLUMN2 and creat COLUMN3 with that value ex: COL2,COL3 135,1 461,4 247,2 C3 - substring( C2, 1 ,1) or C3 - as.numeric( substring( C2, 1, 1) ) -in every row in which COL3=5, value in COLUMN4=value in COLUMN5 C4[ C3==5] - C5[ C3==5] -create COLUMN7 where if COLUMN6=north then COLUMN7 value=N else COLUMN7 value=X C7 - ifelse( C6 == north , N, X) Ill be grateful for any help, thnks -- View this message in context: http://*www.*nabble.com/Some-SQL-Challenges-tp24795946p24795946.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. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] delete lines
Try this: m[!apply(m 0, 1, any),] On Thu, Aug 6, 2009 at 9:57 AM, Inchallah Yarab inchallahya...@yahoo.frwrote: Hi , I need to write a function to delete a row if the value of one element of the row is negatif!!! I have a big file of data and i will check every lines!!! Any ideas 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] solving system of equations involving non-linearities
You have two options: 1. The `BBsolve' function in the BB package to solve this system of 3 equations. 2. Try `nleqslv' function in the nleqslv package. These would work even if the residual is not zero. Hope this helps, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Werner Wernersen pensterfuz...@yahoo.de Date: Thursday, August 6, 2009 7:56 am Subject: [R] solving system of equations involving non-linearities To: r-h...@stat.math.ethz.ch Hi, I would appreciate if someone could help me on track with this problem. I want to compute some parameters from a system of equations given a number of sample observations. The system looks like this: sum_i( A+b_i0 A+b_iC+d_i) = x sum_i( C+d_i0 C+d_iA+b_i) = y sum_i( exp(E+f_i) * ( A+b_i0 A+b_iC+d_i) = z A, C, E are free variables while the other letters represent values given from sample observations. The equations involve counts of the number of fulfilled conditions and therefore non-linearities. Furthermore, since I have many observations i, the equations will unlikely hold exactly and solving will require some closeness measure like the sum of the squared deviations or so. Is there any function in R suitable for solving this problem? Thanks so much for your help, Werner __ R-help@r-project.org mailing list PLEASE do read the posting guide 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 execute a R script but outputting the result to the screen?
Hi, If I run the below command, it will generate a file 'file.Rout' to save the output. But I want the output be shown in the screen directly. I'm wondering if there is a direct way to do so. R CMD BATCH file.R Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with r import data
?read.table and check on the options offered by read.csv2. Open the file in a text editor and see what you have. Check the delimiters and be sure that that they are either ; as specified in read.csv2 or else specify the delimiter ( sep= ??? --- On Thu, 8/6/09, Inchallah Yarab inchallahya...@yahoo.fr wrote: From: Inchallah Yarab inchallahya...@yahoo.fr Subject: [R] problem with r import data To: r-help@r-project.org Received: Thursday, August 6, 2009, 4:37 AM Good moorning, yesterday, i asked for how we can import data into R i found that it is necessary to make the file in csv format then use L- read.csv2(path of file) now i see that the dimension of my table importing into R is 1 colonne (i have realy 20) and (65) the number of all my lines in the excel file (i want to have only the 2600 lines in my table) Also, when i say to do this L[c(1,2,5)] it is not work coluns not define someone have an idea? thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Be smarter than spam. See how smart SpamGuard is at giving junk email __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 execute a R script but outputting the result to the screen?
You did not specify your OS, but you might try at the shell prompt: Rscript file.R See ?Rscript -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Thursday, August 06, 2009 9:35 AM To: r-h...@stat.math.ethz.ch Subject: [R] How to execute a R script but outputting the result to the screen? Hi, If I run the below command, it will generate a file 'file.Rout' to save the output. But I want the output be shown in the screen directly. I'm wondering if there is a direct way to do so. R CMD BATCH file.R Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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: function cannot be evaluated at initial parameters
I am facing a similar problem The code which i am pasting below has been taken from the book Bayesian Computation with R by Jim Albert. laplace=function (logpost, mode, par) { options(warn=-1) fit=optim(mode, logpost, gr = NULL, par, hessian=TRUE, control=list(fnscale=-1)) options(warn=0) mode=fit$par h=-solve(fit$hessian) p=length(mode) int = p/2 * log(2 * pi) + 0.5 * log(det(h)) + logpost(mode, par) stuff = list(mode = mode, var = h, int = int, converge=fit$convergence==0) return(stuff) } A-read.table(file=chemotherapy.txt,head=TRUE) A library(survival) Model_01=survreg(Surv(A$time,A$status)~factor(A$treat)+A$age,dist=weibull) weibullregpost=function (theta, A) { logf=function(t,c,x,sigma,mu,beta) { z=(log(t)-mu-x%*%beta)/sigma f=1/sigma*exp(z-exp(z)) S=exp(-exp(z)) c*log(f)+(1-c)*log(S) } k = dim(A)[2] p = k - 2 t = A[, 1] c = A[, 2] X = A[, 3:k] sigma = exp(theta[1]) mu = theta[2] beta = array(theta[3:k], c(p,1)) return(sum(logf(t,c,X,sigma,mu,beta))) } start=array(c(-Model_01$scale, Model_01$coefficients),c(1,4)) d=cbind(A$time,A$status,A$treat-1,A$age) fit=laplace(weibullregpost, start, d) fit proposal=list(var=fit$var,scale=1.5) rwmetrop=function (logpost, proposal, start, m, par) { pb = length(start) Mpar = array(0, c(m, pb)) b = matrix(t(start)) lb = logpost(start, par) a = chol(proposal$var) scale = proposal$scale accept = 0 for (i in 1:m) { bc = b + scale * t(a) %*% array(rnorm(pb), c(pb, 1)) lbc = logpost(t(bc), par) prob = exp(lbc - lb) if (is.na(prob) == FALSE) { if (runif(1) prob) { lb = lbc b = bc accept = accept + 1 } } Mpar[i, ] = b } accept = accept/m stuff = list(par = Mpar, accept = accept) return(stuff) } bayesfit=rwmetrop(weibullregpost,proposal,fit$mode,1,d) bayesfit$accept par(mfrow=c(2,2)) sigma=exp(bayesfit$par[,1]) mu=bayesfit$par[,2] beta1=bayesfit$par[,3] beta2=bayesfit$par[,4] hist(beta1,xlab=treatment) hist(beta2,xlab=age,main=) hist(sigma,xlab=sigma,main=) The code is running fine for the data given in the book, but when i am using it on my data which is quite large compared to book's data, i am gettin same error. Then i tried changing the parameters and tested a lot of them but the error remains. The other error which i got was Error in chol.default(proposal$var) : the leading minor of order 1 is not positive definite In addition: Warning message: In log(det(h)) : NaNs produced Can anybody suggest some way to get the right parameters? It is really very urgent and i desperately need some help!!! Thanks a lot sandsky wrote: I have an error for a simple optimization problem. Is there anyone knowing about this error? lambda1=-9 lambda2=-6 L-function(a){ s2i2f-(exp(-lambda1*(250^a)-lambda2*(275^a-250^a)) -exp(-lambda1*(250^a)-lambda2*(300^a-250^a))) logl-log(s2i2f) return(-logl)} optim(1,L) Error in optim(1, L) : function cannot be evaluated at initial parameters Thank you in advance -- View this message in context: http://www.nabble.com/Error%3A--function-cannot-be-evaluated-at-initial-parameters-tp19565286p24846455.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] Re move all punctuations except commas
Dear all, I wanted to remove all punctuations except commas from a string. I used: gsub([[:punct:]], , string) but I don't know how to exclude the commas ,. Anyone would kindly answer my basic question? -- View this message in context: http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24845721.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] xyplot and subscripts
Hi all, I have a data frame like this: DF - data.frame(x = rnorm(10), y = rnorm(10), gr = rep(1:5, 2)) and I make the following xy-plot: library(lattice) xyplot(y ~ x, data = DF, groups = gr, type = b, col = 1) Is it possible that the two points that belong to the same group specified by DF$gr to have a different color -- that is for each pair of points connected by the line, I want one to be black and the other red. I tried: xyplot(y ~ x, data = DF, groups = gr, type = b, col = 1:2) but it doen't work. Is there any solution for this?? Thanks a lot! Kito __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 ::Not able to Connect R to SQL Server 2000
Hi Simon, I am using the R 2.9.1 with Window XP. I have one query related with R to the database. I have successfully connected R to MS-Access. But when I tried to connect R to SQL Server 2000 then it throwing some class not found error. I tried the below script for R and try to connect to SQL Server 2000. library(rJava) library(DBI) library(RJDBC) drv-JDBC(com.microsoft.jdbc.sqlserver.SQLServerDriver) Error in .jfindClass(as.character(driverClass)[1]) : class not found Can you please help me in this? Thanks to you. Regards. BS [[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] Seasonal analysis
Hi, Are there any R packages around which would break down a time series into a MxN table for analysis purposes? For example, show the total sales per month per calendar year. Jan Feb. Total 2008 2009 Total Thanks, Eduard -- View this message in context: http://www.nabble.com/Seasonal-analysis-tp24844839p24844839.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] Re move all punctuations except commas
Try this: string - Aaaa. , ccc gsub([^,[:alpha:]|[:space:]], , string) On Thu, Aug 6, 2009 at 9:37 AM, Rnewbie xua...@yahoo.com wrote: Dear all, I wanted to remove all punctuations except commas from a string. I used: gsub([[:punct:]], , string) but I don't know how to exclude the commas ,. Anyone would kindly answer my basic question? -- View this message in context: http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24845721.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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] donlp2
Dear Sir, I am working with one example in R donlp2. How I can get the Hessian matrix from the output. p = c(10,10) par.l = c(-100,-100) par.u = c(100,100) nlin.l = nlin.u = 2 fn = function(x) { x[1]^2+x[2]^2 } dfn = function(x){ c(2*x[1], 2*x[2]) } attr(fn, gr) = dfn nlcon = function(x){ x[1]*x[2] } dnlcon = function(x){ c(x[2], x[1]) } attr(nlcon, gr) = dnlcon donlp2.control = function(hessian = TRUE) ret = donlp2(p, fn, par.u=par.u, par.l=par.l, nlin=list(nlcon), nlin.u=nlin.u, nlin.l=nlin.l,control = donlp2.control()) Thanks, -- Chirackel Ahammed Yoonus Research Associate, Center for Advanced Financial Studies, Institute for Financial Management and Research, Chennai, India - 600034 +91-44-28303 531, +91-9840377561 email : kala...@gmail.com, skype : cayoonus [[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] Re move all punctuations except commas
Try something along these lines: gsub([^[:alnum:][:space:],], , string) On Thu, Aug 6, 2009 at 8:37 AM, Rnewbiexua...@yahoo.com wrote: Dear all, I wanted to remove all punctuations except commas from a string. I used: gsub([[:punct:]], , string) but I don't know how to exclude the commas ,. Anyone would kindly answer my basic question? -- View this message in context: http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24845721.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] random between two values
Hi, I would obtain a random value between two (for example between 40.15 and 56.58 I would have only one value). I'm looking for a package/a function which could do this. Could anybody help me please? Cordialement Damien Landais __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] S4 method dispatch: coercion of arguments with setAs defined
Thanks Martin, it's clearer now. Indeed things get a bit dirty with replace methods. I'm wondering if it's a bug, a normal behaviour or if there is nothing to do about it? I think it's because the replace method of A into B is not called after replacing an object's slot. I imagine this would be done in method 'slot-', wouldn't it? See messages with the following code: setIs(B, A, test=function(object){ message(Test if B is A); TRUE}, coerce=function(object){ message(Coerce B into A); slot(object, obj)}, replace=function(object, value) { message(Replace slot A in B) slot(object, obj) - value object }) setGeneric(number-, function(object, value) standardGeneric(number-)) setReplaceMethod(number, A, function(object, value) { message(Replace number in A) slot(object, number) - value object }) objB - new('B', obj=new('A', number=10)) number(objB) - 20 Martin Morgan wrote: Hi Renaud -- Renaud Gaujoux ren...@mancala.cbio.uct.ac.za writes: Hi list, I've got a class B that contains a slot obj of class A. I'd like to be able to call all the methods of class A directly on objects of class B as if I had called the method on slot obj. This without overloading all methods of class A to work on class B. I don't define B as an extension of A, because I want class B to also work with objects of classes that inherit from class A and that I don't know the names. So I tried to dispatch the methods of class A to slot obj using function setAs as follows: setClass('A', representation(number='numeric')) setGeneric('getNumber', function(object) standardGeneric('getNumber')) setMethod('getNumber', 'A', function(object) obj...@number) setClass('B', representation(obj='A', extra='list')) setAs('B', 'A', def= function(from) f...@obj ) objB - new('B', obj=new('A', number=10)) getNumber(objB) But get the error: Error in function (classes, fdef, mtable) : unable to find an inherited method for function getNumber, for signature B I thought the dispatch procedure in S4 would try to find a way to coerce objects of class 'B' into the closest class usable with the given method (in that case into an object of class 'A'). I expected it to internally do: getNumber(as(objB, 'A')) Am I thinking wrong or do I need to do another thing to make it work? setAs defines a method for coercing from one object to another, without defining an inheritance. You can use 'setIs' setClass('A', representation(number='numeric')) setGeneric('number', function(object) standardGeneric('number')) setMethod('number', 'A', function(object) obj...@number) setClass('B', representation(obj='A', extra='list')) setIs(B, A, test=function(object) TRUE, coerce=function(object) slot(object, obj), replace=function(object, value) { slot(object, obj) - value object }) to define an inheritance relationship: objB - new('B', obj=new('A', number=10)) number(objB) [1] 10 This is not something I usually do (are all A methods appropriate for B's slot 'obj'?) and at least in my hands there seem to be some rough edges setGeneric(number-, function(object, value) standardGeneric(number-)) setReplaceMethod(number, A, function(object, value) { slot(object, number) - value object }) number(objB) - 20 is(objB, B) [1] FALSE Martin Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] random between two values
sample(c(a,b))[1] -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of damien landais Sent: Thursday, August 06, 2009 11:02 AM To: R-help@r-project.org Subject: [R] random between two values Hi, I would obtain a random value between two (for example between 40.15 and 56.58 I would have only one value). I'm looking for a package/a function which could do this. Could anybody help me please? Cordialement Damien Landais __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] random between two values
That's pretty straightforward to do - here's a simple function. The exact behavior at the edges is left as an exercise. :) rbound - function(rmin, rmax) { x - runif(1) x - x * (rmax - rmin) + rmin x } Sarah On Thu, Aug 6, 2009 at 11:02 AM, damien landaisdamien.land...@tdf.fr wrote: Hi, I would obtain a random value between two (for example between 40.15 and 56.58 I would have only one value). I'm looking for a package/a function which could do this. Could anybody help me please? Cordialement Damien Landais -- 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 to execute a R script but outputting the result to the screen?
I didn't know that OS matters. My machine is a linux machine. I have a few different version of R installed in my machine (different commands like R, R-2.9.0, R-2.8 ..). But I don't see the version of Rscript. How to figure out which version of R my Rscript uses? Regards, Peng On Thu, Aug 6, 2009 at 9:45 AM, Erik Iversoneiver...@nmdp.org wrote: You did not specify your OS, but you might try at the shell prompt: Rscript file.R See ?Rscript -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Thursday, August 06, 2009 9:35 AM To: r-h...@stat.math.ethz.ch Subject: [R] How to execute a R script but outputting the result to the screen? Hi, If I run the below command, it will generate a file 'file.Rout' to save the output. But I want the output be shown in the screen directly. I'm wondering if there is a direct way to do so. R CMD BATCH file.R Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Re move all punctuations except commas
Here is a second solution that may be closer to what you were thinking of in terms of structure: library(gsubfn) gsubfn([[:punct:]], ~ sub([^,], , x), string) This matches each punctuation character and then removes any non-commas by applying the function function(x)sub([^,], , x) gsubfn is just like gsub except the replacement string can be a replacement function and one can abbreviate the function using a formula notation as shown. See http://gsubfn.googlecode.com On Thu, Aug 6, 2009 at 11:00 AM, Gabor Grothendieckggrothendi...@gmail.com wrote: Try something along these lines: gsub([^[:alnum:][:space:],], , string) On Thu, Aug 6, 2009 at 8:37 AM, Rnewbiexua...@yahoo.com wrote: Dear all, I wanted to remove all punctuations except commas from a string. I used: gsub([[:punct:]], , string) but I don't know how to exclude the commas ,. Anyone would kindly answer my basic question? -- View this message in context: http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24845721.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] Select subset with specific distribution parameters.
This may be a simple problem, but I am looking to select a subset of rows from a dataframe that will have the same parameters as all the rows in another dataframe. e.g. I have a 500 row dataframe with 20 columns. I want to select a subset of rows from a larger dataframe that match the distribution of values for one or more of the columns within the 500 row dataframe (i.e. within same range, but also having same mean/median and overall shape). By basic subsetting I can get a set with a similar approximate distribution to the 500 row dataset, but not highly similar, and this might be a problem for the analysis. Any help would be much appreciated, thanks. -- View this message in context: http://www.nabble.com/Select-subset-with-specific-distribution-parameters.-tp24848201p24848201.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] Re move all punctuations except commas
it works, but does that mean I really have to specify what to keep rather than what to remove? Gabor Grothendieck wrote: Try something along these lines: gsub([^[:alnum:][:space:],], , string) On Thu, Aug 6, 2009 at 8:37 AM, Rnewbiexua...@yahoo.com wrote: Dear all, I wanted to remove all punctuations except commas from a string. I used: gsub([[:punct:]], , string) but I don't know how to exclude the commas ,. Anyone would kindly answer my basic question? -- View this message in context: http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24845721.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. -- View this message in context: http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24848515.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 execute a R script but outputting the result to the screen?
Try: Rscript -e R.version.string to get the R version, or Rscript --version if you want to know the version of Rscipt itself rather than R. On Thu, Aug 6, 2009 at 11:18 AM, Peng Yupengyu...@gmail.com wrote: I didn't know that OS matters. My machine is a linux machine. I have a few different version of R installed in my machine (different commands like R, R-2.9.0, R-2.8 ..). But I don't see the version of Rscript. How to figure out which version of R my Rscript uses? Regards, Peng On Thu, Aug 6, 2009 at 9:45 AM, Erik Iversoneiver...@nmdp.org wrote: You did not specify your OS, but you might try at the shell prompt: Rscript file.R See ?Rscript -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Thursday, August 06, 2009 9:35 AM To: r-h...@stat.math.ethz.ch Subject: [R] How to execute a R script but outputting the result to the screen? Hi, If I run the below command, it will generate a file 'file.Rout' to save the output. But I want the output be shown in the screen directly. I'm wondering if there is a direct way to do so. R CMD BATCH file.R Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Re move all punctuations except commas
In the solution you cite, yes. In the second solution I provided in the subsequent (second) response to your question, no. On Thu, Aug 6, 2009 at 11:17 AM, Rnewbiexua...@yahoo.com wrote: it works, but does that mean I really have to specify what to keep rather than what to remove? Gabor Grothendieck wrote: Try something along these lines: gsub([^[:alnum:][:space:],], , string) On Thu, Aug 6, 2009 at 8:37 AM, Rnewbiexua...@yahoo.com wrote: Dear all, I wanted to remove all punctuations except commas from a string. I used: gsub([[:punct:]], , string) but I don't know how to exclude the commas ,. Anyone would kindly answer my basic question? -- View this message in context: http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24845721.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. -- View this message in context: http://www.nabble.com/Remove-all-punctuations-except-commas-tp24845721p24848515.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] overlap two graph
It really sounds like you want to use points(). Maybe I'm missing the true question but ellipsePoints returns a 2 column matrix of point coordinates so passing it's output to points() should plot those points on whatever plot you currently have open (in this case the plot of the previous ellipse). If you're looking for an alternative way to do it, you could rbind the outputs together and then plot the whole thing: allPoints-rbind(ellipsePoints(2,5, alpha = 30),ellipsePoints(2,5, alpha = 60)) plot(allPoints) Scott Scott Sherrill-Mix Department of Microbiology University of Pennsylvania 402B Johnson Pavilion 3610 Hamilton Walk Philadelphia, PA 19104-6076 On Thu, Aug 6, 2009 at 3:15 AM, Hemavathi Ramuluhema.ram...@gmail.com wrote: Hi, actually there are coding before plot(ellipsePoints(2,5, alpha = 30), asp=1) which i got it from this website http://www.biostat.wustl.edu/archives/html/s-news/2002-10/msg00186.html It only can draw one ellipse, Now I want to know how to add more ellipse in same diagram? thank you. On Wed, Aug 5, 2009 at 9:53 PM, Scott Sherrill-Mix shesc...@mail.med.upenn.edu wrote: Did you try already try: plot(ellipsePoints(2,5, alpha = 30), asp=1) points(ellipsePoints(2,5, alpha = 60), asp=1,col='red') ? Scott Scott Sherrill-Mix Department of Microbiology University of Pennsylvania 402B Johnson Pavilion 3610 Hamilton Walk Philadelphia, PA 19104-6076 On Wed, Aug 5, 2009 at 5:46 AM, Hemavathi Ramuluhema.ram...@gmail.com wrote: Hi everyone,I need you all help. I want to create few image in same diagram. For example, I wan draw two ellipse in same diagram. plot(ellipsePoints(2,5, alpha = 60), asp=1) and plot(ellipsePoints(2,5, alpha = 30), asp=1) How to display both ellipse together? both is different in angle. Thank you. -- Hemavathi Ramulu [[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. -- Hemavathi Ramulu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 stop function printing unwanted output?
Hi, I want to use an output of one function (LSD.test) in other. How is it that while saving output from LSD.test to variable, it prints own output out? The function could be simplified to: fun - function ( ... ) { ... lsd - LSD.test(data[1], data[2], df, mse) ... } In my example, I don't want LSD.test to print any output, I just want to use some of it later... How to stop it printing anything? Greetz, Timo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] random between two values
Or just use runif's built-in bounds: thisMin-40.15 thisMax-56.58 runif(1,thisMin,thisMax) Scott Scott Sherrill-Mix Department of Microbiology University of Pennsylvania 402B Johnson Pavilion 3610 Hamilton Walk Philadelphia, PA 19104-6076 On Thu, Aug 6, 2009 at 11:11 AM, Sarah Gosleesarah.gos...@gmail.com wrote: That's pretty straightforward to do - here's a simple function. The exact behavior at the edges is left as an exercise. :) rbound - function(rmin, rmax) { x - runif(1) x - x * (rmax - rmin) + rmin x } Sarah On Thu, Aug 6, 2009 at 11:02 AM, damien landaisdamien.land...@tdf.fr wrote: Hi, I would obtain a random value between two (for example between 40.15 and 56.58 I would have only one value). I'm looking for a package/a function which could do this. Could anybody help me please? Cordialement Damien Landais -- 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Matrix function
Hi, I have an equation Xcp and would like to look at errors affecting it. I am applying errors of -.58 to .1 to R and -.45 to .47 to Xc. I would like to look at all combinations. I set up a matrix function as follows and it does not work. On the last line, when it run, it does not seem like the two Xs are not the same. Example: it is NOT 1+(162/1), but using another R value. R-c(1:5) Xc-c(16:20) Xcp-R+((Xc^2)/R) test=R+(Xc^2/R) x=c(-.58, -.44, -.31, -.17, -.04, .1) y=c(-.45,-.27,-.08,.10,.29,.47) actual=Xcp X=((R%o%x+R)) Y=(Xc%o%y+Xc) num.x.col - length(X[1,]) num.y.col - length(Y[1,]) num.rows - length(X[,1]) Z - matrix(nrow=num.rows, ncol=num.x.col*num.y.col) for( i in 1:num.rows) { Z[i,] - as.vector(X[i,] + ((Y[i,])^2 %*% t(X[i,])^-1 )) } -- M. Keith Cox, Ph.D. Alaska NOAA Fisheries, National Marine Fisheries Service Auke Bay Laboratories 17109 Pt. Lena Loop Rd. Juneau, AK 99801 keith@noaa.gov marlink...@gmail.com U.S. (907) 789-6603 [[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 to stop function printing unwanted output?
On Aug 6, 2009, at 11:42 AM, Tymek W wrote: Hi, I want to use an output of one function (LSD.test) in other. How is it that while saving output from LSD.test to variable, it prints own output out? The function could be simplified to: fun - function ( ... ) { ... lsd - LSD.test(data[1], data[2], df, mse) ... } In my example, I don't want LSD.test to print any output, I just want to use some of it later... How to stop it printing anything? ?invisible David Winsemius, MD Heritage Laboratories 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 stop function printing unwanted output?
In my example, I don't want LSD.test to print any output, I just want to use some of it later... How to stop it printing anything? ?invisible I'm not sure that works in this situation: test - function() { print(output) } test() invisible(test()) Both of the above still print out output, which I think is the original problem. The invisible function will not print the value of a function, but if there is an explicit print call within the function, that will of course happen, since the value hasn't been returned at that point. However, we don't know the original problem since LSD.test is not defined, and therefore the example is not reproducible. I assume within the function, it is printing out some values using print or cat? We just have to guess though. Maybe the answer is in ?sink ?? Erik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 stop function printing unwanted output?
On Aug 6, 2009, at 12:24 PM, Erik Iverson wrote: In my example, I don't want LSD.test to print any output, I just want to use some of it later... How to stop it printing anything? ?invisible I'm not sure that works in this situation: test - function() { print(output) } test() invisible(test()) Both of the above still print out output, which I think is the original problem. The invisible function will not print the value of a function, but if there is an explicit print call within the function, that will of course happen, since the value hasn't been returned at that point. However, we don't know the original problem since LSD.test is not defined, and therefore the example is not reproducible. I assume within the function, it is printing out some values using print or cat? We just have to guess though. Maybe the answer is in ?sink ?? Quite right. A search suggests that LSD.test is from package agricolae and it does have several points at which cat() and print() would be subverting my intent. So the answer would be to sink it somewhere that the sun does not shine and then unsink or would that be resurface? With the example on the LSD.test help page: sink(file=undesired.txt) comparison - invisible( LSD.test(yield,virus,df,MSerror, p.adj=bonferroni, group=FALSE, + main=Yield of sweetpotato\ndealt with different virus) ) sink() comparison trtmeans M N std.err 1 cc 24.4 3 2.084067 2 fc 12.86667 3 1.246774 3 ff 36.3 3 4.233727 4 oo 36.9 3 2.482606 Erik David Winsemius, MD Heritage Laboratories 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] Help ::Not able to Connect R to SQL Server 2000
On Aug 6, 2009, at 10:36 , bed.si...@oracle.com wrote: Hi Simon, I am using the R 2.9.1 with Window XP. I have one query related with R to the database. I have successfully connected R to MS-Access. But when I tried to connect R to SQL Server 2000 then it throwing some class not found error. I tried the below script for R and try to connect to SQL Server 2000. library(rJava) library(DBI) library(RJDBC) drv-JDBC(com.microsoft.jdbc.sqlserver.SQLServerDriver) Error in .jfindClass(as.character(driverClass)[1]) : class not found Can you please help me in this? Thanks to you. I suspect that you'll need to load the corresponding drivers. The message essentially tells you that the driver (class) you're trying to load is not known. I don't use Windows (and even less so SQL Server), so I'd suggest you search for JDBC and MS SQL Server and/or ask on the SIG-DB mailing list (although this is technically not an R question). With some luck there may be some MS SQL users on this list as well.. However, if you are on Windows, you may want to go directly to ODBC using RODBC instead of going through JDBC. Cheers, Simon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem installing cairo on freebsd
Late, but hopefully not too late ... Ben, I had same problem with Cairo-1.4-5 on FreeBSD CURRENT-8.0 (i386). On of the authors of Cairo (thanks to Simon Urbanek) reminded me to use gmake instead of make. So in my case I set the environment variable temporarily like this (in tcsh): setenv MAKE gmake R CMD INSTALL Cairo-1.4-5.tar.gz unsetenv MAKE That's all. Good luck, Rainer On 21.07.2009 09:53 (UTC+2), Ben Madin wrote: G'day all, I am trying to install the cairo package on FreeBSD and receiving an error to do with Makevars - (I'm not very good at this stuff) so here is my various bits of information. I guess this is a problem with a missing library, but I have just been through a lot of grief trying to get png and jpeg to work (they do now work!), so I'm not sure where to go for this. R version 2.9.0 (2009-04-17) on FreeBSD server.ausvet.com.au 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sat Jun 7 13:33:54 EST 2008 b...@server.au:/usr/obj/usr/src/sys/AUSVET_CUSTOM i386 with : cairo-1.8.8,1 and p5-Cairo-1.061 using : install.packages(Cairo) and I get this: trying URL 'http://cran.ms.unimelb.edu.au/src/contrib/Cairo_1.4-5.tar.gz' Content type 'application/x-tar' length 75318 bytes (73 Kb) opened URL == downloaded 73 Kb * Installing *source* package 'Cairo' ... checking for gcc... gcc43 -std=gnu99 checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc43 -std=gnu99 accepts -g... yes checking for gcc43 -std=gnu99 option to accept ISO C89... none needed checking how to run the C preprocessor... cpp checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/wait.h that is POSIX.1 compatible... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for string.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking for unistd.h... (cached) yes checking for an ANSI C-conforming const... yes checking for pkg-config... /usr/local/bin/pkg-config checking whether pkg-config knows about cairo... yes checking for configurable backends... gnome-config: not found gnome-config: not found cairo cairo-ft cairo-pdf cairo-png cairo-ps cairo-xlib cairo-xlib-xrender configure: CAIRO_CFLAGS=-D_THREAD_SAFE -I/usr/local/include/cairo -I/usr/local/include/pixman-1 -I/usr/local/include/freetype2 -I/usr/local/include checking if R was compiled with the RConn patch... no checking cairo.h usability... yes checking cairo.h presence... yes checking for cairo.h... yes checking for PNG support in Cairo... yes checking for ATS font support in Cairo... no configure: CAIRO_LIBS=-pthread -L/usr/local/lib -lfreetype -lfontconfig -lpng -lm -lz -lXrender -lcairo -lX11 checking for library containing deflate... none required checking whether Cairo programs can be compiled... yes checking whether cairo_image_surface_get_format is declared... no checking for FreeType support in cairo... yes checking whether FreeType needs additional flags... no checking wheter libjpeg works... yes checking wheter libtiff works... yes configure: creating ./config.status config.status: creating src/Makevars config.status: creating src/cconfig.h ** libs Makevars, line 2: Need an operator Makevars, line 4: Need an operator make: fatal errors encountered -- cannot continue ERROR: compilation failed for package 'Cairo' * Removing '/usr/local/lib/R/library/Cairo' The downloaded packages are in '/tmp/RtmpcIvbUg/downloaded_packages' Updating HTML index of packages in '.Library' Warning message: In install.packages(Cairo) : installation of package 'Cairo' had non-zero exit status cheers Ben __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 stop function printing unwanted output?
?capture.output so with the given example this line should do what you wanted while avoiding the output file dummy - capture.output(comparison - LSD.test(yield,virus,df,MSerror, p.adj=bonferroni, group=FALSE, main=Yield of sweetpotato\ndealt with different virus)) Matthias David Winsemius wrote: On Aug 6, 2009, at 12:24 PM, Erik Iverson wrote: In my example, I don't want LSD.test to print any output, I just want to use some of it later... How to stop it printing anything? ?invisible I'm not sure that works in this situation: test - function() { print(output) } test() invisible(test()) Both of the above still print out output, which I think is the original problem. The invisible function will not print the value of a function, but if there is an explicit print call within the function, that will of course happen, since the value hasn't been returned at that point. However, we don't know the original problem since LSD.test is not defined, and therefore the example is not reproducible. I assume within the function, it is printing out some values using print or cat? We just have to guess though. Maybe the answer is in ?sink ?? Quite right. A search suggests that LSD.test is from package agricolae and it does have several points at which cat() and print() would be subverting my intent. So the answer would be to sink it somewhere that the sun does not shine and then unsink or would that be resurface? With the example on the LSD.test help page: sink(file=undesired.txt) comparison - invisible( LSD.test(yield,virus,df,MSerror, p.adj=bonferroni, group=FALSE, + main=Yield of sweetpotato\ndealt with different virus) ) sink() comparison trtmeans M N std.err 1 cc 24.4 3 2.084067 2 fc 12.86667 3 1.246774 3 ff 36.3 3 4.233727 4 oo 36.9 3 2.482606 Erik David Winsemius, MD Heritage Laboratories 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. -- Matthias Burger Project Manager/ Biostatistician Epigenomics AGKleine Praesidentenstr. 110178 Berlin, Germany phone:+49-30-24345-0fax:+49-30-24345-555 http://www.epigenomics.com matthias.bur...@epigenomics.com -- Epigenomics AG Berlin Amtsgericht Charlottenburg HRB 75861 Vorstand: Geert Nygaard (CEO/Vorsitzender) Oliver Schacht PhD (CFO) Aufsichtsrat: Prof. Dr. Dr. hc. Rolf Krebs (Chairman/Vorsitzender) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Completion for custom $ operator?
Completion should be automatic if you define names() to return the valid names. Thank you Deepayan, that works beautifully. I wonder though; names function for environment objects always returns NULL, but completion still works. Looks tricky. Vitalie. -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] installing R on Solaris 10
Anyone have any experience installing R on UNIX or Linux, I have a Solaris 10 server and have been trying to read the admin guide and install the R binaries on the machine. There are several failures due to an unknown pathname: ERROR: attribute verification of /usr/local/R/lib/R/library/MASS/latex/Null.tex failed pathname does not exist unable to fix attributes The initial install appears to be performed and when I choose to display R project info it displays: ld.so.1: R: fatal: libreadline.so.5: open failed: No such file or directory Killed Any ideas as to what I am missing or forgetting? Thanks in advance, -- Jeremy Willis Mathematics and Statistics Dept Computer Systems Technician/Admin (435)797-4061 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Completion for custom $ operator?
On Thu, Aug 6, 2009 at 10:45 AM, Vitalie S.vitosm...@rambler.ru wrote: Completion should be automatic if you define names() to return the valid names. Thank you Deepayan, that works beautifully. I wonder though; names function for environment objects always returns NULL, but completion still works. Looks tricky. There's a special case coded-in for environments, where one needs to use ls() [See utils:::specialCompletions]. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 with Logit Model
Hello, I have a bit of a tricky puzzle with trying to implement a logit model as described in a paper. The particular paper is on horseracing and they explain a model that is a logit trained per race, yet somehow the coefficients are combined across all the training races to come up with a final set of coefficients. My understanding is that they maximize log likelihood across the entire set of training races. Yet this isn't just as standard logit model as they are looking at data per race. This is a bit hard to explain, so I've attached a tiny pdf of the paragraph from the paper explaining this. Like everything else in the data/stat/econ world, there is probably a library in R that does this kind of thing, but after 3 days of heavy google research, I've been unable to find it. Does anyone have any suggestions?? Thanks. -N __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is there a 'vi' mode in R?
Hi, I'm wondering if R provide a vi mode in the command line just like other shells such as bash do. Can somebody let me know? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to show help in the same mode as where the commands is input?
Hi, In R command line, when I type help(something), it will always show the help in the different mode such that I don't see command lines anymore but just the help document. If I quit from the help mode, I will only see the command lines by not the help document. I would like the help document and command lines be show in the same mode. I'm wondering how to do so. Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using system fonts in MacOS
Dear r-help, I am using R for MacOS (R 2.9.1 GUI 1.28 Tiger build 32-bit (5444)) and would like to be able to use MacOS system fonts for the labels on my plots. So far I have been unsuccessful, to get this to work. Reading the help I found the quartz() and quartzFonts() commands. In an attempt to set the font family I have tried this, quartz(family=Times-Roman), and also this, quartz.options(family=Times-Roman). This opens a new Quartz window, but the labels are still in the default font, when I make a new plot. I have two question: (1) Why doesn't the quartz(family=Times-Roman) make the fonts change? (2) Is it possible to use any MacOS system fonts with R and the Quartz device window? Best regards, Daniel Farrell __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 execute a R script but outputting the result to the screen?
Is there a command line option for me to figure out what R version Rscript calls? On Aug 6, 10:23 am, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try: Rscript -e R.version.string to get the R version, or Rscript --version if you want to know the version of Rscipt itself rather than R. On Thu, Aug 6, 2009 at 11:18 AM, Peng Yupengyu...@gmail.com wrote: I didn't know that OS matters. My machine is a linux machine. I have a few different version of R installed in my machine (different commands like R, R-2.9.0, R-2.8 ..). But I don't see the version of Rscript. How to figure out which version of R my Rscript uses? Regards, Peng On Thu, Aug 6, 2009 at 9:45 AM, Erik Iversoneiver...@nmdp.org wrote: You did not specify your OS, but you might try at the shell prompt: Rscript file.R See ?Rscript -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Thursday, August 06, 2009 9:35 AM To: r-h...@stat.math.ethz.ch Subject: [R] How to execute a R script but outputting the result to the screen? Hi, If I run the below command, it will generate a file 'file.Rout' to save the output. But I want the output be shown in the screen directly. I'm wondering if there is a direct way to do so. R CMD BATCH file.R Regards, Peng __ r-h...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ r-h...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to show help in the same mode as where the commands is input?
Hi, You can define your own pager: Something like this might do what you want: dump.pager - function( files, ...){ cat( readLines( files ), sep = \n ) } options( pager = dump.pager ) Romain On 08/06/2009 08:59 PM, Peng Yu wrote: Hi, In R command line, when I type help(something), it will always show the help in the different mode such that I don't see command lines anymore but just the help document. If I quit from the help mode, I will only see the command lines by not the help document. I would like the help document and command lines be show in the same mode. I'm wondering how to do so. Regards, Peng -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/vzip : Code Snippet : List of CRAN packages |- http://tr.im/vsK1 : R parser package on CRAN `- http://tr.im/vshK : Transfer files through Rserve __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] solving system of equations involving non-linearities
Ravi Varadhan wrote: You have two options: 1. The `BBsolve' function in the BB package to solve this system of 3 equations. 2. Try `nleqslv' function in the nleqslv package. These would work even if the residual is not zero. I hope so but I have some doubts. From the original question I get the impression that this is more a nonlinear least squares problem. I'ld certainly also take a look at optim and other optimisation routines (nlm, BBoptim,...). Have a look in the Task Views: Optimization on CRAN. Berend -- View this message in context: http://www.nabble.com/solving-system-of-equations-involving-non-linearities-tp24845136p24853134.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] Using 'field names' of a data.frame in a function
I may be doing this wrong! but I have a function which I have simplified a lot below. I want to pass some 'field names' of a data-frame to the function for it to then do some manipulation of. Here's my code: #build a simple dataset mydataset = data.frame ( ages=c('40-49','40-49','40-49','30-39','50-59','50-59','60-69','50-59'), sex = c(M,F,F,M,F,F,M,M)) #build a simple function myfunc - function (categories) { table (categories) } #call the function myfunc (c(mydataset$ages, mydataset$sex)) === My output I am getting is: categories 1 2 3 4 5 7 3 1 But what I'm expecting is: table (mydataset$ages, mydataset$sex) F M 30-39 0 1 40-49 2 1 50-59 2 1 60-69 0 1 Calling the function as: myfunc (mydataset$ages, mydataset$sex) doesn't work either and nor does myfunc (c(mydataset$ages, mydataset$sex)) Now in the simple version above I could make the function (category1, category2) and then call table (category1, category2) - but what if I might have a category 3, category 4 etc... How can I pass the dataset name to the function without it trying to actually pass the data to the function? I've also tried paste - but perhaps I'm mis-using it? Many thanks for help in advance This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] writing a simulation
Dear All I 've solved this problem... Thanks Meenu On Thu, Aug 6, 2009 at 1:28 AM, Meenu Sahi meenus...@gmail.com wrote: No its not an or condition. Please see the changed attachment. Many thanks for your help. Regards Meenu On Wed, Aug 5, 2009 at 6:36 PM, David Winsemius dwinsem...@comcast.netwrote: On Aug 4, 2009, at 2:12 PM, Meenu Sahi wrote: Dear R Users I'm writing my first simulation in R. I've put across my problems with a smaller example in the attachment along with the questions. Please help. See Simpson reply to Q1 ##Question2: How can I easily identify which out of the 9 states does ad fall into with Level =5.04 and spread=0.25? ##OUTPUT ad X6 Level 5.04 spread 0.25 state state8 But spread for state7 was -0.34? Had it been 0.24, then this should work (some of the time.) subset(mydat4, Level == 5.4 spread==0.25) [1] Level spread change State 0 rows (or 0-length row.names) Perhaps you meant to specify an or condition? subset(mydat4, Level == 5.4 | spread==0.24) Level spread change State 10 5.40 -0.34BrF State7 11 4.89 0.24BlF State8 Best regards Meenu Example.txt__ R-help@r-project.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. David Winsemius, MD Heritage Laboratories West Hartford, CT [[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] Write the results of sample function which uses a dataframe into an Array
Dear All? Basically I want to write the results of the sample function into an array is a specific order. The sample function uses a dataframe x.1 and therefore the result is also a dataframe and so I cannot write the result into the array in the correct order. If I convert x.1 into a matrix then the sample function fails. PLease help as to what is the problem !!! Has anyone had a similar problem? Please read the question and the problem in the attachment. Many thanks for your time. Kind regards Meenu x.1 is a matrix with 93 columns class(x.1) [1] matrix x.1 41 4243 44 45 EU0006MIndex 0.00500 -0.03337 1.431e-02 0.01387 -0.05793000 DMSW1Curncy 0.06420 -0.05780 5.610e-02 -0.00060 -0.1517 DMSW2Curncy 0.09600 -0.06450 1.053e-01 -0.02730 -0.2335 DMSW3Curncy 0.05850 -0.07550 1.398e-01 -0.05470 -0.2466 DMSW4Curncy 0.02650 -0.08650 1.710e-01 -0.08500 -0.2365 DMSW5Curncy -0.01100 -0.09400 1.815e-01 -0.09830 -0.2252 DMSW6Curncy -0.03650 -0.10100 1.795e-01 -0.09840 -0.2181 DMSW7Curncy -0.05650 -0.11750 1.864e-01 -0.09590 -0.2100 DMSW8Curncy -0.07300 -0.12250 1.872e-01 -0.09920 -0.2015 DMSW9Curncy -0.08650 -0.12650 1.876e-01 -0.09860 -0.1915 DMSW10Curncy -0.10750 -0.13550 1.872e-01 -0.09270 -0.1850 DMSW12Curncy -0.11950 -0.14650 1.900e-01 -0.09300 -0.1735 DMSW15Curncy -0.13200 -0.16600 1.790e-01 -0.07900 -0.1580 DMSW20Curncy -0.13050 -0.19100 1.560e-01 -0.07450 -0.1395 DMSW30Curncy -0.13150 -0.22800 1.600e-01 -0.06900 -0.1230 EUSA40Curncy -0.13350 -0.23220 1.552e-01 -0.07950 -0.1015 EUSA50Curncy -0.13250 -0.22970 1.637e-01 -0.08950 -0.1005 Libor_OAS 0.001208618 -0.005033614 4.506e-05 -0.004526479 -0.01386261 46 47 48 49 50 EU0006MIndex -0.00938 -0.04000 0.04888 0.00687 0.05225 DMSW1Curncy -0.06020 -0.07430 0.15850 -0.02080 0.12740 DMSW2Curncy -0.10200 -0.13300 0.24260 -0.06270 0.18310 DMSW3Curncy -0.12900 -0.13990 0.23590 -0.08500 0.17900 DMSW4Curncy -0.16600 -0.13990 0.21640 -0.09800 0.16670 DMSW5Curncy -0.14700 -0.14990 0.18240 -0.11400 0.14700 DMSW6Curncy -0.13400 -0.15650 0.15500 -0.12700 0.12500 DMSW7Curncy -0.18100 -0.14000 0.16750 -0.13300 0.10400 DMSW8Curncy -0.17300 -0.12650 0.13400 -0.14000 0.08800 DMSW9Curncy -0.16200 -0.14990 0.13640 -0.14500 0.07550 DMSW10Curncy -0.14650 -0.16150 0.12650 -0.14800 0.06650 DMSW12Curncy -0.14100 -0.16000 0.11750 -0.15300 0.05450 DMSW15Curncy -0.13100 -0.16700 0.10300 -0.15500 0.04400 DMSW20Curncy -0.11300 -0.17000 0.08400 -0.16150 0.03450 DMSW30Curncy -0.10900 -0.17990 0.07490 -0.16800 0.02200 EUSA40Curncy -0.11000 -0.18500 0.07500 -0.17400 0.03250 EUSA50Curncy -0.11200 -0.18500 0.07800 -0.17700 0.03150 Libor_OAS-0.002243875 0.006692975 -0.002139178 0.006372163 -0.000319492 51 52 53 54 90 EU0006MIndex 0.17200 0.2200 0.03963000 0.0595 -0.7918700 DMSW1Curncy 0.24500 0.2143 0.0662 0.0640 -0.460 DMSW2Curncy 0.27230 0.1552 0.0750 0.1170 -0.422 DMSW3Curncy 0.27300 0.1203 0.0742 0.1420 -0.386 DMSW4Curncy 0.28730 0.1020 0.0335 0.1621 -0.311 DMSW5Curncy 0.28650 0.0917 -0.0037 0.1786 -0.2255000 DMSW6Curncy 0.28350 0.0787 -0.0297 0.1849 -0.164 DMSW7Curncy 0.27050 0.0711 -0.0591 0.1957 -0.109 DMSW8Curncy 0.26050 0.0611 -0.0741 0.1939 -0.050 DMSW9Curncy 0.25300 0.0522 -0.0942 0.1972 -0.041 DMSW10Curncy 0.24500 0.0463 -0.1083 0.1975 -0.0175000 DMSW12Curncy 0.23000 0.0400 -0.1270 0.1926 0.0255000 DMSW15Curncy 0.21100 0.0388 -0.1418 0.1811 0.0885000 DMSW20Curncy 0.19000 0.0325 -0.1545 0.1825 0.1165000 DMSW30Curncy 0.19100 0.0215 -0.1765 0.1850 0.1295000 EUSA40Curncy 0.17450 0.0085 -0.1835 0.1800 0.1145000 EUSA50Curncy 0.17250 0.0045 -0.1895 0.1680 0.0805000 Libor_OAS-0.006313754 -0.01380074 -0.01809107 -0.01037939 0.2329775 91 92 93 94 20
Re: [R] Using 'field names' of a data.frame in a function
Try this: myfunc - function(...)table(...) with(mydataset, myfunc(ages, sex)) On Thu, Aug 6, 2009 at 4:50 PM, Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polw...@nhs.net wrote: I may be doing this wrong! but I have a function which I have simplified a lot below. I want to pass some 'field names' of a data-frame to the function for it to then do some manipulation of. Here's my code: #build a simple dataset mydataset = data.frame ( ages=c('40-49','40-49','40-49','30-39','50-59','50-59','60-69','50-59'), sex = c(M,F,F,M,F,F,M,M)) #build a simple function myfunc - function (categories) { table (categories) } #call the function myfunc (c(mydataset$ages, mydataset$sex)) === My output I am getting is: categories 1 2 3 4 5 7 3 1 But what I'm expecting is: table (mydataset$ages, mydataset$sex) F M 30-39 0 1 40-49 2 1 50-59 2 1 60-69 0 1 Calling the function as: myfunc (mydataset$ages, mydataset$sex) doesn't work either and nor does myfunc (c(mydataset$ages, mydataset$sex)) Now in the simple version above I could make the function (category1, category2) and then call table (category1, category2) - but what if I might have a category 3, category 4 etc... How can I pass the dataset name to the function without it trying to actually pass the data to the function? I've also tried paste - but perhaps I'm mis-using it? Many thanks for help in advance This message may contain confidential information. If ...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 question regarding R scoping
Hi, The intention is that after executing f2, the value of i to become 1. f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) print(i)} i.e. f2 should print 1, not length(n). ivo --- On Thu, 8/6/09, Steve Lianoglou mailinglist.honey...@gmail.com wrote: From: Steve Lianoglou mailinglist.honey...@gmail.com Subject: Re: [R] A question regarding R scoping To: Ivo Shterev idc...@yahoo.com Cc: r-help@r-project.org Date: Thursday, August 6, 2009, 3:07 AM Hi, On Aug 5, 2009, at 5:55 PM, Ivo Shterev wrote: I have a question related to scoping. Suppose we have 2 functions: f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) } In other words, I would like i=1 regardless of n. Is this possible without having f1 in the body of f2? Thanks in advance! Uhm ... what? You want i = 1 where, exactly? You want to call to f1(i) to set i to 1 in f2? Sorry, I don't really follow. Can you be a bit more explicit? -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Convert dataframe to table with counts where column names become row names
Can anyone explain how best to go from a dataframe to a table (or better yet a new dataframe) of counts, where the row names in the new table (or dataframe) are the column names of the original df. start w/ DF1 = Pos1 Pos2 Pos3 oligo1 G C A oligo2 U U A oligo3 G C C oligo4 C G U oligo5 A A G . End with DF2 = G A U C Pos1 2 1 1 1 Pos2 1 1 1 2 Pos3 1 2 1 1 I know how to generate the counts of each one column at a time using table(DF1$Pos1). Is there a way to do this in one step? Should I just write a for loop for each of the columns? thanks, greg -- View this message in context: http://www.nabble.com/Convert-dataframe-to-table-with-counts-where-column-names-become-row-names-tp24850797p24850797.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] tukey test for interaction
Hello I have performed the following ANOVA test (age = young and old, tret = non treated and treated): ANOVA_EPC-aov(Dibi ~ age*tret, data = EPC) summary(ANOVA_EPC) Df Sum Sq Mean Sq F value Pr(F) age 1 25.346 25.346 2.4510 0.13587 tret 1 5.962 5.962 0.5766 0.45806 age:tret 1 53.280 53.280 5.1522 0.03652 * Residuals 17 175.800 10.341 --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 And I can see a significative effect of interaction What is the Tukey code to see where the interaction is significant? EPC.TUKEY-TukeyHSD(ANOVA_EPC) EPC.TUKEY$ Thank you for your time Hirondelle Varady-Szabo, MSc. Professionnel de recherche Consortium en foresterie Gaspésie-Les-Îles 37, rue Chrétien, bur. 26, C.P. 5 Gaspé, Québec G4X 1E1 tél.: 418-368-5166 sans frais: 1-866-361-5166 téléc.: 418-368-0511 courriel: hirondelle.var...@foretgaspesie-les-iles.ca http://www.mieuxconnaitrelaforet.ca/ www.mieuxconnaitrelaforet.ca [[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] Time Series smoothing
I have a set of data (in a matrix). I spliced a column out and parsed it as.ts (time series). I then plotted the time series but I found that it was very noisy. I wanted to smooth it out. However, I am having some problems smoothing and plotting the smoothed version. A - as.ts(read.table(choose.files())) x - as.ts(A[,10]) plot(x) plot(smooth(x)) plot(smooth(x)) looks exactly like plot(x). Also, StructTS(x) Error in optim(init[mask], getLike, method = L-BFGS-B, lower = rep(0, : L-BFGS-B needs finite values of 'fn' The HoltWinters smoothing or the Kalman smoothing don't work either for various errors... I'm not quite sure what's wrong. Thanks. -- View this message in context: http://www.nabble.com/Time-Series-smoothing-tp24852054p24852054.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 show help in the same mode as where the commands is input?
It freezes at the last line. Do you know why? dump.pager - function( files, ...){ +cat( readLines( files ), sep = \n ) + } options( pager = dump.pager ) help(ls) Help on topic 'ls' was found in the following packages: Package Library AnnotationDbi /home/pengy/utility/R base /usr/local/lib64/R/library Loading Tcl/Tk interface ... done On Aug 6, 2:25 pm, Romain Francois romain.franc...@dbmail.com wrote: Hi, You can define your own pager: Something like this might do what you want: dump.pager - function( files, ...){ cat( readLines( files ), sep = \n )} options( pager = dump.pager ) Romain On 08/06/2009 08:59 PM, Peng Yu wrote: Hi, In R command line, when I type help(something), it will always show the help in the different mode such that I don't see command lines anymore but just the help document. If I quit from the help mode, I will only see the command lines by not the help document. I would like the help document and command lines be show in the same mode. I'm wondering how to do so. Regards, Peng -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30http://romainfrancois.blog.free.fr |-http://tr.im/vzip: Code Snippet : List of CRAN packages |-http://tr.im/vsK1: R parser package on CRAN `-http://tr.im/vshK: Transfer files through Rserve __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] filter function for time series
Hi all, I just need help understanding the filter function. I've seen how to use it to smooth a time series, but how do you know which is a good smoothing? Also, I have seen people do things like x1 = filter(x,filter=rep(1/5,5)) or x2 = filter(x,filter=rep(1/10,10)). I know that rep creates a vector with the first argument repeated the number of times in the second argument (e.g 1/5 1/5 1/5 1/5 1/5). But how does this have anything to do with the filter? Is the filter function some sort of unexplained algorithm? I just don't understand how it works. Thanks. -- View this message in context: http://www.nabble.com/filter-function-for-time-series-tp24852699p24852699.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] Repeatable, But Time Varying R GUI Crash
Hello, I'm having a problem in R. The R GUI is crashing with a message to contact Microsoft for the solution. I've contacted Microsoft and they are of no help. Below is a distilled set of code that will cause the crash. As you will see, there are two do-loops within which is a load command. The crash usually occurs after 200*400 (=80,000) to 2,000*400(=800,000) iterations. Do you have any suggestions on work-arounds? Once you start the function with the problem2() command, the function will print to the screen once every 400 iterations. You can monitor the progress by clicking the scroll button. The R GUI should crash somewhere between i=200 and i=2000. Although the problem is repeatable, the time at which the crash occurs is random. Thanks in advance for your attention, Rich Short I'm using Windows XP, SP3 and R 2.9.1. Here is my session info: sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base (The problem occurs on my Vista machine as well.) *** # This script induces the R GUI to crash. problem2 = function(){ junk = mat.or.vec(8,40) junk[] = 1 mjunk = mat.or.vec(8,40) mjunk[] = -1 PathA = tempdir() conX = paste(PathA,junkx,sep=\\) conY = paste(PathA,junky,sep=\\) outJunk = file(conX, open=wb) save(junk, file=outJunk) close(outJunk) outJunkY = file(conY, open=wb) save(mjunk, file=outJunkY) close(outJunkY) sign = 1 for(i in 1:4000){ for(ii in 1:400){ sign = -sign if(sign0){ load(file=conX) }else{ load(file=conY) } sum = junk[1,5] + mjunk[3,30] } cat( junk = ,junk[1,5],sep=) cat( mjunk = ,mjunk[3,30],sep=) cat( sum = ,sum,sep=) cat( i = ,i,\n,sep=) } } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 question regarding R scoping
Howdy, On Aug 6, 2009, at 4:11 PM, Ivo Shterev wrote: Hi, The intention is that after executing f2, the value of i to become 1. f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) print(i)} i.e. f2 should print 1, not length(n). Yeah, you can using parent.frame()'s and such: f1 - function(i) assign('i', 10, envir=parent.frame()) f2 - function(n) { i - length(n) f1(i) print(i) } R f2(1:20) [1] 10 Honestly, this just smells like a *really* bad idea, though ... just have f1() return a value that you use in f2. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 recording numeric output into another dataframe
dear all, I have two dataframes dataframe1 ID a b c dataframe2 ID value a;W 100 X;c 200 Y;Z 300 I wanted to match the IDs from the two dataframes and record the values into a new column of dataframe1 at the corresponding rows. This is what I expect: dataframe1 ID value a 100 b c 200 I tried doing it like this: for (i in seq(1:nrow(dataframe1))) { dataframe1[i,value]-dataframe2[grep(dataframe1[i,ID], dataframe2$ID),value] } but I failed. I was able to extracted the values from dataframe2 but not able to record the values in the corresponding rows of dataframe1. I would appreciate any suggestions. Thanks in advance. Jim -- View this message in context: http://www.nabble.com/problem-with-recording-numeric-output-into-another-dataframe-tp24850155p24850155.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] A question regarding R scoping
On 8/6/2009 4:11 PM, Ivo Shterev wrote: Hi, The intention is that after executing f2, the value of i to become 1. f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) print(i)} i.e. f2 should print 1, not length(n). ivo --- On Thu, 8/6/09, Steve Lianoglou mailinglist.honey...@gmail.com wrote: From: Steve Lianoglou mailinglist.honey...@gmail.com Subject: Re: [R] A question regarding R scoping To: Ivo Shterev idc...@yahoo.com Cc: r-help@r-project.org Date: Thursday, August 6, 2009, 3:07 AM Hi, On Aug 5, 2009, at 5:55 PM, Ivo Shterev wrote: I have a question related to scoping. Suppose we have 2 functions: f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) } In other words, I would like i=1 regardless of n. Is this possible without having f1 in the body of f2? Thanks in advance! It is possible by messing around with Sys.frame(), but a really bad idea. There are two variables named i: one local to f1, and another local to f2. Since f2 has no lexical relation to f1, things happening locally there should not affect f1. Duncan Murdoch Uhm ... what? You want i = 1 where, exactly? You want to call to f1(i) to set i to 1 in f2? Sorry, I don't really follow. Can you be a bit more explicit? -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] A question regarding R scoping
So is your question: Can you/how do you pass variables by reference in R? I do not know the answer, but I do think that is what you're getting at, yes? -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ivo Shterev Sent: Thursday, August 06, 2009 3:11 PM To: Steve Lianoglou Cc: r-help@r-project.org Subject: Re: [R] A question regarding R scoping Hi, The intention is that after executing f2, the value of i to become 1. f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) print(i)} i.e. f2 should print 1, not length(n). ivo --- On Thu, 8/6/09, Steve Lianoglou mailinglist.honey...@gmail.com wrote: From: Steve Lianoglou mailinglist.honey...@gmail.com Subject: Re: [R] A question regarding R scoping To: Ivo Shterev idc...@yahoo.com Cc: r-help@r-project.org Date: Thursday, August 6, 2009, 3:07 AM Hi, On Aug 5, 2009, at 5:55 PM, Ivo Shterev wrote: I have a question related to scoping. Suppose we have 2 functions: f1 = function(i){i = 1} f2 = function(n){ i = length(n) f1(i) } In other words, I would like i=1 regardless of n. Is this possible without having f1 in the body of f2? Thanks in advance! Uhm ... what? You want i = 1 where, exactly? You want to call to f1(i) to set i to 1 in f2? Sorry, I don't really follow. Can you be a bit more explicit? -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Convert dataframe to table with counts where column names become row names
Try this: t(sapply(DF1, table)) On Thu, Aug 6, 2009 at 2:14 PM, ghinkle ghin...@alnylam.com wrote: Can anyone explain how best to go from a dataframe to a table (or better yet a new dataframe) of counts, where the row names in the new table (or dataframe) are the column names of the original df. start w/ DF1 = Pos1 Pos2 Pos3 oligo1 G C A oligo2 U U A oligo3 G C C oligo4 C G U oligo5 A A G . End with DF2 = G A U C Pos1 2 1 1 1 Pos2 1 1 1 2 Pos3 1 2 1 1 I know how to generate the counts of each one column at a time using table(DF1$Pos1). Is there a way to do this in one step? Should I just write a for loop for each of the columns? thanks, greg -- View this message in context: http://www.nabble.com/Convert-dataframe-to-table-with-counts-where-column-names-become-row-names-tp24850797p24850797.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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Convert dataframe to table with counts where column names become row names
On Aug 6, 2009, at 1:14 PM, ghinkle wrote: Can anyone explain how best to go from a dataframe to a table (or better yet a new dataframe) of counts, where the row names in the new table (or dataframe) are the column names of the original df. start w/ DF1 = Pos1 Pos2 Pos3 oligo1 G C A oligo2 U U A oligo3 G C C oligo4 C G U oligo5 A A G . apply(DF1, 2, table) Pos1 Pos2 Pos3 A112 C121 G211 U111 Since tables are really matrices, the t() operation would bring you to your goal: t( apply(DF1, 2, table) ) A C G U Pos1 1 1 2 1 Pos2 1 2 1 1 Pos3 2 1 1 1 End with DF2 = G A U C Pos1 2 1 1 1 Pos2 1 1 1 2 Pos3 1 2 1 1 I know how to generate the counts of each one column at a time using table(DF1$Pos1). Is there a way to do this in one step? Should I just write a for loop for each of the columns? --- David Winsemius, MD Heritage Laboratories 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] Repeatable, But Time Varying R GUI Crash
On 8/6/2009 4:11 PM, Marilyn Rich Short wrote: Hello, I'm having a problem in R. The R GUI is crashing with a message to contact Microsoft for the solution. I've contacted Microsoft and they are of no help. Below is a distilled set of code that will cause the crash. As you will see, there are two do-loops within which is a load command. The crash usually occurs after 200*400 (=80,000) to 2,000*400(=800,000) iterations. Do you have any suggestions on work-arounds? I can confirm it in R-patched as well. It happens on the very first time through if you set gctorture() on, so it looks like somewhere in there is a missing PROTECT, and the garbage collector is reclaiming something that it shouldn't. I'll try to track it down, but I'm not sure how quick I'll be. (My house is full of contractors right now, so not a very nice place to work.) I don't know any workaround other than avoid doing the buggy thing. But I can't tell you what that is Duncan Murdoch Once you start the function with the problem2() command, the function will print to the screen once every 400 iterations. You can monitor the progress by clicking the scroll button. The R GUI should crash somewhere between i=200 and i=2000. Although the problem is repeatable, the time at which the crash occurs is random. Thanks in advance for your attention, Rich Short I'm using Windows XP, SP3 and R 2.9.1. Here is my session info: sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base (The problem occurs on my Vista machine as well.) *** # This script induces the R GUI to crash. problem2 = function(){ junk = mat.or.vec(8,40) junk[] = 1 mjunk = mat.or.vec(8,40) mjunk[] = -1 PathA = tempdir() conX = paste(PathA,junkx,sep=\\) conY = paste(PathA,junky,sep=\\) outJunk = file(conX, open=wb) save(junk, file=outJunk) close(outJunk) outJunkY = file(conY, open=wb) save(mjunk, file=outJunkY) close(outJunkY) sign = 1 for(i in 1:4000){ for(ii in 1:400){ sign = -sign if(sign0){ load(file=conX) }else{ load(file=conY) } sum = junk[1,5] + mjunk[3,30] } cat( junk = ,junk[1,5],sep=) cat( mjunk = ,mjunk[3,30],sep=) cat( sum = ,sum,sep=) cat( i = ,i,\n,sep=) } } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Ylim
Hello All: Can anybody tell me what is the problem with my program please. I have an error message as appears below. My program is: ifn - Jul08_09.LM data - read.table(ifn) ofn - Jul.png bitmap(ofn, type = png256, width = 30, height = 30, pointsize = 30, bg = white,res=50) par(mar=c(5, 5, 3, 2),lwd=5) par(cex.main=1.6,cex.lab=1.6,cex.axis=1.6) par(mfrow = c(3,4)) ifn - T.dat trait - read.table(ifn) i - 1 j - 1 for(k in 1:12) { dat - data[i:(i+2), ] colnames(dat)-c(SM,E,NP) Ymin - if( min(dat$SM) 0.0 ) (dat$SM - dat$E) else 0.0 Ymax - if( max(dat$SM) 0.0 ) (dat$SM + dat$E) else 0.0 Graph-barplot(dat$SM, names.arg=dat$NP, main = trait[j:j,], xlab = data[i:i,1:1], ylim = c(Ymin,Ymax) ) segments(Graph, dat$SM + dat$E, Graph, dat$SM - dat$E) i - i + 3 j - j + 1 } dev.off() And the error message is: Error in plot.window(xlim, ylim, log = log, ...) : invalid 'ylim' value Calls: barplot - barplot.default - plot.window Execution halted Thanks very much, Mohsen [[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] Redoing axis in a strip plot
Hello everyone, simple question--the documentation is confusing so i am forced to ask: I have a strip plot, how do create my own axis tick marks and set limits? Thanks! stripplot(jitter(clahanvs30) ~ vs30, data = completetable) Mehdi Khan [[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] Ylim
Hi, On Aug 6, 2009, at 4:48 PM, Mohsen Jafarikia wrote: Hello All: Can anybody tell me what is the problem with my program please. I have an error message as appears below. My program is: ifn - Jul08_09.LM data - read.table(ifn) ofn - Jul.png bitmap(ofn, type = png256, width = 30, height = 30, pointsize = 30, bg = white,res=50) par(mar=c(5, 5, 3, 2),lwd=5) par(cex.main=1.6,cex.lab=1.6,cex.axis=1.6) par(mfrow = c(3,4)) ifn - T.dat trait - read.table(ifn) i - 1 j - 1 for(k in 1:12) { dat - data[i:(i+2), ] colnames(dat)-c(SM,E,NP) Ymin - if( min(dat$SM) 0.0 ) (dat$SM - dat$E) else 0.0 Ymax - if( max(dat$SM) 0.0 ) (dat$SM + dat$E) else 0.0 Graph-barplot(dat$SM, names.arg=dat$NP, main = trait[j:j,], xlab = data[i:i,1:1], ylim = c(Ymin,Ymax) ) segments(Graph, dat$SM + dat$E, Graph, dat$SM - dat$E) i - i + 3 j - j + 1 } dev.off() And the error message is: Error in plot.window(xlim, ylim, log = log, ...) : invalid 'ylim' value Calls: barplot - barplot.default - plot.window Execution halted Did you take a look at what c(Ymin, Ymax) is? -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Why is 0 not an integer?
b/c class(0) [1] numeric typeof(0) [1] double class(0L) [1] integer typeof(0L) [1] integer When you call the : function it always returns an integer sequence, but when you assign a numeric to an element of the vector it gets coerced to the more general type, in this case, numeric. Note that is.numeric returns TRUE for both is.numeric(0) and is.numeric(0L). Daniel Gerlanc Associate Analyst Geode Capital Management 1 Post Office Sq, Floor 28 Boston, MA 02109 daniel.gerl...@geodecapital.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.