Re: [R] R square for Monotone regression
Dear Thierry, I do not know fdrtool::monoreg(), however I think that the simple R^2 is meaningless in thise case. An unconstrained (non-monotonic) fit will have always a higher R^2 and more degrees-of-freedom. A better approach would use any goodness-of-fit criterion penalized for the degrees of freedom of the fit itself (for instance AIC, BIC, GCV,..) Hope this helps you, vito thierrydb ha scritto: > I'm using the monoreg function (with weights) from the fdrtool package. > How can I calculate the R square for this type of regression? > > > Thanks for your help, > > > Thierry -- Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Università di Palermo viale delle Scienze, edificio 13 90128 Palermo - ITALY tel: 091 6626240 fax: 091 485726/485612 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpolation between 2 vectors
Hello, I tried the approx() and it worked. Now, I have a list named "interpol" resulting from the interpolation. I would like to append the values in interpol$y in the position specified by interpol$x in a existing vector "spect1". I tried with append() and the following code: spect1 <- c(1:10909) for(i in 1:length(interpol$x)){ append(spect1,interpol$y[i],interpol$x[i]) } but it didn't work. Any idea? Best, Dani Daniel Valverde Saubí Grup de Biologia Molecular de Llevats Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vallès- SPAIN Centro de Investigación Biomédica en Red en Bioingeniería, Biomateriales y Nanomedicina (CIBER-BBN) Grup d'Aplicacions Biomèdiques de la RMN Facultat de Biociències Universitat Autònoma de Barcelona Edifici Cs, Campus UAB 08193 Cerdanyola del Vallès- SPAIN +34 93 5814126 En/na jim holtman ha escrit: > check out the 'approx' function. > > On Feb 19, 2008 12:44 PM, Dani Valverde <[EMAIL PROTECTED]> wrote: > >> Hello, >> I have two vectors, one with 13112 points and the other one with 10909. >> I wonder if there is a way to interpolate the data so the shorter >> vectors has the same number of points as the longer one. >> Best, >> Dani >> >> -- >> Daniel Valverde Saubí >> >> Grup de Biologia Molecular de Llevats >> Facultat de Veterinària de la Universitat Autònoma de Barcelona >> Edifici V, Campus UAB >> 08193 Cerdanyola del Vallès- SPAIN >> >> Centro de Investigación Biomédica en Red >> en Bioingeniería, Biomateriales y >> Nanomedicina (CIBER-BBN) >> >> Grup d'Aplicacions Biomèdiques de la RMN >> Facultat de Biociències >> Universitat Autònoma de Barcelona >> Edifici Cs, Campus UAB >> 08193 Cerdanyola del Vallès- SPAIN >> +34 93 5814126 >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/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] Why does plot() ignore the data type for axis labels?
Hi Stiffler, Duncan Murdoch wrote: >> The point is that a scatterplot is a graph of real numbers, not of >> integers. >> Use a plot designed for a discrete data type if you don't want things >> displayed as their real values ... To drive home Duncan's point (not that it needs it) ...and to complete the loop, consider how R treats factors: > x [1] 1 2 3 > factor(x) [1] 1 2 3 Levels: 1 2 3 ## And: > factor(x, labels=c("one", "two", "three")) [1] one two three Levels: one two three > unclass(factor(x, labels=c("one", "two", "three"))) [1] 1 2 3 attr(,"levels") [1] "one" "two" "three" It does, in the end, make perfect sense. HTH, Mark. Duncan Murdoch-2 wrote: > > On 19/02/2008 5:40 PM, Stiffler wrote: >> >> >> Mark Difford wrote: > I was wondering why the plot() command ignores the datatype when > displaying axis labels... >>> plot() doesn't ignore the datatype: >>> [...] >>> plot(x,y) calls xy.coords(), which recasts x as: x = as.double(x), which >>> is fine, since x is (also/primarily) numeric. >>> >>> HTH, Mark. >>> >>> >> >> Thanks for the explanation Mark. >> >> If integers are being recast as doubles R is ignoring/overriding the >> user's >> choice of data-type. There may be good reasons for doing that internally >> (uniformity, code re-use etc) , but it is not what I'd expect as an >> end-user >> --- neither ?plot nor ?xy.coords seem to mention that coordinates need to >> be >> floating point numbers. > > They don't need to be floating point numbers, they are converted if not. > > The point is that a scatterplot is a graph of real numbers, not of > integers. Use a plot designed for a discrete data type if you don't > want things displayed as their real values (see for example barplot, > stripchart, dotchart, etc.) > > Duncan Murdoch > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://www.nabble.com/Why-does-plot%28%29-ignore-the-data-type-for-axis-labels--tp15562325p15584404.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 plot image() without painting a map (the background)
Hello, In fact I would like to make something like a "movie" : to keep the map as background and to display successively the temperatures pictures. At the moment I create the picture of the temperature with R from latitude, longitude, temperature data. I read that it can be done with image() so I used this method. So if I want to use your methods, I have to convert the picture created with image() into a jpg (or an other format) picture. Am I right ? If yes, what is the best way to perform this conversion ? Thanks for your help, Ptit Bleu. -- View this message in context: http://www.nabble.com/how-to-plot-image%28%29-without-painting-a-map-%28the-background%29-tp15546906p15584405.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] New Package 'JM' for the Joint Modelling of Longitudinal and Survival Data
Dear R-users, I'd like to announce the release of the new package JM (JM_0.1-0 available from CRAN) for the joint modelling of longitudinal and time-to-event data. The package has a single model-fitting function called jointModel(), which accepts as main arguments a linear mixed effects object fit returned by function lme() of package nlme, and a survival object fit returned by either function coxph() or function survreg() of package survival. In addition, the method argument of jointModel() specifies the type of the survival submodel to be fitted and the type of the numerical integration technique; available options are: * "ph-GH": the time-dependent version of a proportional hazards model with unspecified baseline hazard function. This option corresponds to the joint model proposed by Wulfsohn and Tsiatis, Biometrics, 1997. * "weibull-GH": the Weibull model under the accelerated failure time formulation. * "ch-GH" and "ch-Laplace": an additive log cumulative hazard model, in which the log cumulative baseline hazard is approximated using B-splines. For "ph-GH", "weibull-GH" and "ch-GH" the Gauss-Hermite integration rule is used to approximate the required integrals, whereas for "ch-Laplace" a fully exponential Laplace approximation method is applied. The last option is more suitable for high-dimensional random effects vectors, when e.g., modelling nonlinear subject-specific trajectories with splines or high-order polynomials. Sample analyses can be found at: http://student.kuleuven.be/~m0390867/R%20packages%20&%20Computing/R%20Packages/pbc.R, and http://student.kuleuven.be/~m0390867/R%20packages%20&%20Computing/R%20Packages/aids.R Any kind of feedback (questions, suggestions, bug-reports, etc.) is more than welcome. Best, Dimitris Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] overdrawing a plot
Hi helpers. I have the following problem and I need some help When using grid.edit inside a pdf device it applies the changes on a second plot, not erasing the first one. Here it is an example. >DF<-data.frame(A=c(1:12),B=c(1:12)*c(rnorm(12,mean=1)),C=2*c(1:12),D=re p(c(1:4),each=3)) >trellis.device(pdf,file='prueba.pdf') >ggplot()+geom_line(mapping=aes(x=A,y=B,colour=D),data=DF) >grid.edit(gPath('legend'),gp=gpar(fontsize=8),grep=TRUE,redraw=TRUE) >dev.off() produces a two pages pdf document, one with and one without the changes inttroduced by grid.edit If I use >DF<-data.frame(A=c(1:12),B=c(1:12)*c(rnorm(12,mean=1)),C=2*c(1:12),D=re p(c(1:4),each=3)) >trellis.device(pdf,file='prueba.pdf') >ggplot()+geom_line(mapping=aes(x=A,y=B,colour=D),data=DF)+grid.edit(gPa th('legend'),gp=gpar(fontsize=8),grep=TRUE,redraw=TRUE) it produces the error: Error en editDLfromGPath(gPath, specs, strict, grep, global, redraw) : 'gPath' (legend) not found May anybody tell me how to save just the edited plot on the pdf file? Thanks in advance [[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] clustering problem
First I just want to say thanks for all the help I've had from the list so far..) I now have what I think is a clustering problem. I have lots of objects which I have measured a dissimilarity between. Now, this list only has one entry per pair, so it is not symmetrical. Example input: NameA NameB Dist 189_1C2 189_1C1 0 189_1C3 189_1C1 0.017 189_1C3 189_1C2 0.017 189_1C4 189_1C1 0 189_1C4 189_1C2 0 189_1C4 189_1C3 0.017 189_1C5 189_1C1 0.05 189_1C5 189_1C2 0.05 189_1C5 189_1C3 0.067 189_1C5 189_1C4 0.05 189_1C6 189_1C1 0.05 189_1C6 189_1C2 0.05 189_1C6 189_1C3 0.067 189_1C6 189_1C4 0.05 189_1C6 189_1C5 0 The distance measure is 0 if identical, and then increases with increasing dissimilarity up till 1. What I would like to get from these data is a hierarchical clustering graph. In this example I would then group 189_1C2 189_1C1 189_1C4, 189_1C6 189_1C5, and 189_1C3 off with itself. The distances between the groups should be the mean distances between the objects within each group (I think). I have looked at hclust and it seems like it should be able to do what I want. However, I am unsure of how to use it to get what I am looking for. Thankyou in advance for your help! Karin -- Karin Lagesen, PhD student [EMAIL PROTECTED] http://folk.uio.no/karinlag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] insert() function
Hello, I am trying to insert a certain number of points into a certain position of a vector with this code: x <- seq(1:10909) x1 <- c(13112-10909) spect1 <- rnorm(13112) interpol <- approx(x,spect1,xout=c(seq(from=1, by=((10909 - 1)/(x1 - 1)), length.out=x1))) pos <- round(interpol$x,0) intensities <- interpol$y spect2 <- insert(spect1,ats=pos,values=intensities) "interpol" object is the result of interpoling the missing x values with respect to spect1. "pos" object is a vector with the indexes where the values are to be placed (it is the rounded values of interpol$x) and "intensities" is a vector with the values to be inserted. I try to insert the values of "intensities" into the positions specified by "pos" in the "x" vector using the insert() functions as shown in the code I paste, but I get this error: Error in list("insert(spect1, ats = pos, values = intensities)" = , : [2008-02-20 11:36:28] Exception: Argument 'ats' and argument 'values' has different lengths: 2203 != 1 at throw(Exception(...)) at throw.default("Argument 'ats' and argument 'values' has different lengths: ", length(ats), " != ", length(values)) at throw("Argument 'ats' and argument 'values' has different lengths: ", length(ats), " != ", length(values)) at insert.default(spect1, ats = pos, values = intensities) at insert(spect1, ats = pos, values = intensities) Can anyone help me on how can I solve it? I know that "pos" and "intensities" have the same length, so I don't know why I get this error. Any ideas will be welcome. Best, Dani -- Daniel Valverde Saubí Grup de Biologia Molecular de Llevats Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vallès- SPAIN Centro de Investigación Biomédica en Red en Bioingeniería, Biomateriales y Nanomedicina (CIBER-BBN) Grup d'Aplicacions Biomèdiques de la RMN Facultat de Biociències Universitat Autònoma de Barcelona Edifici Cs, Campus UAB 08193 Cerdanyola del Vallès- SPAIN +34 93 5814126 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Transfer Crosstable to Word-Document
Greg Snow-2 wrote: > > >> write.table(my.data, 'clipboard', sep="\t") > > Then in Excel just do a paste and the data is there, this saves a couple > of steps from saving as a .csv file and importing that into excel. This > would probably be fine for a few tables. > > > Just to inform: if you use write.table(my.data,'whateverfile.xls',sep="\t", quote=FALSE), you can open this file right from the windows explorer as a normal excel file. If you're already running excel and choose file>open, you will get a dialog box, where you have to click complete or OK. Bart -- View this message in context: http://www.nabble.com/Transfer-Crosstable-to-Word-Document-tp15504150p15586769.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] insert() function
Hi. On Feb 20, 2008 2:38 AM, Dani Valverde <[EMAIL PROTECTED]> wrote: > Hello, > I am trying to insert a certain number of points into a certain position > of a vector with this code: > x <- seq(1:10909) > x1 <- c(13112-10909) > spect1 <- rnorm(13112) > interpol <- approx(x,spect1,xout=c(seq(from=1, by=((10909 - 1)/(x1 - > 1)), length.out=x1))) > pos <- round(interpol$x,0) > intensities <- interpol$y Please provide reproducible code that does not give an error. > > spect2 <- insert(spect1,ats=pos,values=intensities) Is this the famous insert() in R.utils? Please give your sessionInfo() to help others see what you are using. I repeat, please provide us with sessionInfo(). > > "interpol" object is the result of interpoling the missing x values with > respect to spect1. "pos" object is a vector with the indexes where the > values are to be placed (it is the rounded values of interpol$x) and > "intensities" is a vector with the values to be inserted. I try to > insert the values of "intensities" into the positions specified by "pos" > in the "x" vector using the insert() functions as shown in the code I > paste, but I get this error: > > Error in list("insert(spect1, ats = pos, values = intensities)" = > , : > > [2008-02-20 11:36:28] Exception: Argument 'ats' and argument 'values' > has different lengths: 2203 != 1 > at throw(Exception(...)) > at throw.default("Argument 'ats' and argument 'values' has different > lengths: ", length(ats), " != ", length(values)) > at throw("Argument 'ats' and argument 'values' has different lengths: > ", length(ats), " != ", length(values)) > at insert.default(spect1, ats = pos, values = intensities) > at insert(spect1, ats = pos, values = intensities) > > Can anyone help me on how can I solve it? I know that "pos" and > "intensities" have the same length, so I don't know why I get this > error. Any ideas will be welcome. I challenge that claim, because one of the first assertions insert() (of R.utils) does is: if (length(ats) != length(values)) throw("Argument 'ats' and argument 'values' has different lengths: ", length(ats), " != ", length(values)) Do the following before you call insert() to troubleshoot your data: str(spect1) str(pos) str(intensities) /Henrik > Best, > > Dani > > -- > Daniel Valverde Saubí > > Grup de Biologia Molecular de Llevats > Facultat de Veterinària de la Universitat Autònoma de Barcelona > Edifici V, Campus UAB > 08193 Cerdanyola del Vallès- SPAIN > > Centro de Investigación Biomédica en Red > en Bioingeniería, Biomateriales y > Nanomedicina (CIBER-BBN) > > Grup d'Aplicacions Biomèdiques de la RMN > Facultat de Biociències > Universitat Autònoma de Barcelona > Edifici Cs, Campus UAB > 08193 Cerdanyola del Vallès- SPAIN > +34 93 5814126 > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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] Specaccum
Hello, I'm trying to obtain a species abundance curve with the function specaccum from vegan package. I've applied this function to my data and I've obtained something like this: Sites1.00 2.00 3.00 4.00 5.000 6.000 7.00 Richness 6.51 8.29 9.15 9.77 10.330 10.760 sd 1.381662 1.350608 1.200799 1.117853 0.9749903 0.933 0.90 But the problem is that I want to export this data to an excel file, or a txt file, but I'm not able to do it because I can not asign this values to a data.frame or a matrix or something. When I try to transform in a data frame the program tell me: Error en as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class "specaccum" into a data.frame Then, what can I do? Thank you very much. Alfonso Pérez Rodríguez Instituto de Investigaciones Marinas C/ Eduardo Cabello nº 6 C.P. 36208 Vigo (España) Tlf.- 986231930 Extensión 241 e-mail: [EMAIL PROTECTED] [[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] Problem Using the %in% command
Hello all! I have the following problem with the %in% command: 1) I have a data frame that consists of functions (rows) and genes (columns). The whole has been loaded with the "read.delim" command because of gene-duplications between the different rows. 2) Now, there is another data frame that contains all the genes (only the genes and without duplicates) from all the functions of the above data frame. What I want to do now is to use the "% in %" command to obtain a TRUE-FALSE data frame. This should be a data frame, where for every function some genes are TRUE and some are FALSE depending if they were or not in the specific function when matched against the "all genes" data frame. The main problem I have is the way how the genes are in the first data frame. I used the "unlist" command to separate them through commas ",". But every time I do the match between the first and second data frame it returns out FALSE for every gene in every function. Can anyone please give me a hind how to handle the problem? Thank you very much in advance! Paul -- Paul C. Schröder PhD-Student Division of Proteomics, Genomics & Bioinformatics Center for Applied Medicine (CIMA) University of Navarra Avda. Pio XII, 55 E-31008 Pamplona, Spain Tel: +34 948 194700, ext 5023 email: [EMAIL PROTECTED] [[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] History of R
Earl F. Glynn wrote: > Nearly six years ago, SAS also refused to give us academic pricing because > we were not a degree granting institution. About a year ago, SAS finally > granted us academic pricing, but most of the analysis momentum was already > for the use of R/Bioconductor. I recently read the small print on the academic license our site has for SAS. You have to: 1 inform SAS of any taught courses that use SAS 2 inform SAS of any research projects using SAS 3 allow SAS to refer to your institution as a SAS user 4 allow SAS to review your taught courses 5 ensure your courses are taught using qualified personnel. 6 give SAS your first-born male offspring I spoke to our site's licensing supremos and they say they've never heard of anyone complying with 1 or 2. Point 4 sounds like petty fiddling in our educational business, and point 5 left 'qualified' undefined. Point 6 doesn't bother me since I don't have kids. Luckily other parts of our institution have made deals with SAS to use it for consulting and training, so perhaps some of these points don't apply to my department. I've not seen the small print on that contract though, but I expect it to be written in blood on freshly slaughtered deerskin... Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Getting started help
Thank you very much, everybody. The scale of responses of depth of guidance is overwhelming. All this will help me to become an expert in no time! I have a while yet as I am still collecting data for my PhD project but when I start statistical data analysis, thanks to all of you, I will know what to do with one of the required softwares! I will let you know how I get on. Donatas G. wrote: > > I have been asking these same questions here on this list half a year > before. > You will probably find what you need by following this link and the > subsequent discussion: > > https://stat.ethz.ch/pipermail/r-help/2007-July/136162.html > > Donatas > > On Tuesday 19 February 2008 15:14:19 jim holtman rašė: >> I have no idea what "numbers form the RAD7 machine" look like, but >> there is a whole section on importing data in the user manual. >> 'read.table' is a start. >> >> To change directories, use 'setwd'. To start a new R session on >> Windows, just setup a shortcut to RGUI.exe. Most of this is covered >> in the documentation that comes with R. >> >> On 2/19/08, Rthoughts <[EMAIL PROTECTED]> wrote: >> > Hello, I need to learn to use r-software for my PhD research project >> > involving long timelines of radon radiation variations. >> > >> > I am using windows. >> > >> > I am currently discouraged by the use of r. I cannot figure out how to >> > use it despite extensive searches. Can anyone help me with getting >> > started? How can import a txt file with series of numbers from the RAD7 >> > machine? How can I open up and set directories with the imported file >> or >> > to start a new r session? >> > >> > Thank you so much if you can help. >> > -- >> > View this message in context: >> > http://www.nabble.com/Getting-started-help-tp15560581p15560581.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. > > > > -- > Donatas Glodenis > http://dg.lapas.info > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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/Getting-started-help-tp15560581p15588323.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] overdrawing a plot
Gallego Liberman, Matias isofoton.com> writes: > When using grid.edit inside a pdf device it applies the changes on a > second plot, not erasing the first one. .. > >DF<-data.frame(A=c(1:12),B=c(1:12)*c(rnorm(12,mean=1)),C=2*c(1:12),D=re > p(c(1:4),each=3)) > >trellis.device(pdf,file='prueba.pdf') > >ggplot()+geom_line(mapping=aes(x=A,y=B,colour=D),data=DF) > >grid.edit(gPath('legend'),gp=gpar(fontsize=8),grep=TRUE,redraw=TRUE) > >dev.off() > > produces a two pages pdf document, one with and one without the changes > inttroduced by grid.edit ... I had a similar problem, and Paul Murrell sent me a workaround: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/104038.html "You can capture the ggplot drawing as a grid grob (gTree), edit that (no drawing occurs to this point), and then draw it ..." Hadley realized that this is a bit awkward, and it could be there is a better solution in the post-christmas revision. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem Using the %in% command
With the format you have, we have to split out the genes separated by commas and then do 'table'. Here is one way of doing it: > x <- readLines(textConnection(" Function > x + Function1 gene5, gene19, gene22, gene23 + Function2 gene1, gene7, gene19 + Function3 gene2, gene3, gene7, gene23")) > closeAllConnections() > # funny data; split it up. get rid of header > x <- x[-1] > # split on blanks > x.b <- strsplit(x, "[[:blank:]]+") > # recombine into a 'long' format > x.c <- lapply(x.b, function(z) cbind(z[1], unlist(strsplit(z[-1], "," > x.c <- do.call(rbind, x.c) > table(list(x.c[,1], x.c[,2])) .2 .1 gene1 gene19 gene2 gene22 gene23 gene3 gene5 gene7 Function1 0 1 0 1 1 0 1 0 Function2 1 1 0 0 0 0 0 1 Function3 0 0 1 0 1 1 0 1 > On 2/20/08, Paul Christoph Schröder <[EMAIL PROTECTED]> wrote: > I'm sorry if I didn't wrote it the right way. I'm just starting in the world > of R and it's not that easy at the beginning. > I wrote it again with code and comments. I hope it is understandable now. Do > you think I should post it again in this shape? > > func_gen<-read.delim(file, header=T) #contains functions (rows) and genes > (colum); func_gen is a data.frame > > #It looks like this: > # Function x > # Function1 gene5, gene19, gene22, gene23 > # Function2 gene1, gene7, gene19 > # Function3 gene2, gene3, gene7, gene23 > > # Duplicates of genes exist between different functions. This is why the > "read.delim" command was used instead of the "read.table" command #because > of "duplicate 'row.names' are not allowed" error. > > all_genes #contains all genes from above data frame; all_genes is a > data.frame > #It looks like this: > # Genes > # gene1 > # gene2 > # gene3 > # gene5 > # gene7 > # gene19 > # gene 22 > # gene 23 > > func_gen[,2] %in% all_genes #this should result in a true-false matrix > # Like this: > # Functiongene1gene2gene3 gene5 gene7 gene19 gene22 > gene23 > # Function1 F F F T F > T T T > # Function2 T F F F T > T F F > # Function3 F T T F T > F F T > > #and instead I obtain a true-false matrix with only FALSE-values. > > Thanks in advance! > Paul > > > -- Paul C. Schröder PhD-Student Division of Proteomics, Genomics & > Bioinformatics Center for Applied Medicine (CIMA) University of > Navarra Avda. Pio XII, 55 E-31008 Pamplona, Spain Tel: +34 948 194700, ext > 5023 email: [EMAIL PROTECTED] > > > jim holtman escribió: > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide > commented, minimal, self-contained, reproducible code. It is hard to give a > solution if we don't have the problem statement, or an example of the data > structures you are using. On Feb 20, 2008 6:57 AM, Paul Christoph > Schröder <[EMAIL PROTECTED]> wrote: > Hello all! I have the following problem with the %in% command: 1) I have a > data frame that consists of functions (rows) and genes (columns). The whole > has been loaded with the "read.delim" command because of gene-duplications > between the different rows. 2) Now, there is another data frame that > contains all the genes (only the genes and without duplicates) from all the > functions of the above data frame. What I want to do now is to use the "% > in %" command to obtain a TRUE-FALSE data frame. This should be a data > frame, where for every function some genes are TRUE and some are FALSE > depending if they were or not in the specific function when matched against > the "all genes" data frame. The main problem I have is the way how the > genes are in the first data frame. I used the "unlist" command to separate > them through commas ",". But every time I do the match between the first and > second data frame it returns out FALSE for every gene in every > function. Can anyone please give me a hind how to handle the problem? Thank > you very much in advance! Paul -- Paul C. Schröder PhD-Student Division of > Proteomics, Genomics & Bioinformatics Center for Applied Medicine > (CIMA) University of Navarra Avda. Pio XII, 55 E-31008 Pamplona, Spain Tel: > +34 948 194700, ext 5023 email: [EMAIL PROTECTED] [[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 c
Re: [R] Specaccum
Try this data(BCI) sp1 <- specaccum(BCI) as.data.frame(sp1[3:5]) On 20/02/2008, Alfonso Pérez Rodríguez <[EMAIL PROTECTED]> wrote: > Hello, I'm trying to obtain a species abundance curve with the function > specaccum from vegan package. I've applied this function to my data and I've > obtained something like this: > > Sites1.00 2.00 3.00 4.00 5.000 6.000 7.00 > Richness 6.51 8.29 9.15 9.77 10.330 10.760 sd > 1.381662 1.350608 1.200799 1.117853 0.9749903 0.933 0.90 > > But the problem is that I want to export this data to an excel file, or a txt > file, but I'm not able to do it because I can not asign this values to a > data.frame or a matrix or something. When I try to transform in a data frame > the program tell me: > > Error en as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = > stringsAsFactors) : > cannot coerce class "specaccum" into a data.frame > > Then, what can I do? Thank you very much. > > > > > > Alfonso Pérez Rodríguez > Instituto de Investigaciones Marinas > C/ Eduardo Cabello nº 6 > C.P. 36208 Vigo (España) > Tlf.- 986231930 Extensión 241 > e-mail: [EMAIL PROTECTED] > [[alternative HTML version deleted]] > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Specaccum
You need to read the help for specaccum to see what it returns. If you want the site and richness components, as in the example you give, you could do: my.sa <- specaccum(my.data) write.table(cbind(my.sa$sites, my.sa$richness), "myoutput.csv") Sarah On Feb 20, 2008 7:24 AM, Alfonso Pérez Rodríguez <[EMAIL PROTECTED]> wrote: > Hello, I'm trying to obtain a species abundance curve with the function > specaccum from vegan package. I've applied this function to my data and I've > obtained something like this: > > Sites1.00 2.00 3.00 4.00 5.000 6.000 7.00 > Richness 6.51 8.29 9.15 9.77 10.330 10.760 sd > 1.381662 1.350608 1.200799 1.117853 0.9749903 0.933 0.90 > > But the problem is that I want to export this data to an excel file, or a txt > file, but I'm not able to do it because I can not asign this values to a > data.frame or a matrix or something. When I try to transform in a data frame > the program tell me: > > Error en as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = > stringsAsFactors) : > cannot coerce class "specaccum" into a data.frame > > Then, what can I do? Thank you very much. > > -- 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] Specaccum
On Wed, 2008-02-20 at 13:24 +0100, Alfonso Pérez Rodríguez wrote: > Hello, I'm trying to obtain a species abundance curve with the > function specaccum from vegan package. I've applied this function to > my data and I've obtained something like this: > > Sites1.00 2.00 3.00 4.00 5.000 6.000 > 7.00 Richness 6.51 8.29 9.15 9.77 10.330 > 10.760 sd 1.381662 1.350608 1.200799 1.117853 0.9749903 > 0.933 0.90 That is just the _printed_ representation of the resulting object. In R, don't believe your eyes - what is printed is not always an accurate reflection of the complete object! > > But the problem is that I want to export this data to an excel file, > or a txt file, but I'm not able to do it because I can not asign this > values to a data.frame or a matrix or something. When I try to > transform in a data frame the program tell me: > > Error en as.data.frame.default(x[[i]], optional = TRUE, > stringsAsFactors = stringsAsFactors) : > cannot coerce class "specaccum" into a data.frame > > Then, what can I do? Thank you very much. I'll start with a reproducible example, from ?specaccum require("vegan") data(BCI) sp1 <- specaccum(BCI) str(sp1) The latter call yields: List of 6 $ call: language specaccum(comm = BCI) $ method : chr "exact" $ sites : int [1:50] 1 2 3 4 5 6 7 8 9 10 ... $ richness: num [1:50] 90.8 121.6 139.0 150.7 159.2 ... $ sd : num [1:50] 6.93 7.19 7.00 6.64 6.25 ... $ perm: NULL - attr(*, "class")= chr "specaccum" Note the class - "specaccum" - and R has no idea how to convert this to a data frame or matrix - there is no as.data.frame.specaccum() and this is because how do you combine 3 vectors of length 50 into a data frame with other information that is of a different type and length? You can't. So, now your problem boils down to extracting the relevant information from sp1 and writing that out as a data frame. This is very easy. Given your email I presume you are interested in the 'sites', 'richness' and 'sd' components: my.res <- with(sp1, data.frame(sites, richness, sd)) head(my.res) The latter call yielding the first 6 lines of my.res (there are 50 in total): sites richness sd 1 1 90.7800 6.934811 2 2 121.6098 7.193362 3 3 139.0459 7.001993 4 4 150.7116 6.635769 5 5 159.2363 6.248117 6 6 165.8306 5.894738 Now just write out my.res using write.table() write.table(my.res, file = "my.results.txt") Which works for me. Is that what you wanted? HTH G > > > > > Alfonso Prez Rodrguez > Instituto de Investigaciones Marinas > C/ Eduardo Cabello n 6 > C.P. 36208 Vigo (Espaa) > Tlf.- 986231930 Extensin 241 > e-mail: [EMAIL PROTECTED] > [[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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 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] Confidence Interval for SMR
> Hello, > > I am looking for a function which allows to calculate the confidence > interval for a standard mortality ratio. I do have vectors with the > number of observed and expected death. Has anybody a hint where to > look? > Best, > Stefan We find the following function useful for an SMR cipoisson(observed, expected) Terry Therneau Mayo Clinic "cipoisson" <- function(k, time = 1, p = 0.95, method = c("exact", "anscombe") ) { nn <- max(length(k), length(time), length(p)) if(nn > 1) { k <- rep(k, length = nn) time <- rep(time, length = nn) p <- rep(p, length = nn) } p <- (1 - p)/2 #two sided method <- match.arg(method) if(method == "exact") { dummy1 <- ifelse(k == 0, 1, k) #avoid an error message of qgamma lower <- ifelse(k == 0, 0, qgamma(p, dummy1)) upper <- qgamma(1 - p, k + 1) } else if(method == "anscombe") { # anscombe's method upper <- (sqrt(k + 7/8) - qnorm(p)/2)^2 lower <- (sqrt(k - 1/8) + qnorm(p)/2)^2 } else stop("Invalid method") if(nn == 1) c(lower = lower, upper = upper)/time else cbind(lower = lower, upper = upper)/time } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Compare mean survival time
Xing Yuan wrote: > Dear List, > > Does anybody no how to compare mean survival times for two (more) groups in > R? What test statistics should I use? You should be careful considering the mean survival time, because censoring in survival data often makes the mean less informative. The median survival time is what is generally recommended for testing (i.e. in survdiff) and the statistical test of the median survival times following the methods in Harrington and Fleming (1982) Biometrika v.69 pp553-566. Corey Corey S. Sparks, Ph.D. Assistant Professor Department of Demography and Organization Studies University of Texas San Antonio One UTSA Circle San Antonio, TX 78249 email:[EMAIL PROTECTED] [[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] Compare mean survival time
Xing Yuan wrote: > Dear List, > > Does anybody no how to compare mean survival times for two (more) groups in > R? What test statistics should I use? Because of censoring, you can only compare the conditional means. That is, given a pre-defined cutpoint such as "2 years", you estimate the expected amount of the next 2 years that a person in each group will experience. For stability you need to have the cutpoint be smaller than the larger censoring times. (If no one has more than 2 years of fu, setting the cutpoint to 5 years is silly). The current survfit routine calculates the conditional mean and se() thereof for each curve. Unfortunately, it chooses the cutpoint per curve, as the largest time value in that curve. To make the numbers from two curves comparable, they need to have a common cutpoint. And, as Thomas L has pointed out to me, the cutpoint value should not be a value derived from the data, since the se calculation is under the assumption of a fixed cutpoint. This is easily done by preprocessing the data. (The cutpoint must be small enough so that every curve is "cut off" somewhat for this to work). newtime <- pmin(time, cutpoint) newstat <- ifelse(time<=cutpoint, status, 0) fit <- survfit(Surv(newtime, newstat) ~ group) print(fit, show.rmean=T) (This will be easier in the future, by giving a cutpoint to the print function). Since the curves are independent, the variance of the difference in means is the sum of the variances. Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] p-value for fixed effect in generalized linear mixed model
Dear R-users, I am currently trying to switch from SAS to R, and am not very familiar with R yet, so forgive me if this question is irrelevant. If I try to find the significance of the fixed factor "spikes" in a generalized linear mixed model, with "site" nested within "zone" as a random factor, I compare following two models with the anova function: model1<-lmer(aphids~spikes+(1|zone:site), method="ML", family=quasipoisson) model2<-lmer(aphids~(1|zone:site), method="ML", family=quasipoisson) anova(model1,model2) This gives me a p< 2.2e-16 ***, concluding that "spikes" has a highly significant effect on "aphids". However, when I look at the summary of model1: summary(model1) I find a t-value for "spikes" of -0.1166 which is really insignificant... When I try model1 in SAS with proc glimmix, corrected for overdispersion with "random _residual_", it also gives a p-value for "spikes" of 0,985. So if "spikes" is not having a significant effect on "aphids", then why the above mentionned p-value generated by anova in R? Can anyone explain this? Please find the dataset in the attachment. Many thanks beforehand, Martijn. -- Martijn Vandegehuchte Ghent University Department Biology Terrestrial Ecology Unit K.L.Ledeganckstraat 35 B-9000 Ghent telephone: +32 (0)9/264 50 84 e-mail: [EMAIL PROTECTED] website TEREC: www.ecology.ugent.be/terec sitezoneheight spikes diametertotmas densroot vitalityaphids C inland 74 0 43 118.9 2.2 0.730025231 0 C inland 78 26 55 143.1 1.7 0.621942697 2 C inland 117 15 118 423.4 2.8 0.763705104 0 C inland 96 0 21 291.9 10.30.87529976 1 C inland 91 4 85 175.3 3.9 0.8141542 0 C inland 101 8 65 254.5 1.7 0.761886051 1 C inland 85 160 300 89.41.5 0.488188976 0 C inland 77 0 12 56.92.3 0.876977153 8 C inland 59 0 13 23.30.4 0.991416309 23 C inland 146 44 213 216.5 2 0.348127601 0 C inland 44 0 29 79.94.9 0.819230769 0 C inland 113 12 250 321 0.6 0.48128509 0 C inland 64 0 35 104 1.5 0.350100604 0 C inland 64 0 41 21.71.9 0.783410138 2 C inland 105 12 270 74.31.1 0.951547779 3 C inland 105 12 270 374.7 1 0.742727515 1 C inland 86 0 65 155.9 4.9 0.885923949 17 C inland 81 0 250 97.30.4 0.324029126 0 C inland 83 64 379 98.61 0.90872211 1 C inland 116 18 250 259.5 1.
Re: [R] Transfer Crosstable to Word-Document
I don't use Word much but an xtable (html) seems to import with no trouble. Thanks for reminding me that it works well with OOo. --- Peter Dalgaard <[EMAIL PROTECTED]> wrote: > Gabor Grothendieck wrote: > > On Feb 16, 2008 5:28 PM, David Scott > <[EMAIL PROTECTED]> wrote: > > > >> On Sat, 16 Feb 2008, Alan Zaslavsky wrote: > >> > >> > >>> If you want to get nicely formatted tables in > Word and are familiar with > >>> Office tools (I know it's the Evil Empire but > some of us work there), I > >>> suggest that you use Excel for formatting and > then insert the table into > >>> your Word document. IMHO, Excel is much > superior to Word for table > >>> formatting, e.g. modifying number of significant > digits, playing around > >>> with fonts and number formats, etc. And when > you have gotten the formats > >>> right you can paste in modified values of the > numbers in the table without > >>> having to do the formatting again. Including > the table in your Word > >>> document is easy by cut-paste or creating a live > link. > >>> > >>> As a user of R under Unix I haven't looked into > the facilities for writing > >>> tables to Excel under Windows but there is > something there. Alternatively > >>> you can write a fixed-column or tab-delimited > file and easily import to > >>> Excel. > >>> > >>> > >> Production of tables and formatting them in Word > is something I have dealt > >> with a couple of times recently and it really is > important to do something > >> smart because of the time taken to individually > format tables. > >> > >> An approach I used recently was to produce a text > table in R and export it > >> to Excel as a .csv file which could then be > copied as is to Word. Borders > >> and the like would still have to be formatted > individually but not entries > >> > > > > You could get a border automatically by writing > your table out > > as HTML. Try this using the builtin data frame > iris: > > > > library(R2HTML) > > HTML(iris, border = 1, file("clipboard","w"), > append=FALSE) > > > > Now paste that into Excel and from Excel into Word > and you should > > have a border around it. > > > > See ?HTML.data.frame > > > > You could alternately generate the HTML yourself > giving quite a bit > > of control. > > > Just curious (I don't use Word if I can help it -- > even the simplest of > things drive me up the wall), but can you not import > HTML directly in > Word? OpenOffice seems to do it quite happily with > xtable output. > > -- >O__ Peter Dalgaard Øster > Farimagsgade 5, Entr.B > c/ /'_ --- Dept. of Biostatistics PO Box 2099, > 1014 Cph. K > (*) \(*) -- University of Copenhagen Denmark > Ph: (+45) 35327918 > ~~ - ([EMAIL PROTECTED]) > FAX: (+45) 35327907 > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] p-value for fixed effect in generalized linear mixed model
The lme4 package is still in development. I can't guarantee the evaluation of the deviance for the quasipoisson family. There is a certain amount of mystery about the role of the dispersion parameter and the null deviance in families like quasipoisson and quasibinomial. For the time being don't base tests on a value of the deviance for such models. On Feb 20, 2008 8:19 AM, Martijn Vandegehuchte <[EMAIL PROTECTED]> wrote: > Dear R-users, > > I am currently trying to switch from SAS to R, and am not very familiar with > R yet, so forgive me if this question is irrelevant. > > If I try to find the significance of the fixed factor "spikes" in a > generalized linear mixed model, with "site" nested within "zone" as a random > factor, I compare following two models with the anova function: > > model1<-lmer(aphids~spikes+(1|zone:site), method="ML", family=quasipoisson) > model2<-lmer(aphids~(1|zone:site), method="ML", family=quasipoisson) > anova(model1,model2) > > This gives me a p< 2.2e-16 ***, concluding that "spikes" has a highly > significant effect on "aphids". However, when I look at the summary of model1: > > summary(model1) > > I find a t-value for "spikes" of -0.1166 which is really insignificant... > > When I try model1 in SAS with proc glimmix, corrected for overdispersion with > "random _residual_", it also gives a p-value for "spikes" of 0,985. So if > "spikes" is not having a significant effect on "aphids", then why the above > mentionned p-value generated by anova in R? > > Can anyone explain this? > > Please find the dataset in the attachment. > > Many thanks beforehand, > > Martijn. > > > > > > > > > > -- > Martijn Vandegehuchte > Ghent University > Department Biology > Terrestrial Ecology Unit > K.L.Ledeganckstraat 35 > B-9000 Ghent > telephone: +32 (0)9/264 50 84 > e-mail: [EMAIL PROTECTED] > > website TEREC: www.ecology.ugent.be/terec > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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 with circular-linear regression in package circular
I am looking for assistance in figuring out how to use the circular-linear regression in package circular. See below for an example of what I have been trying. If anyone can help me with this please reply to my email address. Thank you, This is what I have been doing: with a linear variable x; lets use >x=c(1:10) and a circular variable y; for example >y=circular(c(123,239,265,342,198,253,343,237,162,247),units='degrees') trying to do the regression; >lm.circular(y,x, type='c-l') I get the error, >Error in lm.circular.cl(...) : 'init' is missing with no default But I tried to create a vector, init with the same columns as x (as the description of c-l regression says and I still get an error) >Error in lm.circular.cl(...) : 'init' must have the same number of elements as >the columns of 'x' Any assistance is appreciated. Kristen Covino Graduate Student and Teaching Assistant School of Biology and Ecology University of Maine at Orono 5751 Murray Hall Office: 217 Phone: 207-581-2547 Email: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Stress with MDS
Hi, I am looking for the best multidimensional configuration for my data (47*47 distance matrix). I ve tried classical metric (cmdscale) and non metric MDS (isoMDS, nmds) but it is now difficult to choose the best solution because of the uncertainties in the definitions of the "stress" function. So, same problem, several questions : 1. Statistical consideration : With "cmdscale" we get eigen values. What is the best way to choose optimal dimensionality? With the eigen values and corresponding GOF like we do with PCA ? If I compute stress1, does it make any sense (I saw it in some publications)? 2. With isoMDS and nmds we get the final stress but i can't find the source code so i don't know what is in the box. Obviously, I got different values from isoMDS and nmds . I started from the same initial configuration (cmdscale) and the same parameters (maxit,tol)to compare results. I tried to compute stress1 by myself and find values closed to nmds with ndms config, but far away from isoMDS with isoMDS config (plus a strange increasing value between k=4 and k=5). Could you help me please? I lost myself... k isoMDS$stress stress1(isoMDS) nmds$stress stress1(nmds) 2 0,18830413 0.2912164 0.2758062 0.2658789 3 0,11521339 0.1866746 0.1754007 0.1727632 4 0,08733106 0.1638274 0.1281730 0.1271329 5 0,06942862 0.1991569 0.09756043 0.0970992 6 0,05751437 0.1563326 0.07846889 0.07822841 Here is my stress1 function stress1<-function(datadist,fitteddist) {sqrt(sum((datadist-fitteddist)^2)/sum(datadist^2))} Best regards __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rd to latex
Hello, I would like to convert an Rd object to a latex file, so that I can put it in my thesis. How can I do it? I tryed latex(), but it only works for code... Best, Dani -- Daniel Valverde Saubí Grup de Biologia Molecular de Llevats Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vallès- SPAIN Centro de Investigación Biomédica en Red en Bioingeniería, Biomateriales y Nanomedicina (CIBER-BBN) Grup d'Aplicacions Biomèdiques de la RMN Facultat de Biociències Universitat Autònoma de Barcelona Edifici Cs, Campus UAB 08193 Cerdanyola del Vallès- SPAIN +34 93 5814126 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rd to latex
See R CMD Rdconv --help (at the command line). [This is in Appendix B of 'An Introduction to R'] On Wed, 20 Feb 2008, Dani Valverde wrote: Hello, I would like to convert an Rd object to a latex file, so that I can put it in my thesis. How can I do it? I tryed latex(), but it only works for code... Best, Dani -- Daniel Valverde Saubí Grup de Biologia Molecular de Llevats Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vallès- SPAIN Centro de Investigación Biomédica en Red en Bioingeniería, Biomateriales y Nanomedicina (CIBER-BBN) Grup d'Aplicacions Biomèdiques de la RMN Facultat de Biociències Universitat Autònoma de Barcelona Edifici Cs, Campus UAB 08193 Cerdanyola del Vallès- SPAIN +34 93 5814126 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stress with MDS
I presume this is isoMDS which is part of package MASS, support software for a book. The definitions of 'stress' are in that book, and the source code is part of the package. It makes no sense to use a metric definition of stress with a non-metric method of fitting: the original and fitted distances are not even on the same scale. As for 'nmds', you haven't told us where you found it: please remember to supply the 'at a minimum' infomation the posting guide asked for. (There are at least two packages supplying a function of that name.) It is standard academic practice (and basic courtesy) to acknowledge the authorship of software you use -- that includes isoMDS. You need to do some background reading to answer your questions: the references in the help for isoMDS would be a good start. On Wed, 20 Feb 2008, Montignies Francois wrote: > Hi, > > I am looking for the best multidimensional configuration for my data (47*47 > distance matrix). > I ve tried classical metric (cmdscale) and non metric MDS (isoMDS, nmds) > but it is now difficult to choose the best solution because of the > uncertainties in the definitions of the "stress" function. > > So, same problem, several questions : > > 1. Statistical consideration : With "cmdscale" we get eigen values. What is > the best way to choose optimal dimensionality? With the eigen values and > corresponding GOF like we do with PCA ? If I compute stress1, does it make > any sense (I saw it in some publications)? > > 2. With isoMDS and nmds we get the final stress but i can't find the source > code so i don't know what is in the box. Obviously, I got different values > from isoMDS and nmds . I started from the same initial configuration > (cmdscale) and the same parameters (maxit,tol)to compare results. > I tried to compute stress1 by myself and find values closed to nmds with > ndms config, but far away from isoMDS with isoMDS config (plus a strange > increasing value between k=4 and k=5). Could you help me please? I lost > myself... > > k isoMDS$stress stress1(isoMDS) nmds$stress stress1(nmds) > 2 0,18830413 0.2912164 0.2758062 0.2658789 > 3 0,11521339 0.1866746 0.1754007 0.1727632 > 4 0,08733106 0.1638274 0.1281730 0.1271329 > 5 0,06942862 0.1991569 0.09756043 0.0970992 > 6 0,05751437 0.1563326 0.07846889 0.07822841 > > Here is my stress1 function > > stress1<-function(datadist,fitteddist) > {sqrt(sum((datadist-fitteddist)^2)/sum(datadist^2))} > > Best regards > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rd to latex
maybe the xtable package? On Wednesday 20 February 2008 05:42:27 pm Dani Valverde wrote: DV> Hello, DV> I would like to convert an Rd object to a latex file, so that I can put DV> it in my thesis. How can I do it? I tryed latex(), but it only works for DV> code... DV> Best, DV> DV> Dani DV> __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rd to latex
Hello, I've tried with R CMD Rdeconv and it works, but, when I want to paste it into my main latex file, there are lots of undefined environments. I loaded the package Rd.sty in the latex document preface, but it does not seem to work. Any idea? Best, Dani Daniel Valverde Saubí Grup de Biologia Molecular de Llevats Facultat de Veterinària de la Universitat Autònoma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vallès- SPAIN Centro de Investigación Biomédica en Red en Bioingeniería, Biomateriales y Nanomedicina (CIBER-BBN) Grup d'Aplicacions Biomèdiques de la RMN Facultat de Biociències Universitat Autònoma de Barcelona Edifici Cs, Campus UAB 08193 Cerdanyola del Vallès- SPAIN +34 93 5814126 En/na Stefan Grosse ha escrit: > maybe the xtable package? > > > On Wednesday 20 February 2008 05:42:27 pm Dani Valverde wrote: > DV> Hello, > DV> I would like to convert an Rd object to a latex file, so that I can put > DV> it in my thesis. How can I do it? I tryed latex(), but it only works for > DV> code... > DV> Best, > DV> > DV> Dani > DV> > > > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] a questtion about Cronbach's alpha more than 1
Dear All, I am a novice in R and am working on my thesis for master's in Epidemiology & Biostatistics. While calculating Cronbach's alpha for the SF-36 questionnaire, I got all 8 of them more than 1. Is it possible to get alpha more than 1. If yes, please help me understand it. I read about the negative alpha value on your web postings. It does not answer my question though. Thank you. Sincerely, Dr. Smita Pakhale, MD McGill University, Canada Never miss a thing. Make Yahoo your home page. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rd to latex
On 2/20/2008 11:42 AM, Dani Valverde wrote: > Hello, > I would like to convert an Rd object to a latex file, so that I can put > it in my thesis. How can I do it? I tryed latex(), but it only works for > code... > Best, See ?Rdconv and its references. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] reshaping data frame
Dear all, I'm having a few problems trying to reshape a data frame. I tried with reshape{stats} and melt{reshape} but I was missing something. Any help is very welcome. Please find details below: # # data in its original shape: indiv <- rep(c("A","B"),c(10,10)) level.1 <- rpois(20, lambda=3) covar.1 <- rlnorm(20, 3, 1) level.2 <- rpois(20, lambda=3) covar.2 <- rlnorm(20, 3, 1) my.dat <- data.frame(indiv,level.1,covar.1,level.2,covar.2) # the values of level.1 and level.2 represent the number of cases for the particular # combination of indiv*level*covar value # I would like to do two things: # 1. reshape to long reducing my.dat[,2:5] into two colums "factor" (levels= level.1 & level.2) # and the covariate # 2. create one new row for each case in level.1 and level.2 # the new reshaped data.frame would should look like this: # indiv factorcovar case.id # A level.1 4.6141051 # A level.1 4.6141052 # A level.2 31.0644051 # A level.2 31.0644052 # A level.2 31.0644053 # A level.2 31.0644054 # A level.1 19.1857841 # A level.2 48.4559291 # A level.2 48.4559292 # A level.2 48.4559293 # etc... # Thank you very much!! Ahimsa -- ahimsa campos-arceiz www.camposarceiz.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Data frame with 0 rows.
Rolf Turner wrote: > For reasons best known only to myself ( :-) ) I wish to create a data > frame with 0 rows and 9 columns. > > The best I've been able to come up with is: > > junk <- as.data.frame(matrix(0,nrow=0,ncol=9)) > > Is there a sexier way? I'm unsure of their virtue or seediness, but here are some alternatives: > data.frame(a=numeric(0), b=numeric(0)) # include 9 arguments if you like [1] a b <0 rows> (or 0-length row.names) > as.data.frame(rep(list(a=numeric(0)), 9)) [1] a a.1 a.2 a.3 a.4 a.5 a.6 a.7 a.8 <0 rows> (or 0-length row.names) > -- Tony Plate > > cheers, > > Rolf > > ## > Attention:\ This e-mail message is privileged and confid...{{dropped:9}} > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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] reshaping data frame
On 2/20/2008 1:14 PM, ahimsa campos-arceiz wrote: > Dear all, > > I'm having a few problems trying to reshape a data frame. I tried with > reshape{stats} and melt{reshape} but I was missing something. Any help is > very welcome. Please find details below: > > # > # data in its original shape: > > indiv <- rep(c("A","B"),c(10,10)) > level.1 <- rpois(20, lambda=3) > covar.1 <- rlnorm(20, 3, 1) > level.2 <- rpois(20, lambda=3) > covar.2 <- rlnorm(20, 3, 1) > my.dat <- data.frame(indiv,level.1,covar.1,level.2,covar.2) > > # the values of level.1 and level.2 represent the number of cases for the > particular > # combination of indiv*level*covar value > > # I would like to do two things: > # 1. reshape to long reducing my.dat[,2:5] into two colums "factor" (levels= > level.1 & level.2) > # and the covariate > # 2. create one new row for each case in level.1 and level.2 > > # the new reshaped data.frame would should look like this: > > # indiv factorcovar case.id > # A level.1 4.6141051 > # A level.1 4.6141052 > # A level.2 31.0644051 > # A level.2 31.0644052 > # A level.2 31.0644053 > # A level.2 31.0644054 > # A level.1 19.1857841 > # A level.2 48.4559291 > # A level.2 48.4559292 > # A level.2 48.4559293 > # etc... > > # Maybe there is a better way, but this seems to do what you want: # # data in its original shape: indiv <- rep(c("A","B"),c(10,10)) level.1 <- rpois(20, lambda=3) covar.1 <- rlnorm(20, 3, 1) level.2 <- rpois(20, lambda=3) covar.2 <- rlnorm(20, 3, 1) my.dat <- data.frame(indiv,level.1,covar.1,level.2,covar.2) long <- reshape(my.dat, varying = list(c("level.1","level.2"), c("covar.1","covar.2")), timevar="level", idvar="case.id", v.names=c("ncases","covar"), direction="long") newdf <- with(long, data.frame(indiv = rep( indiv, ncases), level = rep( level, ncases), covar = rep( covar, ncases), case.id = rep(case.id, ncases))) The idea is to first reshape() and then rep() each variable ncases times. You can then convert newdf$level into a factor if you like. > Thank you very much!! > > Ahimsa -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Data frame with 0 rows. (Thanks.)
Thanks to Bill Venables, Gabor Grothendieck, and Tony Plate all of whom gave me useful advice in answer to my question: >> For reasons best known only to myself ( :-) ) I wish to create a data >> frame with 0 rows and 9 columns. >> The best I've been able to come up with is: >> junk <- as.data.frame(matrix(0,nrow=0,ncol=9)) >> Is there a sexier way? My personal preference among the suggested solutions was Tony Plate's: > > as.data.frame(rep(list(a=numeric(0)), 9)) > [1] a a.1 a.2 a.3 a.4 a.5 a.6 a.7 a.8 > <0 rows> (or 0-length row.names) Thanks again to all. cheers, Rolf Turner P. S. It is interesting to observe that if you rbind() such a zero row data frame onto another one (with the same column names of course) then the type/ mode of the columns in the result is determined by the second (``non-empty'') data frame. It appears that if you rbind two non-empty data frames, the type/mode of the columns of the result is determined by coercion to a sort of minimal type --- at least rbind()-ing numeric to factor yields character. I haven't experimented thoroughly (nor delved into the source) but it would seem that the designers have very cleverly made the result of rbinding as sensible as it is possible to be, given the silly behaviour of the user! R. T. ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] recursive function help SOLVED (sort of)
Well, it turns out to be very simple - just insert a Vectorize between integrate and function(x). However, the special cases where C[i,j]==1 make the actual code quite messy. It matches pmvnorm {mvtnorm} and pmnorm {mnormt} quite well. And the recursive method is incredibly slow for higher dimensions. And still some cases blow up or don't converge. So, never mind. It looked clever, but I would recommend pmvnorm for speed and accuracy, even though it is non-deterministic for higher dimensions. One little note: for the bivariate, this method (without recursion) is as accurate as the existing methods and a bit faster than pmvnorm. -- David -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, February 19, 2008 3:08 PM To: r-help@r-project.org Subject: [R] recursive function help I'm trying to implement a recursive function using integrate, and I suspect I need a Vectorize somewhere, but I can't suss it out. Any help would be appreciated. I've tried traceback() and various debugging ideas to no avail (most likely due to my inexperience with these tools.) Here's what I have. Nk <- function(m, C) { if (length(m) > 1) { rho <- C[1, -1] Rmat <- C[-1, -1] B <- diag(1/sqrt(1 - rho*rho)) %*% (-rho %*% t(rho) + Rmat) %*% diag(1/sqrt(1 - rho*rho)) integrate( function(x) dnorm(x) * Nk((m[-1] - rho*x)/sqrt(1 - rho*rho), B), -10, m[1] )$value } else { pnorm(m[1]) } } my example is > x2 <- c(0.0781292, -1.6403152) > sigma2 <- matrix(c(1, -0.5054781, -0.5054781, 1), nrow=2) > Nk(x2, sigma2) Error in integrate(function(x) dnorm(x) * Nk((m[-1] - rho * x)/sqrt(1 - : non-finite function value All the pieces work outside of the function, and the integrand is finite as far as I can see. [Yes, this is a recursive function for multivariate cumulative normal. It seems to match (so far for k=2 without recursion) the existing R functions from packages mvtnorm and mnormt. It is from D. Cassimon, et al. Closed-form valuation of American call options on stocks paying multiple dividends. Finance Research Letters 4 (2007) 33-48.] Thank you to anyone who can shed some light on this. David L. Reiner, PhD Rho Trading Securities, LLC __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 questtion about Cronbach's alpha more than 1
On 20-Feb-08 17:34:33, Smita Pakhale wrote: > Dear All, > I am a novice in R and am working on my thesis for > master's in Epidemiology & Biostatistics. While > calculating Cronbach's alpha for the SF-36 > questionnaire, I got all 8 of them more than 1. Is it > possible to get alpha more than 1. If yes, please help > me understand it. I read about the negative alpha > value on your web postings. It does not answer my > question though. > Thank you. > Sincerely, > Dr. Smita Pakhale, MD > McGill University, Canada You should not get alpha > 1 if you calculate it by the standard definition. You can of course get negative values which are arbitrarily large. I wonder, therefore, whether a) You have calculated it by an incorrect method or a non-standard definition or b) You have somehow been presented with negative alpha < 1 as positive values > 1. Can you provide more detail about how you obtained the values you are writng about? Best wishes, Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 20-Feb-08 Time: 19:55:00 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] igraph package, version 0.5
igraph is a package for graphs and networks. It has a C core and uses a simple and fast graph representation allowing millions of vertices and edges. NEW FEATURES: - We use the ARPACK library for graph related eigenvalue problems, like Page Rank calculation, Kleinberg's hub and authority scores, eigenvector centrality, etc. There is also a generic interface if someone wants to use ARPACK for a different (not necessarily graph-related) problem. - We support the BLISS graph isomorphism algorithm, and the implementation of the VF2 algorithm can calculate subgraph isomorphisms now. - We include a collection of "famous" graphs, these can be created by referring to their name. - We have a new 'graph.formula' function, for creating small graphs using symbolic names, by giving simple R formulae. - Many functions support weighted graphs now: Page Rank, modularity calculation, the fast greedy community finding algorithm, etc. - We have a new graph layout algorithm called 'graphopt'. - A bunch of new functions are added: biconnected components and articulation points, dyad and triad census, functions for vertex similarity, functions for estimating closeness, betweenness and edge betweenness, etc. - igraph can write files in the DOT format now. - Some graphics improvements, e.g. it is possible to draw graphs on top of each other, etc. - Many bugs were fixed, the most important one is probably that now memory is always properly deallocated when CTRL+C (ESC) is used to interrupt a computation. PACKAGE DESCRIPTION: igraph is originally a C library for graphs, but has interfaces to high level languages like R, Python and Ruby. The R package contains BOTH the C library and its R interface. igraph supports: - graph generators, creating both regular structures like trees, lattices, etc. and various random graphs. - a rich set of functions calculating structural properties of graphs, like vertex centrality (degree, betweenness, closeness, page rank, eigenvector centrality, Burt's constraints, etc.), shortest paths, dyad and triad census, network motifs, girth, K-core decomposition, etc. - attributes can be associated with the vertices/edges of the graph, or the graph itself. The attributes can be arbitrary R objects. - graph visualization using regular R devices, interactive visualization using Tcl/Tk, 3D visualization using RGL. - graph layout generators, the standard Kamada-Kawai and Fruchterman-Reingold algorithms are included, plus many more. - Functions for graph and subgraph isomorphism, the BLISS and the VF2 algorithms are included. - Functions for maximal network flows, minimal cuts, vertex and edge connectivity. - igraph can read and write many popular file formats used for storing graph data: GraphML, Pajek, GML and others. - igraph contains implementations of many community structure detection algorithms proposed recently. See more at the igraph homepage: http://cneurocvs.rmki.kfki.hu/igraph/index.html -- Csardi Gabor <[EMAIL PROTECTED]> ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Summing over an index of an array
Try apply(A,2:3,sum) --- Saurav Pathak <[EMAIL PROTECTED]> wrote: > Hi, > > I cannot seem to figure out how to sum over an index > of a array. > For example, let A be a 3 dimensional array. I want > to, say, find > the sum over the first dimension. That is > > S_jk = Sum_i A_ijk > > where now S is a 2-dim matrix. I dont want to use a > loop. > > Thanks, > -- > saurav > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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] [OT] Linux/UNIX question
Dear R Gurus: I'm trying to find R on another Linux system. I'm using the find command, (surprise), but I only want to see the output where it exists, not all of the other stuff. Is there an option that I could select, please? Right now I have find / -name R TIA, Sincerely, Edna __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Compilation error on installing rgl package
Hi all, I encountered difficulties when I tried to install the rgl package. I'm using R devel (2.7.0) on Mac OS X 10.5.1. Below is the message popping up when compiling the package from source. I'd be grateful if someone can help me solve the problem. Thanks, Kenneth * Installing *source* package 'rgl' ... checking for gcc... gcc -arch x86_64 -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 gcc -arch x86_64 -std=gnu99 accepts -g... yes checking for gcc -arch x86_64 -std=gnu99 option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -arch x86_64 -std=gnu99 -E checking for gcc... (cached) gcc -arch x86_64 -std=gnu99 checking whether we are using the GNU C compiler... (cached) yes checking whether gcc -arch x86_64 -std=gnu99 accepts -g... (cached) yes checking for gcc -arch x86_64 -std=gnu99 option to accept ANSI C... (cached) none needed checking for libpng-config... yes configure: using libpng-config configure: using libpng dynamic linkage checking for X... libraries /usr/X11/lib, headers /usr/X11/include checking for glEnd in -lGL... yes checking for gluProject in -lGLU... yes configure: creating ./config.status config.status: creating src/Makevars ** libs g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include -I/System/Library/Frameworks/OpenGL.framework/Headers -DHAVE_PNG_H -I/usr/local/include/libpng12 -I/usr/X11/include -DDarwin -DNO_GL_PREFIX -I/usr/X11R6/include -Iext -I/usr/local/include -g -O2 -fPIC -g -O2 -c BBoxDeco.cpp -o BBoxDeco.o g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include -I/System/Library/Frameworks/OpenGL.framework/Headers -DHAVE_PNG_H -I/usr/local/include/libpng12 -I/usr/X11/include -DDarwin -DNO_GL_PREFIX -I/usr/X11R6/include -Iext -I/usr/local/include -g -O2 -fPIC -g -O2 -c Background.cpp -o Background.o g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include -I/System/Library/Frameworks/OpenGL.framework/Headers -DHAVE_PNG_H -I/usr/local/include/libpng12 -I/usr/X11/include -DDarwin -DNO_GL_PREFIX -I/usr/X11R6/include -Iext -I/usr/local/include -g -O2 -fPIC -g -O2 -c Color.cpp -o Color.o g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include -I/System/Library/Frameworks/OpenGL.framework/Headers -DHAVE_PNG_H -I/usr/local/include/libpng12 -I/usr/X11/include -DDarwin -DNO_GL_PREFIX -I/usr/X11R6/include -Iext -I/usr/local/include -g -O2 -fPIC -g -O2 -c Disposable.cpp -o Disposable.o g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include -I/System/Library/Frameworks/OpenGL.framework/Headers -DHAVE_PNG_H -I/usr/local/include/libpng12 -I/usr/X11/include -DDarwin -DNO_GL_PREFIX -I/usr/X11R6/include -Iext -I/usr/local/include -g -O2 -fPIC -g -O2 -c FaceSet.cpp -o FaceSet.o g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include -I/System/Library/Frameworks/OpenGL.framework/Headers -DHAVE_PNG_H -I/usr/local/include/libpng12 -I/usr/X11/include -DDarwin -DNO_GL_PREFIX -I/usr/X11R6/include -Iext -I/usr/local/include -g -O2 -fPIC -g -O2 -c Light.cpp -o Light.o g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include -I/System/Library/Frameworks/OpenGL.framework/Headers -DHAVE_PNG_H -I/usr/local/include/libpng12 -I/usr/X11/include -DDarwin -DNO_GL_PREFIX -I/usr/X11R6/include -Iext -I/usr/local/include -g -O2 -fPIC -g -O2 -c LineSet.cpp -o LineSet.o g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include -I/System/Library/Frameworks/OpenGL.framework/Headers -DHAVE_PNG_H -I/usr/local/include/libpng12 -I/usr/X11/include -DDarwin -DNO_GL_PREFIX -I/usr/X11R6/include -Iext -I/usr/local/include -g -O2 -fPIC -g -O2 -c LineStripSet.cpp -o LineStripSet.o g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include -I/System/Library/Frameworks/OpenGL.framework/Headers -DHAVE_PNG_H -I/usr/local/include/libpng12 -I/usr/X11/include -DDarwin -DNO_GL_PREFIX -I/usr/X11R6/include -Iext -I/usr/local/include -g -O2 -fPIC -g -O2 -c Material.cpp -o Material.o g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include -I/System/Library/Frameworks/OpenGL.framework/Headers -DHAVE_PNG_H -I/usr/local/include/libpng12 -I/usr/X11/include -DDarwin -DNO_GL_PREF
Re: [R] [OT] Linux/UNIX question
On 20-Feb-08 21:51:54, Edna Bell wrote: > Dear R Gurus: > > I'm trying to find R on another Linux system. > > I'm using the find command, (surprise), but I only want to see the > output where it exists, not all of the other stuff. > > Is there an option that I could select, please? > > Right now I have > > find / -name R > > TIA, > Sincerely, > Edna It depends on precisely what you want to find. If you just want to locate the command "R" to run R, then, assuming that when you're logged in your $PATH contains what it should, the command which R should find it for you. E.g.: $ which R /usr/bin/R You may well find that your 'find' command generates a stream of "permission denied" messages. Since these emerge on the "stderr" channel (No 2) rather than on "stdout" (No 1), you can do find / -name R 2>/dev/null However, since all the R libraries have a subdirectory called R, you can still get a lot of output. But maybe you want that, in this case ... ! Basically, though, if R is there the main "R" command will be at /usr/bin/R, and the libraries will be at /usr/lib/R. You will also find an apparently identical "R" command at /usr/lib/R/bin/R but this is simply a symbolic link to /usr/bin/R Hoping this helps, Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 20-Feb-08 Time: 22:14:35 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Summing over an index of an array
On Wed, 2008-02-20 at 13:39 -0800, Moshe Olshansky wrote: > Try > > apply(A,2:3,sum) If speed is an issue, then colSums is a faster version of the above: > A <- array(c(1:27), dim = c(3,3,3)) > (res1 <- apply(A, 2:3, sum)) [,1] [,2] [,3] [1,]6 33 60 [2,] 15 42 69 [3,] 24 51 78 > (res2 <- colSums(A, dims = 1)) [,1] [,2] [,3] [1,]6 33 60 [2,] 15 42 69 [3,] 24 51 78 > all.equal(res1, res2) [1] TRUE This is only really an issue with large arrays or for use in repeated calculations. > system.time(replicate(1, apply(A, 2:3, sum))) user system elapsed 2.766 0.018 2.928 > system.time(replicate(1, colSums(A, dims = 1))) user system elapsed 0.563 0.006 0.596 HTH G > > --- Saurav Pathak <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > I cannot seem to figure out how to sum over an index > > of a array. > > For example, let A be a 3 dimensional array. I want > > to, say, find > > the sum over the first dimension. That is > > > > S_jk = Sum_i A_ijk > > > > where now S is a 2-dim matrix. I dont want to use a > > loop. > > > > Thanks, > > -- > > saurav > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 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.
[R] Non-standard S4 behavior
Hi all, I've been trying out the code from Chamber's "Classes and Methods in the S language": http://www.omegahat.org/RSMethods/Intro.pdf >From my session: R> whatis <- function(object) paste( "sdw" ) R> setMethod( "whatis", "vector", function(object) paste( "cswdvcr" ) ) R> dumpMethod( "whatis", "numeric" ) [1] "whatis.numeric.R" But the "whatis.numeric.R" file contains: setMethod("whatis", "numeric", NULL ) As you can see this is not what the guide describes. My R environment( built from source ): R> sessionInfo() R version 2.6.0 (2007-10-03) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] rcompgen_0.1-15 tools_2.6.0 My Linux( uname -a): Linux hostname 2.6.18.8-0.7-default #1 SMP Tue Oct 2 17:21:08 UTC 2007 x86_64 x86_64 x86_64 GNU/Linux When searching the list-archives, I found a similar situation: http://tolstoy.newcastle.edu.au/R/help/06/01/19558.html But they didn't address this issue, down the thread. Thanks, Aravind. [[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] Automatically discovering dependencies in Sweave
I am using Sweave in a Makefile-managed LaTeX project. I regenerate the .tex files automatically when there are changes in the Rnw files, but this also needs to be done when files that are sourced using source() are changed. Is there something that can be done using codetools to discover all the sourced files? I suppose one thing I could to would be to make a wrapper for source() that would log all of the files accessed. Or maybe even more generally for file(), but that would probably produce a lot of things I don't want as dependencies. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] factors ordered by mean
Hi, How to order the levels os factor not by alphabetic order but by mean of Y. Somethink like this: I have this alphabetic order: > levels(pH) [1] "alto" "baixo" "medio" the order by mean os yvar is: > sort(tapply(Riqueza,pH,mean)) baixomedio alto 11.56667 20.0 26.8 How to make the levels of pH ordered by this mean to the result to see somethink like this: > levels(pH) [1] "baixo" "medio" "alto" I try this to make a function that I need to get ordered levels by this mean and after rename to make a automatic contrasts by comparing models. > levels(pH)[1] <- "baixomedio" > levels(pH)[2] <- "baixomedio" > levels(pH) [1] "baixomedio" "alto" and after this a make a new model to be compared with a model with 3 levels where "baixo" and "medio" is separated. without ordered levels these command is wrong because the levels(pH)[1] is "alto" and not "baixo". Normally I use recode from car package, but for automatization your syntax is a difficult. Thanks Ronaldo -- > Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Biologia Computacional | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8187 | [EMAIL PROTECTED] | [EMAIL PROTECTED] | http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | LinuxUser#: 205366 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Compilation error on installing rgl package
On 20/02/2008 4:54 PM, Kenneth Lo wrote: > Hi all, > > I encountered difficulties when I tried to install the > rgl package. I'm using R devel (2.7.0) on Mac OS X > 10.5.1. Below is the message popping up when > compiling the package from source. There's been some discussion of this on the R-sig-mac list. The problem is that none of the developers of rgl have access to 64 bit OSX (or 10.5 of any type, for that matter), and nobody with access has provided a patch. Duncan Murdoch > I'd be grateful if someone can help me solve the > problem. > > Thanks, > Kenneth > > * Installing *source* package 'rgl' ... > checking for gcc... gcc -arch x86_64 -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 gcc -arch x86_64 -std=gnu99 accepts > -g... yes > checking for gcc -arch x86_64 -std=gnu99 option to > accept ANSI C... none needed > checking how to run the C preprocessor... gcc -arch > x86_64 -std=gnu99 -E > checking for gcc... (cached) gcc -arch x86_64 > -std=gnu99 > checking whether we are using the GNU C compiler... > (cached) yes > checking whether gcc -arch x86_64 -std=gnu99 accepts > -g... (cached) yes > checking for gcc -arch x86_64 -std=gnu99 option to > accept ANSI C... (cached) none needed > checking for libpng-config... yes > configure: using libpng-config > configure: using libpng dynamic linkage > checking for X... libraries /usr/X11/lib, headers > /usr/X11/include > checking for glEnd in -lGL... yes > checking for gluProject in -lGLU... yes > configure: creating ./config.status > config.status: creating src/Makevars > ** libs > g++ -arch x86_64 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include > -I/System/Library/Frameworks/OpenGL.framework/Headers > -DHAVE_PNG_H -I/usr/local/include/libpng12 > -I/usr/X11/include -DDarwin -DNO_GL_PREFIX > -I/usr/X11R6/include -Iext -I/usr/local/include -g > -O2 -fPIC -g -O2 -c BBoxDeco.cpp -o BBoxDeco.o > g++ -arch x86_64 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include > -I/System/Library/Frameworks/OpenGL.framework/Headers > -DHAVE_PNG_H -I/usr/local/include/libpng12 > -I/usr/X11/include -DDarwin -DNO_GL_PREFIX > -I/usr/X11R6/include -Iext -I/usr/local/include -g > -O2 -fPIC -g -O2 -c Background.cpp -o Background.o > g++ -arch x86_64 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include > -I/System/Library/Frameworks/OpenGL.framework/Headers > -DHAVE_PNG_H -I/usr/local/include/libpng12 > -I/usr/X11/include -DDarwin -DNO_GL_PREFIX > -I/usr/X11R6/include -Iext -I/usr/local/include -g > -O2 -fPIC -g -O2 -c Color.cpp -o Color.o > g++ -arch x86_64 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include > -I/System/Library/Frameworks/OpenGL.framework/Headers > -DHAVE_PNG_H -I/usr/local/include/libpng12 > -I/usr/X11/include -DDarwin -DNO_GL_PREFIX > -I/usr/X11R6/include -Iext -I/usr/local/include -g > -O2 -fPIC -g -O2 -c Disposable.cpp -o Disposable.o > g++ -arch x86_64 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include > -I/System/Library/Frameworks/OpenGL.framework/Headers > -DHAVE_PNG_H -I/usr/local/include/libpng12 > -I/usr/X11/include -DDarwin -DNO_GL_PREFIX > -I/usr/X11R6/include -Iext -I/usr/local/include -g > -O2 -fPIC -g -O2 -c FaceSet.cpp -o FaceSet.o > g++ -arch x86_64 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include > -I/System/Library/Frameworks/OpenGL.framework/Headers > -DHAVE_PNG_H -I/usr/local/include/libpng12 > -I/usr/X11/include -DDarwin -DNO_GL_PREFIX > -I/usr/X11R6/include -Iext -I/usr/local/include -g > -O2 -fPIC -g -O2 -c Light.cpp -o Light.o > g++ -arch x86_64 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include > -I/System/Library/Frameworks/OpenGL.framework/Headers > -DHAVE_PNG_H -I/usr/local/include/libpng12 > -I/usr/X11/include -DDarwin -DNO_GL_PREFIX > -I/usr/X11R6/include -Iext -I/usr/local/include -g > -O2 -fPIC -g -O2 -c LineSet.cpp -o LineSet.o > g++ -arch x86_64 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include > -I/System/Library/Frameworks/OpenGL.framework/Headers > -DHAVE_PNG_H -I/usr/local/include/libpng12 > -I/usr/X11/include -DDarwin -DNO_GL_PREFIX > -I/usr/X11R6/include -Iext -I/usr/local/include -g > -O2 -fPIC -g -O2 -c LineStripSet.cpp -o > LineStripSet.o > g++ -arch x86_64 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resource
[R] Calculating the Distance
***creating matrix and calculating variance across probesets x<-1:2 y<-2:141 data.matrix<-data.matrix(data[,y]) variableprobe<-apply(data.matrix[x,],1,var) hist(variableprobe) **filter out low variance* data.sub = data.matrix[order(variableprobe,decreasing=TRUE),][1:1,] dim(data.sub) [1] 1 140 summary(data.sub) a few samples: Sample_68_C Sample_69_D Sample_69_C Sample_70_D Sample_70_C Min. : 1.873 Min. : 1.893 Min. : 1.873 Min. : 1.722 Min. : 1.871 1st Qu.: 5.202 1st Qu.: 5.176 1st Qu.: 4.176 1st Qu.: 4.763 1st Qu.: 5.366 Median : 6.559 Median : 6.502 Median : 5.579 Median : 6.208 Median : 6.622 Mean : 6.473 Mean : 6.445 Mean : 5.697 Mean : 6.189 Mean : 6.558 3rd Qu.: 7.738 3rd Qu.: 7.742 3rd Qu.: 6.967 3rd Qu.: 7.547 3rd Qu.: 7.813 Max. :14.953 Max. :14.863 Max. :14.741 Max. :15.102 Max. :14.975 What is the best way to give me me probes only. I am trying to tell R to show me all the probes (10,000). What i want to do is to use the dist function to compute distances between the samples above. This function will take the matrix and computes the distances between the rows of the matrix. I tried dis <- dist(t(exprs(data.sub)), method="euclidean") but it is measuring the point by point which is too big. I would like to measure the distances between the rows. thanks!!! -- View this message in context: http://www.nabble.com/Calculating-the-Distance-tp15601307p15601307.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] fastbw() in Design works for continuous variable?
Hi, it seems that the fastbw() in the Design package only works with variable of class "factor" according to the help page if I understand correctly. Is there any R function/package that do stepwise variable selection for a Cox model with continuous independent variables? Thank you John Looking for last minute shopping deals? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plotting every ith data point?
Hello, fellow R enthusiasts. Ok, I've been racking my brain about this small issue, and between searching the help archives and reading through the plot-related documentation, I can't figure out how to achieve my desired endpoint without some ugly, brute force coding. What I would like to do is make a plot in which only a subset of my data are plotted, but in regular intervals, such as every 5th point along the sequence. Is anyone aware of a built-in function in plot or a related graphing family that can do this, or alternatively, a simple way to extract the desired rows from my original dataframe? I want to do this because I want to plot multiple series of points with their confidence intervals (arrows), and even if I specify type="b," the output ends up looking like just a series of crowded points. For example, if you try making the plot below, you will see how crowded two lines look without error bars: > example.df<-data.frame(StartDate=(94:157), DSR1=seq(0.4, 0.8, length.out=64), > DSR2=seq(0.3, 0.9, length.out=64)) > plot(example.df$StartDate, example.df$DSR1, type="b", ylim=c(0.3,0.9)) > points(example.df$StartDate, example.df$DSR2, type="b", pch=3) Any ideas for an elegant solution to my dilemma? Thanks in advance for any help. cheers, Jessi Brown Ph.D. student Program in Ecology, Evolution, and Conservation Biology University of Nevada, Reno __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting every ith data point?
Try this: ix <- seq(1, nrow(example.df), 5) with(example.df[ix,], { plot(DSR1 ~ StartDate, type = "b", ylim = c(0.3, 0.9)) points(DSR2 ~ StartDate, type = "b", pch = 3) }) On Wed, Feb 20, 2008 at 6:57 PM, Jessi Brown <[EMAIL PROTECTED]> wrote: > Hello, fellow R enthusiasts. > > Ok, I've been racking my brain about this small issue, and between > searching the help archives and reading through the plot-related > documentation, I can't figure out how to achieve my desired endpoint > without some ugly, brute force coding. > > What I would like to do is make a plot in which only a subset of my > data are plotted, but in regular intervals, such as every 5th point > along the sequence. Is anyone aware of a built-in function in plot or > a related graphing family that can do this, or alternatively, a simple > way to extract the desired rows from my original dataframe? I want to > do this because I want to plot multiple series of points with their > confidence intervals (arrows), and even if I specify type="b," the > output ends up looking like just a series of crowded points. > > For example, if you try making the plot below, you will see how > crowded two lines look without error bars: > > > example.df<-data.frame(StartDate=(94:157), DSR1=seq(0.4, 0.8, > > length.out=64), DSR2=seq(0.3, 0.9, length.out=64)) > > plot(example.df$StartDate, example.df$DSR1, type="b", ylim=c(0.3,0.9)) > > points(example.df$StartDate, example.df$DSR2, type="b", pch=3) > > Any ideas for an elegant solution to my dilemma? > > Thanks in advance for any help. > > cheers, Jessi Brown > > Ph.D. student > Program in Ecology, Evolution, and Conservation Biology > University of Nevada, Reno > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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] intersecting rows of a matrix
useR's, First, I would like to say thanks to John Fox for providing this segment of code to perform intersection for multiple sets: intersection <- function(x, y, ...){ if (missing(...)) intersect(x, y) else intersect(x, intersection(y, ...)) } I want to execute this function on the rows of a matrix I have: Ik.mat.test <- matrix(c(2,3,6,1,2,6,6,1,2),byrow=T,nrow=3) > Ik.mat.test [,1] [,2] [,3] [1,]236 [2,]126 [3,]612 I need to find a way to run the intersection function on the rows of this matrix. The result should be a vector containing 2, 6. This works, but I want to find a way to do this for any size matrix. intersection(Ik.mat.test[1,],Ik.mat.test[2,], Ik.mat.test[3,]) So, if the user supplied a matrix with any number of rows, I would like to be able to run this function. Any ideas? I have tried something like do.call(intersection, list(Ik.mat.test[1,]: Ik.mat.test[3,])) but this doesnt work Thanks in advance. Derek -- View this message in context: http://www.nabble.com/intersecting-rows-of-a-matrix-tp15601658p15601658.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] fastbw() in Design works for continuous variable?
array chip wrote: > Hi, it seems that the fastbw() in the Design package > only works with variable of class "factor" according > to the help page if I understand correctly. Is there > any R function/package that do stepwise variable > selection for a Cox model with continuous independent > variables? Yes it works. "Factor" was not a good choice of words in the documentation. Frank > > Thank you > > John > > > > > Looking for last minute shopping deals? > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] factors ordered by mean
Try this: factor(pH,levels=names(sort(tapply(Riqueza,pH,mean 2008/2/20, Ronaldo Reis Junior <[EMAIL PROTECTED]>: > Hi, > > How to order the levels os factor not by alphabetic order but by mean of Y. > Somethink like this: > > I have this alphabetic order: > > > levels(pH) > [1] "alto" "baixo" "medio" > > the order by mean os yvar is: > > sort(tapply(Riqueza,pH,mean)) >baixomedio alto > 11.56667 20.0 26.8 > > How to make the levels of pH ordered by this mean to the result to see > somethink like this: > > > levels(pH) > [1] "baixo" "medio" "alto" > > I try this to make a function that I need to get ordered levels by this mean > and after rename to make a automatic contrasts by comparing models. > > > levels(pH)[1] <- "baixomedio" > > levels(pH)[2] <- "baixomedio" > > levels(pH) > [1] "baixomedio" "alto" > > and after this a make a new model to be compared with a model with 3 levels > where "baixo" and "medio" is separated. > > without ordered levels these command is wrong because the levels(pH)[1] > is "alto" and not "baixo". > > Normally I use recode from car package, but for automatization your syntax > is > a difficult. > > Thanks > Ronaldo > -- > > Prof. Ronaldo Reis Júnior > | .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Biologia Computacional > | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia > | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil > | `- Fone: (38) 3229-8187 | [EMAIL PROTECTED] | [EMAIL PROTECTED] > | http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | LinuxUser#: 205366 > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] intersecting rows of a matrix
Try this: do.call(intersection, unname(as.data.frame(t(mat On Wed, Feb 20, 2008 at 6:45 PM, dxc13 <[EMAIL PROTECTED]> wrote: > > useR's, > > First, I would like to say thanks to John Fox for providing this segment of > code to perform intersection for multiple sets: > intersection <- function(x, y, ...){ >if (missing(...)) intersect(x, y) >else intersect(x, intersection(y, ...)) > } > > I want to execute this function on the rows of a matrix I have: > Ik.mat.test <- matrix(c(2,3,6,1,2,6,6,1,2),byrow=T,nrow=3) > > Ik.mat.test > [,1] [,2] [,3] > [1,]236 > [2,]126 > [3,]612 > > I need to find a way to run the intersection function on the rows of this > matrix. The result should be a vector containing 2, 6. > This works, but I want to find a way to do this for any size matrix. > intersection(Ik.mat.test[1,],Ik.mat.test[2,], Ik.mat.test[3,]) > So, if the user supplied a matrix with any number of rows, I would like to > be able to run this function. Any ideas? > I have tried something like > do.call(intersection, list(Ik.mat.test[1,]: Ik.mat.test[3,])) > but this doesnt work > > Thanks in advance. > Derek > > > > -- > View this message in context: > http://www.nabble.com/intersecting-rows-of-a-matrix-tp15601658p15601658.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] R console closes on its own
Dear R-experts, I am running a script that has the following structure: windows(height=5.5,width=8) dat<-read.csv("myfile.csv") names(dat)<-c('a','b','c','d') dat<-dat[,1:4] xyplot(dat$a~dat$b) Then I usually save the plot as a PDF (from the menu in the R console). I can save the PDF twice in a row; but at the third time, right when I am about to give a name to the graph, R crashes, no error messages. I am using R 2.6.2, for Windows. I copy the script from TinnR. Thank you in adavance for any help, Judith Never miss a thing. Make Yahoo your home page. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] intersecting rows of a matrix
lk.list<-split(lk.mat.test,1:nrow(lk.mat.test)) names(lk.list)<-NULL do.call(intersection,lk.list) 2008/2/20, dxc13 <[EMAIL PROTECTED]>: > > useR's, > > First, I would like to say thanks to John Fox for providing this segment of > code to perform intersection for multiple sets: > intersection <- function(x, y, ...){ > if (missing(...)) intersect(x, y) > else intersect(x, intersection(y, ...)) > } > > I want to execute this function on the rows of a matrix I have: > Ik.mat.test <- matrix(c(2,3,6,1,2,6,6,1,2),byrow=T,nrow=3) > > Ik.mat.test > [,1] [,2] [,3] > [1,]236 > [2,]126 > [3,]612 > > I need to find a way to run the intersection function on the rows of this > matrix. The result should be a vector containing 2, 6. > This works, but I want to find a way to do this for any size matrix. > intersection(Ik.mat.test[1,],Ik.mat.test[2,], Ik.mat.test[3,]) > So, if the user supplied a matrix with any number of rows, I would like to > be able to run this function. Any ideas? > I have tried something like > do.call(intersection, list(Ik.mat.test[1,]: Ik.mat.test[3,])) > but this doesnt work > > Thanks in advance. > Derek > > > > -- > View this message in context: > http://www.nabble.com/intersecting-rows-of-a-matrix-tp15601658p15601658.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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] intersecting rows of a matrix
Thanks Gabor, that works great! Gabor Grothendieck wrote: > > Try this: > > do.call(intersection, unname(as.data.frame(t(mat > > > On Wed, Feb 20, 2008 at 6:45 PM, dxc13 <[EMAIL PROTECTED]> wrote: >> >> useR's, >> >> First, I would like to say thanks to John Fox for providing this segment >> of >> code to perform intersection for multiple sets: >> intersection <- function(x, y, ...){ >>if (missing(...)) intersect(x, y) >>else intersect(x, intersection(y, ...)) >> } >> >> I want to execute this function on the rows of a matrix I have: >> Ik.mat.test <- matrix(c(2,3,6,1,2,6,6,1,2),byrow=T,nrow=3) >> > Ik.mat.test >> [,1] [,2] [,3] >> [1,]236 >> [2,]126 >> [3,]612 >> >> I need to find a way to run the intersection function on the rows of this >> matrix. The result should be a vector containing 2, 6. >> This works, but I want to find a way to do this for any size matrix. >> intersection(Ik.mat.test[1,],Ik.mat.test[2,], Ik.mat.test[3,]) >> So, if the user supplied a matrix with any number of rows, I would like >> to >> be able to run this function. Any ideas? >> I have tried something like >> do.call(intersection, list(Ik.mat.test[1,]: Ik.mat.test[3,])) >> but this doesnt work >> >> Thanks in advance. >> Derek >> >> >> >> -- >> View this message in context: >> http://www.nabble.com/intersecting-rows-of-a-matrix-tp15601658p15601658.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/intersecting-rows-of-a-matrix-tp15601658p15602494.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R console closes on its own
Hi Judith, If I undestand, see ?savePlot and try this xyplot(dat$a~dat$b) savePlot(filename="C:\\yourname",type=c("pdf"),device=dev.cur()) I hope this helps. Jorge On 2/20/08, Judith Flores <[EMAIL PROTECTED]> wrote: > > Dear R-experts, > > I am running a script that has the following > structure: > > windows(height=5.5,width=8) > > dat<-read.csv("myfile.csv") > names(dat)<-c('a','b','c','d') > dat<-dat[,1:4] > > xyplot(dat$a~dat$b) > > > Then I usually save the plot as a PDF (from the > menu in the R console). I can save the PDF twice in a > row; but at the third time, right when I am about to > give a name to the graph, R crashes, no error > messages. > > I am using R 2.6.2, for Windows. I copy the script > from TinnR. > > Thank you in adavance for any help, > > Judith > > > > > > Never miss a thing. Make Yahoo your home page. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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] plotting every ith data point?
Try this: library(lattice) xyplot(DSR1 + DSR2 ~ StartDate, example.df, type = "b", pch = c(1, 3), subset = seq(1, nrow(example.df), 5)) On Wed, Feb 20, 2008 at 8:57 PM, Jessi Brown <[EMAIL PROTECTED]> wrote: > Thanks for the ideas so far, Gabor and Phil. > > I was hoping to find a solution that didn't depend on building another > data frame, but if that's the easiest way, I can certainly do it > through that route. At least your solutions involve fewer lines of > code than I had devised for extracting the desired rows (am still a > newbie at data manipulation with R!). > > cheers, Jessi > > > On Wed, Feb 20, 2008 at 7:08 PM, Gabor Grothendieck > <[EMAIL PROTECTED]> wrote: > > Try this: > > > > ix <- seq(1, nrow(example.df), 5) > > with(example.df[ix,], { > >plot(DSR1 ~ StartDate, type = "b", ylim = c(0.3, 0.9)) > >points(DSR2 ~ StartDate, type = "b", pch = 3) > > }) > > > > > > > > > > On Wed, Feb 20, 2008 at 6:57 PM, Jessi Brown <[EMAIL PROTECTED]> wrote: > > > Hello, fellow R enthusiasts. > > > > > > Ok, I've been racking my brain about this small issue, and between > > > searching the help archives and reading through the plot-related > > > documentation, I can't figure out how to achieve my desired endpoint > > > without some ugly, brute force coding. > > > > > > What I would like to do is make a plot in which only a subset of my > > > data are plotted, but in regular intervals, such as every 5th point > > > along the sequence. Is anyone aware of a built-in function in plot or > > > a related graphing family that can do this, or alternatively, a simple > > > way to extract the desired rows from my original dataframe? I want to > > > do this because I want to plot multiple series of points with their > > > confidence intervals (arrows), and even if I specify type="b," the > > > output ends up looking like just a series of crowded points. > > > > > > For example, if you try making the plot below, you will see how > > > crowded two lines look without error bars: > > > > > > > example.df<-data.frame(StartDate=(94:157), DSR1=seq(0.4, 0.8, > > length.out=64), DSR2=seq(0.3, 0.9, length.out=64)) > > > > plot(example.df$StartDate, example.df$DSR1, type="b", ylim=c(0.3,0.9)) > > > > points(example.df$StartDate, example.df$DSR2, type="b", pch=3) > > > > > > Any ideas for an elegant solution to my dilemma? > > > > > > Thanks in advance for any help. > > > > > > cheers, Jessi Brown > > > > > > Ph.D. student > > > Program in Ecology, Evolution, and Conservation Biology > > > University of Nevada, Reno > > > > > > __ > > > R-help@r-project.org mailing list > > > https://stat.ethz.ch/mailman/listinfo/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] plotting every ith data point?
Thanks for the ideas so far, Gabor and Phil. I was hoping to find a solution that didn't depend on building another data frame, but if that's the easiest way, I can certainly do it through that route. At least your solutions involve fewer lines of code than I had devised for extracting the desired rows (am still a newbie at data manipulation with R!). cheers, Jessi On Wed, Feb 20, 2008 at 7:08 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Try this: > > ix <- seq(1, nrow(example.df), 5) > with(example.df[ix,], { >plot(DSR1 ~ StartDate, type = "b", ylim = c(0.3, 0.9)) >points(DSR2 ~ StartDate, type = "b", pch = 3) > }) > > > > > On Wed, Feb 20, 2008 at 6:57 PM, Jessi Brown <[EMAIL PROTECTED]> wrote: > > Hello, fellow R enthusiasts. > > > > Ok, I've been racking my brain about this small issue, and between > > searching the help archives and reading through the plot-related > > documentation, I can't figure out how to achieve my desired endpoint > > without some ugly, brute force coding. > > > > What I would like to do is make a plot in which only a subset of my > > data are plotted, but in regular intervals, such as every 5th point > > along the sequence. Is anyone aware of a built-in function in plot or > > a related graphing family that can do this, or alternatively, a simple > > way to extract the desired rows from my original dataframe? I want to > > do this because I want to plot multiple series of points with their > > confidence intervals (arrows), and even if I specify type="b," the > > output ends up looking like just a series of crowded points. > > > > For example, if you try making the plot below, you will see how > > crowded two lines look without error bars: > > > > > example.df<-data.frame(StartDate=(94:157), DSR1=seq(0.4, 0.8, > length.out=64), DSR2=seq(0.3, 0.9, length.out=64)) > > > plot(example.df$StartDate, example.df$DSR1, type="b", ylim=c(0.3,0.9)) > > > points(example.df$StartDate, example.df$DSR2, type="b", pch=3) > > > > Any ideas for an elegant solution to my dilemma? > > > > Thanks in advance for any help. > > > > cheers, Jessi Brown > > > > Ph.D. student > > Program in Ecology, Evolution, and Conservation Biology > > University of Nevada, Reno > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/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] factors ordered by mean
On Wed, Feb 20, 2008 at 6:02 PM, Ronaldo Reis Junior <[EMAIL PROTECTED]> wrote: > Hi, > > How to order the levels os factor not by alphabetic order but by mean of Y. > Somethink like this: > > I have this alphabetic order: > > > levels(pH) > [1] "alto" "baixo" "medio" > > the order by mean os yvar is: > > sort(tapply(Riqueza,pH,mean)) >baixomedio alto > 11.56667 20.0 26.8 > > How to make the levels of pH ordered by this mean to the result to see > somethink like this: > > > levels(pH) > [1] "baixo" "medio" "alto" Have a look at ?reorder Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 console closes on its own
On 20/02/2008 7:44 PM, Judith Flores wrote: > Dear R-experts, > >I am running a script that has the following > structure: > > windows(height=5.5,width=8) > > dat<-read.csv("myfile.csv") > names(dat)<-c('a','b','c','d') > dat<-dat[,1:4] > > xyplot(dat$a~dat$b) > > >Then I usually save the plot as a PDF (from the > menu in the R console). I can save the PDF twice in a > row; but at the third time, right when I am about to > give a name to the graph, R crashes, no error > messages. > > I am using R 2.6.2, for Windows. I copy the script > from TinnR. > > Thank you in adavance for any help, That sounds like a bug, in R or TinnR. Can you reproduce the problem if you don't use TinnR? If so, could you send me a version of myfile.csv, and I'll see if I can reproduce it and fix it. (You might be able to reproduce it without the read.csv() call, just by creating dat with fake data, e.g. dat <- data.frame(a=1:10, b=1:10, c=1:10, d=1:10). If the bug requires TinnR, then you should probably send details to its maintainers. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] intersecting rows of a matrix
Thank you, that also works perfectly! I am not sure which method works more efficiently, but they are both instantaneous and give the correct result. Thanks Derek Henrique Dallazuanna wrote: > > lk.list<-split(lk.mat.test,1:nrow(lk.mat.test)) > names(lk.list)<-NULL > do.call(intersection,lk.list) > > 2008/2/20, dxc13 <[EMAIL PROTECTED]>: >> >> useR's, >> >> First, I would like to say thanks to John Fox for providing this segment >> of >> code to perform intersection for multiple sets: >> intersection <- function(x, y, ...){ >> if (missing(...)) intersect(x, y) >> else intersect(x, intersection(y, ...)) >> } >> >> I want to execute this function on the rows of a matrix I have: >> Ik.mat.test <- matrix(c(2,3,6,1,2,6,6,1,2),byrow=T,nrow=3) >> > Ik.mat.test >> [,1] [,2] [,3] >> [1,]236 >> [2,]126 >> [3,]612 >> >> I need to find a way to run the intersection function on the rows of this >> matrix. The result should be a vector containing 2, 6. >> This works, but I want to find a way to do this for any size matrix. >> intersection(Ik.mat.test[1,],Ik.mat.test[2,], Ik.mat.test[3,]) >> So, if the user supplied a matrix with any number of rows, I would like >> to >> be able to run this function. Any ideas? >> I have tried something like >> do.call(intersection, list(Ik.mat.test[1,]: Ik.mat.test[3,])) >> but this doesnt work >> >> Thanks in advance. >> Derek >> >> >> >> -- >> View this message in context: >> http://www.nabble.com/intersecting-rows-of-a-matrix-tp15601658p15601658.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 > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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/intersecting-rows-of-a-matrix-tp15601658p15603158.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] extending code to handle more variables
useR's, Consider the variables defined below: yvals <- c(25,30,35) x1 <- c(1,2,3) x2 <- c(3,4,5) x3 <- c(6,7,8) x <- as.data.frame(cbind(x1,x2,x3)) delta <- c(2.5, 1.5, 0.5) h <- delta/2 vars <- 3 xk1 <- seq(min(x1)-0.5, max(x1)+0.5, 0.5) xk2 <- seq(min(x2)-0.5, max(x2)+0.5, 0.5) xk3 <- seq(min(x3)-0.5, max(x3)+0.5, 0.5) xks <- list(xk1,xk2,xk3) xk <- do.call("expand.grid", xks) I want to perform several calculations with these variables. For only two variables, my code is successful, however, here there are three variables (x1,x2,x3) and there could really be n variables (x1,...xn) if need be. Below is code that works for two variables, I want to convert it to work for any number of variables. Any ideas? yk <- numeric(nrow(xk)) for (j in 1:nrow(xk)) { w1 <- abs(x[,1] - xk$x1[j]) w2 <- abs(x[,2] - xk$x2[j]) Ik1 <- which(w1 <= h[1]) Ik2 <- which(w2 <= h[2]) Ik <- intersect(Ik1, Ik2) YIk <- yvals[Ik] yk[j] <- mean(YIk) } The result is the one-dimensional vector yk. Does anyone know how to extend this code to cover any number of variables? Thanks in advance. dxc13 -- View this message in context: http://www.nabble.com/extending-code-to-handle-more-variables-tp15604234p15604234.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] plotting every ith data point?
Hi, this might also work for You: > points(example.df$StartDate[ (row(example.df)%%5)==0 ], example.df$DSR2[ (row(example.df)%%5)==0 ], type="p", pch=3) > points(example.df$StartDate[ (row(example.df)%%5)==0 ], example.df$DSR2[ (row(example.df)%%5)==0 ], type="p", pch=3) Kind regads, Kimmo Jessi Brown wrote (21.02.2008): > Hello, fellow R enthusiasts. > > Ok, I've been racking my brain about this small issue, and between > searching the help archives and reading through the plot-related > documentation, I can't figure out how to achieve my desired endpoint > without some ugly, brute force coding. > > What I would like to do is make a plot in which only a subset of my > data are plotted, but in regular intervals, such as every 5th point > along the sequence. Is anyone aware of a built-in function in plot or > a related graphing family that can do this, or alternatively, a > simple way to extract the desired rows from my original dataframe? I > want to do this because I want to plot multiple series of points with > their confidence intervals (arrows), and even if I specify type="b," > the output ends up looking like just a series of crowded points. > > For example, if you try making the plot below, you will see how > > crowded two lines look without error bars: > > example.df<-data.frame(StartDate=(94:157), DSR1=seq(0.4, 0.8, > > length.out=64), DSR2=seq(0.3, 0.9, length.out=64)) > > plot(example.df$StartDate, example.df$DSR1, type="b", > > ylim=c(0.3,0.9)) points(example.df$StartDate, example.df$DSR2, > > type="b", pch=3) > > Any ideas for an elegant solution to my dilemma? > > Thanks in advance for any help. > > cheers, Jessi Brown > > Ph.D. student > Program in Ecology, Evolution, and Conservation Biology > University of Nevada, Reno > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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] plotting every ith data point?
Hi, sorry, the correct commands should look like this: > plot(example.df$StartDate[ (row(example.df)%%5)==0 ], example.df$DSR1[ (row(example.df)%%5)==0 ], type="p", ylim=c(0.3,0.9)) > points(example.df$StartDate[ (row(example.df)%%5)==0 ], example.df$DSR2[ (row(example.df)%%5)==0 ], type="p", pch=3) (In my previous mail I had the "points" twice) Kind regards, Kimmo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Selecting timestamps
R-users, I have two vectors (of timestamps) d1 <- as.POSIXct(strptime("2.2.2002 07:00", format="%d.%m.%Y %H:%M")) d2 <- as.POSIXct(strptime("4.2.2002 07:00", format="%d.%m.%Y %H:%M")) seq1 <- seq(d1, d2, "hours") seq1 d3 <- as.POSIXct(strptime("2.2.2002 15:22", format="%d.%m.%Y %H:%M")) d4 <- as.POSIXct(strptime("3.2.2002 18:12", format="%d.%m.%Y %H:%M")) seq2 <- seq(d3, d4, "hours") seq2 How to select timestamps from seq1 which are just before and after of particular timestamp in seq2? The resulting vector should look like this in this example: "2002-02-02 15:00:00 Normaaliaika" "2002-02-02 16:00:00 Normaaliaika" "2002-02-02 16:00:00 Normaaliaika" "2002-02-02 17:00:00 Normaaliaika" "2002-02-02 17:00:00 Normaaliaika" "2002-02-02 18:00:00 Normaaliaika" "2002-02-02 18:00:00 Normaaliaika" etc. Thank you, Lauri > sessionInfo() R version 2.6.0 (2007-10-03) i386-pc-mingw32 locale: LC_COLLATE=Finnish_Finland.1252;LC_CTYPE=Finnish_Finland.1252;LC_MONETARY=Finnish_Finland.1252;LC_NUMERIC=C;LC_TIME=Finnish_Finland.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RODBC_1.2-3 loaded via a namespace (and not attached): [1] tools_2.6.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Permutation Test
Dear R users, i am fairly new to R and am having trouble creating code to solve a problem. I've searched the list, combed Crawley's 'R book' and several others, but can't quite find what i want. I want to generate permutations of various 'blocks' of 14 numbers. Each number within a block is a character state for a particular biological taxon. In the example below, for 'character 1' (i.e., block 1) there are thus 4 'states' (0, 1, 2, and 3), BUT there are differing quantities of each state (e.g., five of state 0, two of state 1, four of state 2, etc.). I'd like to 'shuffle' these states across the 14 taxon labels as many times as there are unique combinations (or, if there are several million or more unique combinations, i'd like to do perhaps 1 million Monte Carlo subsets of the possible combinations). Here is an example: Taxon Character 1 Perm 1 Perm 2 Perm 3 ... Perm N A 00 3 2 B 22 0 0 C 32 2 0 D 10 0 3 E 03 0 1 F 21 3 2 G 13 2 0 H 00 2 2 I02 1 1 J21 0 0 K 03 3 3 L30 2 3 M 32 0 2 N 20 1 0 I have many characters, some with more states (e.g., character 2, below, has 6 states) and some with less states. So, ideally, the code needs to be able to deal with this. Taxon Character 2 A 5 B 3 C 2 D 4 E 4 F 1 G 3 H 0 I4 J1 K 0 L 4 M 4 N 3 Am I right in thinking that the correct way of working out how many possible permutations there can be in this instance is: N! / (n1!) (n2!) (n3!)... (ni!). Where N is the number of taxa (14) and (for character 2) n1 could be 'number of state zeros' (i.e., 2), n2 could be 'number of state ones' (i.e., 2), n3 could be 'number of state twos (i.e., 1) etc? Any help would be greatly appreciated. Thanks a lot. Steve ~~ Steven Worthington PhD Candidate New York Consortium in Evolutionary Primatology New York, NY 10003 USA ~~ -- View this message in context: http://www.nabble.com/Permutation-Test-tp15605886p15605886.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] Selecting timestamps
Since both sequences are in hourly steps, there is a fairly easy way to do this: > before <- colSums(outer(seq1, seq2, "<")) > sort(c(seq1[before], seq1[before+1])) This uses the fact that both sequences are in hourly time steps, so the time stamp 'just after' the member of seq2 is the next one to the one 'just before'. Relaxing this assumption, if needed, is left as an easy exercise. Bill Venables -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lauri Nikkinen Sent: Thursday, 21 February 2008 5:04 PM To: [EMAIL PROTECTED] Subject: [R] Selecting timestamps R-users, I have two vectors (of timestamps) d1 <- as.POSIXct(strptime("2.2.2002 07:00", format="%d.%m.%Y %H:%M")) d2 <- as.POSIXct(strptime("4.2.2002 07:00", format="%d.%m.%Y %H:%M")) seq1 <- seq(d1, d2, "hours") seq1 d3 <- as.POSIXct(strptime("2.2.2002 15:22", format="%d.%m.%Y %H:%M")) d4 <- as.POSIXct(strptime("3.2.2002 18:12", format="%d.%m.%Y %H:%M")) seq2 <- seq(d3, d4, "hours") seq2 How to select timestamps from seq1 which are just before and after of particular timestamp in seq2? The resulting vector should look like this in this example: "2002-02-02 15:00:00 Normaaliaika" "2002-02-02 16:00:00 Normaaliaika" "2002-02-02 16:00:00 Normaaliaika" "2002-02-02 17:00:00 Normaaliaika" "2002-02-02 17:00:00 Normaaliaika" "2002-02-02 18:00:00 Normaaliaika" "2002-02-02 18:00:00 Normaaliaika" etc. Thank you, Lauri > sessionInfo() R version 2.6.0 (2007-10-03) i386-pc-mingw32 locale: LC_COLLATE=Finnish_Finland.1252;LC_CTYPE=Finnish_Finland.1252;LC_MONETAR Y=Finnish_Finland.1252;LC_NUMERIC=C;LC_TIME=Finnish_Finland.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RODBC_1.2-3 loaded via a namespace (and not attached): [1] tools_2.6.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Stat related question : Skew Normal distribution
Hi, I would like to ask here one stat related question. Suppose Z ~ Skew-Normal(0,1,1). Now I want to find a variable f: Z -> Y which has Z ~ Skew-Normal(0,1,lambda) distribution. Can anyone give me some light how to do that? Regards, - [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Stat related question : Skew Normal distribution
Hi, I would like to ask here one stat related question. Suppose Z ~ Skew-Normal(0,1,1). Now I want to find a variable f: Z -> Y which has Y~ Skew-Normal(0,1,lambda) distribution. Can anyone give me some light how to do that? Regards, - [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.