Re: [R] How to generate fake population (ie. not sample) data?
On Wed, 4 Mar 2009, David Winsemius wrote: In what ways is rnorm not a satisfactory answer? My guess was that CB wants to generate a finite population whose mean and variance are specified, which would involve rnorm() followed by centering and scaling. -thomas -- David Winsemius On Mar 3, 2009, at 9:33 PM, CB wrote: This seems like it should be obvious, but searches I've tried all come up with rnorm etc. Is there a way of generating normally-distributed 'population' data with known parameters? Cheers, CB. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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. Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] nice way to find or not a value (problem with numeric(0))
Hello, I have a data.frame called spec containing data about samples. But I don't have these data for all my samples. So if I have data (that is code of the sample is in spec$Code), I would like to assign data1 to the variable m. If I don't have this data, I would like to assign 1 to m. I tried this : m-spec$data1[spec$Code==code]*(code %in%specmodules$Code) + 1*(!code %in% specmodules$Code) It works when I have the data but if it is not the case I get numeric(0) instead of 1. I finally use the following command. It works but I'm sure there is a more elegant way. if (code %in%spec$Code) m-spec$data1[spec$Code==code] else m-1 Is there a way to avoid an if-test ? Thanks for your help, Have a good day, Ptit Bleu. -- View this message in context: http://www.nabble.com/nice-way-to-find-or-not-a-value-%28problem-with-numeric%280%29%29-tp22325406p22325406.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] Self-Organizing Map analysis
glaporta glaporta at freeweb.org writes: Dear list, I read the SOM package manual but I don't understand how to perform (for example) 1) the SOM analysis on Iris data 2) with a visualization similar to that of figure 7 in http://www.cis.hut.fi/projects/somtoolbox/package/papers/techrep.pdf In R, I used the following calls to create SOM maps similar to the ones in the literature (I don't find the SOM toolbox figures particularly inspiring): library(class) data(iris) n - 10 sg - somgrid(n, n, rectangular) df.som - batchSOM(df, sg, c(4,4,3,3,2,2,1,1)) windows(record=TRUE) for (i in 1:ncol(df)) { xy - matrix(df.som$codes[,i], n, n) image(xy) contour(xy, add=T) grid(col=gray) } Of course, there are not enough Iris data to generate a reasonable SOM grid. At least n - 30 is needed for a nice graph, and that means at least 1000 data points. Using a Binhex grid instead of a rectangular one will result in diagrams similar to those from the SOM toolbox. But then the 'image' call has to be a bit prepared for this. Regards, Hans Werner Any suggestion? Thanks in advance, Gianandrea __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scatter plot question
plot(x,rho,pch=id) -Mensaje original- De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]en nombre de Dipankar Basu Enviado el: 03 March 2009 20:11 Para: r-help@r-project.org Asunto: [R] scatter plot question Hi R Users, I have a dataframe like this: id x rho A 1 0.1 B 20 0.5 C 2 0.9 ... I want to do a scatter plot of x versus rho but for each point on the scatter plot I want the corresponding entry for id instead of points. In STATA I can do so by twoway (scatter x rho, mlabel(id)) How can I do the same in R? I am sure there is some simple way to do this. Dipankar [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: nice way to find or not a value (problem with numeric(0))
Hi r-help-boun...@r-project.org napsal dne 04.03.2009 09:11:06: Hello, I have a data.frame called spec containing data about samples. But I don't have these data for all my samples. So if I have data (that is code of the sample is in spec$Code), I would like to assign data1 to the variable m. If I don't have this data, I would like to assign 1 to m. I tried this : m-spec$data1[spec$Code==code]*(code %in%specmodules$Code) + 1*(!code %in% specmodules$Code) It works when I have the data but if it is not the case I get numeric(0) instead of 1. I finally use the following command. It works but I'm sure there is a more elegant way. if (code %in%spec$Code) m-spec$data1[spec$Code==code] else m-1 It is a bit cryptic what do you want. Above version shall not work as it takes only one logical value but you probably have vector of values. (We do not know code, spec$Code or any other data you have). when I try your first construction with some values I have I get sensible results so without trying to find out how your data really look like I suggest you to inspect it more closely and/or provide some working example demonstrating what you did, what is the result and how the result shall look like. zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 50 10 1 120 80 50 20 zdrz$otac[5]-NA zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 50 1 1 120 80 50 20 zdrz$sklon[4]-Inf zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 Inf 1 1 120 80 50 20 zdrz$sklon[4]-NA zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 NA 1 1 120 80 50 20 Regards Petr Is there a way to avoid an if-test ? Thanks for your help, Have a good day, Ptit Bleu. -- View this message in context: http://www.nabble.com/nice-way-to-find-or-not-a- value-%28problem-with-numeric%280%29%29-tp22325406p22325406.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multivariate GARCH Package
Dear Mohammad, have a look at the finance task view on CRAN: http://cran.at.r-project.org/web/views/Finance.html (Dirk has nicely updated this page recently). In addition, Patrick Burns provides a recipe for PC-GARCH models on his web-site: http://www.burns-stat.com/pages/Working/multgarchuni.pdf HTH, Bernhard Good day everyone, I tried to find a multivariate GARCH package and failed to find one. Although when I searched R I found the following link which describes the package: http://www.r-project.org/user-2006/Slides/Schmidbauer+Tunalioglu.pdf can any one help me with this issue. Thank you in advance [[alternative HTML version deleted]] * Confidentiality Note: The information contained in this ...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: preparing data for barplot()
Hi Read what barplot does and look to your plot. If you want each row to be plotted as stacked bar with names uder each bar taken from peaople variable then you need to transpose your matrix - barplot takes columns plot without names - you do not want them really plotted add names under each bar - that is what names.arg is for barplot(t(data.matrix(fakedata[,-1])), names.arg=fakedata$people) Regards Petr r-help-boun...@r-project.org napsal dne 03.03.2009 19:00:12: What is the best way to produce a barplot from my data? I would like the barplot to show each person with the values stacked val1+val2+val3, so there is one bar for each person When I use barplot(data.matrix(realdata)), it shows one bar for each value instead. To post here, I created an artificical data set, but it works fine. fakedata - as.data.frame(list(LETTERS[1:3])) colnames(fakedata) - 'people' fakedata['val1'] = abs(rnorm(3)) fakedata['val2'] = abs(rnorm(3)) fakedata['val3'] = abs(rnorm(3)) barplot(data.matrix(fakedata)) At a glance there is no substantial difference is between my fake data and my real data. realdata person val1 val2 val3 1 A 221 71 175 2 B 222 85 147 mydata people val1 val2 val3 1 A 0.75526748 0.445386 0.09186245 2 B 0.06107566 2.008815 2.50269410 3 C 0.47171611 0.592037 0.57612168 However data.matrix(realdata) person val1 val2 val3 1 NA 221 71 175 2 NA 222 85 147 Warning messages: 1: NAs introduced by coercion 2: NAs introduced by coercion So then I converted 'person' from a list to factors, which removed the coercision error, but barplot() still shows each bar as value instead of a person. My serialized() data subset is here (look at bottom half where there are no line numbers) http://pastebin.com/m6d1e1d79 Thanks in advance, Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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 : Interview with Anne Milley ,SAS
Dear Lists, This is an off topic (OT ). I recently took Anne Milley's interview .In Part 1 of the interview , Anne talks about SAS, WPS, other softwares she studied like SPSS,.She also talks about the difference between small and big companies , what sets SAS apart and the famous licensing model of SAS Interview Anne Milley, SAS Part 1http://smartdatacollective.com/Home/16909 Anne Milley has been a part of SAS Institutes core strategy team. She was in the news recently with an article by the legendary Ashlee Vance in the Bits Blog of New York Times http://bits.blogs.nytimes.com/2009/02/16/sas-warms-to-open-source-one-letter-at-a-time/ In the article, Ms. Milley said, I think it addresses a niche market for high-end data analysts that want free, readily available code. We have customers who build engines for aircraft. I am happy they are not using freeware when I get on a jet. To her credit, Ms. Milley addressed some of the critical comments head-on in a subsequent blog posthttp://bits.blogs.nytimes.com/2009/01/08/r-you-ready-for-r/ . This sparked my curiosity in knowing Anne ,and her perspective more than just a single line quote and here is an interview. This is part 1 of the interview *Ajay -Describ.* Read more at http://smartdatacollective.com/Home/16909 and at http://www.decisionstats.com/ http://www.decisionstats.com/ (my server would be slower .It has no ads ,sponsors etc..) Regards, Ajay Please use comments section for comments. [[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] modifying a built in function from the stats package (fixing arima)
Dear Carlos and Kjetil, Thanks for your answer. I do not think that is the way to go. If you believe that your algorithm is better than the existing one, talk to the author of the package and discuss the improvement. The whole community will benefit. I should be able to *easily* modify it and test it first! Copy the existing function into a new file, edit it and load it via source. 3) after downloading the source package (stats) containung arima, rename it (my.arima) and then do the changes. I obviously saved it with a different name and I was expecting it to work out of the box but I get an error that I don't know how to solve: Error in Delta %+% c(1, rep(0, seasonal$period - 1), -1) : object R_TSconv not found Other people have previously discussed this in this list with no success... http://www.nabble.com/Foreign-function-call-td21836156.html Any other hints or maybe help with the error that I'm getting? -Mensaje original- De: Carlos J. Gil Bellosta [mailto:c...@datanalytics.com] Enviado el: 03 March 2009 21:30 Para: Marc Vinyes CC: r-help@r-project.org Asunto: Re: [R] modifying a built in function from the stats package (fixing arima) Hello, I do not think that is the way to go. If you believe that your algorithm is better than the existing one, talk to the author of the package and discuss the improvement. The whole community will benefit. If you want to tune the existing function and tailor it to your needs, you have several ways to go, among them: 1) Copy the existing function into a new file, edit it and load it via source. 2) Download the source package and modify it for your own purposes. Best regards, Carlos J. Gil Bellosta http://www.datanalytics.com On Tue, 2009-03-03 at 18:20 +0100, Marc Vinyes wrote: Dear members of the list, I'm a beginner in R and I'm having some trouble with: Error in optim(init[mask], armafn, method = BFGS, hessian = TRUE, control = optim.control, : non-finite finite-difference value [8] when running arima. I've seen that some people have come accross the same problem: https://stat.ethz.ch/pipermail/r-help/2008-August/169660.html So I'd like to modify the code of arima to change the optimization function with another one that handles these problems automatically , however I don't find the way to do it and http://tolstoy.newcastle.edu.au/R/e6/help/09/01/2476.html points out a way that doesn't work for me: * If I type edit(arima) and I modify it, changes are not saved, * If I copy the code and I save it like a different function, I get the hard error: Error in Delta %+% c(1, -1) : object R_TSconv not found Anybody can give me a hint? I miss matlab's easy way of doing this (edit function.m). Thanks in advance MarC (AleaSoft) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R - MATLAB apply like function
ARDIA David david.ardia at unifr.ch writes: Dear all, I very often use the R function apply, for speedup purposes. I am now also using MATLAB, and would like to use the same kind of function. I have already asked MATLAB people, and the answer is : vectorize... but of course, this is not always possible. So, instead of using a FOR loop all the time, I tried using the bsxfun. The only other Matlab functions I can come up with of are 'arrayfun', 'structfun', and 'cellfun'. For instance, arrayfun(@(x)isequal(x.f1, x.f2), S) applies an anonymous function to a structure array. But think of it, loops in Matlab are much faster than in R -- especially since version 2008a --, so the need for avoiding them is not as big. Regards, Hans Werner So you R people, who might also use MATLAB, do you have any solution? Are you also nervous about this fact (maybe also because of this R-MATLAB question). Thanks for your help, Dave [[alternative HTML version deleted]] __ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Selecting one row or multiple rows per ID
Vedula, Satyanarayana svedula at jhsph.edu writes: I need to select one row per patient i in clinic j. The data is organized similar to that shown below. ... If patient has outcome recorded at visit 2, then outcome = outcome columns at visit 2 If patient does not have visit 2, then outcome = outcome at visit 5 If patient does not have visit 2 and visit 5, then outcome = outcome at visit ... other rules I prefer to use a table driven approach here, because one can easily get lost in all these if's, and medical research requires well defined documentation of the outcome you choose. So I first convert the data to the wide format; you might alternatively use function cast in package reshape for this, but I never can get the syntax right. I also prefer to do most of this preparatory work on the database level, e.g. with PIVOT. Create a translation table of the 25 possible combinations to the column you selected, and you can be sure you forgot no combination. Dieter outc = data.frame( patclin = as.factor( paste(c(1,1,1,1,3,3,3,3), c(1,3,3,3,5,5,5,5),sep=.)), vis = as.factor(c(2,1,2,3,1,3,4,5)), outcom = c(22,21,21,20,24,21,22,22)) outw = reshape(outc,v.names=outcom,idvar=patclin,timevar=vis, direction=wide) outw = outw[,order(names(outw))] # I am sure there is a more elegant way to do this # I prefer to do this type of work on the database level outw$code= as.factor( apply(sapply(outw[,1:5],function(x){as.integer(!is.na(x))}),1,paste, collapse=)) # Note : the values here are not exactly what you requeste, # use your logic to select columns here usevisit = data.frame(code=levels(outw$code),visit=c(2,3,4)) outw = merge(usevisit,outw) outw # you get a documented table of the columns you selected and # can use visit to select the column # code visit outcom.1 outcom.2 outcom.3 outcom.4 outcom.5 patclin #1 01000 2 NA 22 NA NA NA 1.1 #2 10111 3 24 NA 21 22 22 3.5 #3 11100 4 21 21 20 NA NA 1.3 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2: annotated horizontal lines
Dear Dave, Another option would be to manually create the breaks of your plot. library(ggplot2) myBreaks - sort(c(pretty(mtcars$mpg), min(mtcars$mpg))) ggplot(aes(x = wt, y = mpg), data = mtcars) + geom_point() + geom_hline(yintercept = min(mtcars$mpg)) + scale_y_continuous(breaks = myBreaks) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens baptiste auguie Verzonden: dinsdag 3 maart 2009 21:50 Aan: Dave Murray-Rust CC: R Help Onderwerp: Re: [R] ggplot2: annotated horizontal lines I see your problem (although label should be outside the mapping in your case, i think). A possible workaround is to provide some dummy data, as the default NULL doesn't seem to work, qplot( wt, mpg, data=mtcars ) + geom_text(data=data.frame(x=0,y=0),mapping=aes(x=1,y=0),label=test) I'm sure Hadley will come up with a better explanation. Best, baptiste On 3 Mar 2009, at 19:51, Dave Murray-Rust wrote: On 3 Mar 2009, at 18:41, baptiste auguie wrote: What's wrong with geom_text? my.value = 0.65 qplot(1,1)+geom_hline(v=0)+ geom_text(mapping=aes(x=1,y=0),label=paste(my.value),vjust=-1) Well, firstly I hadn't thought to use it. Ooops. Secondly, I can't make it just do a single value - it seems to want a value for every point in the dataset, e.g.: qplot( wt, mpg, data=mtcars ) + geom_text(mapping=aes(x=1,y=0,label=paste(0.5),vjust=-1)) Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 1, 32 Cheers, dave baptiste On 3 Mar 2009, at 18:10, Dave Murray-Rust wrote: Hello, I'm using geom_hline to add a minimum line to my plot (representing the best solution found so far by a search algorithm). I'd like to annotate this line with it's numerical value to save trying to read it off the graph, but I can't see a clear way to do this - any ideas? (Alternatively, if this is against the spirit of the grammar of graphics, is there a better way to represent the information?) Cheers, dave -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Comparing two matrices
matel.rtest accepts both Euclidean and non Euclidean matrices. If both distance matrices are Euclidean, then a faster algorithm is used to speed up the permutation procedure. You can also use mantel.randtest which is exactly similar to rtest but faster as computation are in C. Sarah Goslee wrote: Hi, For the Mantel test, your matrices do not need to be Euclidean, but they do need to be symmetric. You could write a similar test that does not require a symmetric matrix, though. Sarah On Tue, Mar 3, 2009 at 11:40 AM, Koen Hufkens koen.hufk...@ua.ac.be wrote: Hi List, I would like to compare two (confusion) matrices. I ended up with the ade4 mantel.rtest function as my best option. However it seems that my data is non-euclidean in nature (is.euclid gives a FALSE). I attached both matrices at the end of the document. Are there any tools to transform these matrices into an euclidean form so I can use mantel.rtest with confidence. Other suggestions are also welcome. Kind regards, Koen -- matrix 1 V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 1 0 60 5 0 9 3 3 0 18 1 1 2 30 0 12 0 2 45 1 0 5 4 1 3 8 32 0 1 19 5 4 0 27 1 3 4 0 0 3 0 67 1 3 0 0 0 25 5 12 3 13 26 0 12 27 0 3 2 2 6 1 72 1 0 4 0 11 0 0 10 1 7 3 2 9 0 45 40 0 0 0 0 0 8 13 3 0 0 0 1 0 0 10 0 72 9 24 26 34 0 6 2 0 2 0 2 4 10 2 21 1 0 1 67 0 0 1 0 6 11 2 2 28 11 10 10 0 22 3 13 0 matrix 2 V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 1 0 66 0 10 9 5 0 3 7 0 0 2 43 0 0 14 2 32 0 1 5 3 0 3 11 32 4 0 19 10 1 7 13 2 0 4 0 0 0 0 0 0 0 0 0 0 0 5 11 6 4 18 0 15 18 22 4 1 0 6 2 40 3 3 12 0 1 24 1 14 0 7 4 5 0 8 32 49 2 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 9 19 23 2 42 8 2 0 0 0 3 1 10 1 16 3 3 3 73 0 0 2 0 0 11 2 4 0 20 15 10 15 0 10 7 17 -- Stéphane DRAY (d...@biomserv.univ-lyon1.fr ) Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I 43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France Tel: 33 4 72 43 27 57 Fax: 33 4 72 43 13 88 http://pbil.univ-lyon1.fr/members/dray/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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 pdf of function
Hi Guys, I'm a numbie to R. I searched the forum for plotting pdf's of functions but couldn't find one that explained my question. I have been asked to plot the pdf fX(x) = 1/pi(1+x^2). -infinity x infinity. I would be greatfull if someone might point me to a webpage that might give me a hand. Kindest regards Beetle -- View this message in context: http://www.nabble.com/Plotting-pdf-of-function-tp22325904p22325904.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] Number Regular Expressions
On 04-Mar-09 07:55:11, Bob Roberts wrote: Hi, I'm trying to write a regular expression that captures numbers in the form 9,007,653,372,262.48 but does not capture dates in the form 09/30/2005 I have tried numerous expressions, but they all seem to return the dates as well. Thanks. Testing the regular expression [0123456789,.][^/]* with grep (on Linux, R is not involved in this test): $ grep '[ ][0123456789,.][^/]*[ ]' EOT A line with no numbers This is 9,007,653,372,262.48 one line Another no-numbers This is 09/30/2005 another line Yet another no-numbers EOT This is 9,007,653,372,262.48 one line Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 04-Mar-09 Time: 09:30:17 -- 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] Number Regular Expressions
Not clear what else is allowed to match and what not but this will match strings of numbers commas and decimal points but not match if there is anything else in the string like a slash: regexpr(^[0-9.,]+$, 9,007,653,372,262.48) On Wed, Mar 4, 2009 at 2:55 AM, Bob Roberts quagmire54...@yahoo.com wrote: Hi, I'm trying to write a regular expression that captures numbers in the form 9,007,653,372,262.48 but does not capture dates in the form 09/30/2005 I have tried numerous expressions, but they all seem to return the dates as well. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting pdf of function
have a look at ?curve(), e.g., curve((1 + x^2) / pi, -15, 15) I hope it helps. Best, Dimitris Beetle wrote: Hi Guys, I'm a numbie to R. I searched the forum for plotting pdf's of functions but couldn't find one that explained my question. I have been asked to plot the pdf fX(x) = 1/pi(1+x^2). -infinity x infinity. I would be greatfull if someone might point me to a webpage that might give me a hand. Kindest regards Beetle -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 generate fake population (ie. not sample) data?
2009/3/4 Daniel Nordlund djnordl...@verizon.net: Something like this may help get you started. std.pop - function(x,mu,stdev){ ((x-mean(x))/sd(x)*stdev)+mu } population - std.pop(rnorm(1000),10,5) Hope this is helpful, Dan Very helpful. I hadn't thought of a simple roll-your-own approach, and was instead trying to find something built-in. Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to generate fake population (ie. not sample) data?
2009/3/4 Thomas Lumley tlum...@u.washington.edu: On Wed, 4 Mar 2009, David Winsemius wrote: In what ways is rnorm not a satisfactory answer? My guess was that CB wants to generate a finite population whose mean and variance are specified, which would involve rnorm() followed by centering and scaling. Exactly. Being an R novice, I was thinking more of built-in functions; but I see now it's straightforward enough to do. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 pdf of function
but this is not a probability density function, since lim(abs(x)- infty)=infty. But there is just a pair of brackets missing in Beetles post. btw. homework? Dimitris Rizopoulos schrieb: have a look at ?curve(), e.g., curve((1 + x^2) / pi, -15, 15) I hope it helps. Best, Dimitris Beetle wrote: Hi Guys, I'm a numbie to R. I searched the forum for plotting pdf's of functions but couldn't find one that explained my question. I have been asked to plot the pdf fX(x) = 1/pi(1+x^2). -infinity x infinity. I would be greatfull if someone might point me to a webpage that might give me a hand. Kindest regards Beetle -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Descriptive stats for factors in SEM
I feel really dumb for having to ask this, but here I go anyway... I perform structural equation modeling on a survey, using about 25 variables that create a total of 5 latent variables (factors). Applying sem (using the sem package) was a piece of cake, even for an (SEM) layman, thanks for THE excellent work here. I have all the variable/path coefficients, A- and P-matrix etc. But now I am stuck with a seemingly simple task. How do I compute the values of my latent variables, using the data I have? I need a table for my factors, showing mean, st.dev, and correlations, as seems common in journals. But I don't seem able to calculate the values that my factors take. How would I go best about to get descriptive statistics and a correlation table for my factors? I searched the archives and read as many articles by John Fox as I could, but this seems way to basic to deserve any mention :-). Thanks for any hint, Sebastian Spaeth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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: flaw in CRAN package wavelets: Daubechies d8 not recognized by function wt.filter
Thank you. I do not know where the source code is available.I never uploaded anything to CRAN. I am just an R user so far. Can you please tell me ? I did notify the package maintainer mentioned in the package on-line documentation, namely Eric Aldrich eldr...@gmail.com, twice. I suspect hic contact information is obsolete because he never got back to me or the R forum. Moreover, his web site does not exist and his name cannot be found in the University of Washington directory. Best regards, Maura -Messaggio originale- Da: David Winsemius [mailto:dwinsem...@comcast.net] Inviato: mer 04/03/2009 7.20 A: mau...@alice.it Cc: r-help@r-project.org; eldr...@gmail.com Oggetto: Re: [R] flaw in CRAN package wavelets: Daubechies d8 not recognized by function wt.filter You can look at the code yourself. The d8 filter appears to have a deletion mutation making it different than the other d-series and the fix looks feasible for testing: d6.filter - function(mod = F) { class - Daubechies name - d6 L - as.integer(6) g - c(0.332670552950083, 0.806891509311093, 0.459877502118491, -0.135011020010255, -0.0854412738820267, 0.0352262918857096) if (modwt == TRUE) { g - g/sqrt(2) transform - modwt } else transform - dwt h - wt.filter.qmf(g, inverse = TRUE) wt.filter - new(wt.filter, L = L, h = h, g = g, wt.class = class, wt.name = name, transform = transform) return(wt.filter) } d8.filter - function(mod = F) { class - Daubechies name - d8 L - as.integer(8) g - c(0.230377813307443, 0.714846570548406, 0.630880767935879, -0.0279837694166834, -0.187034811717913, 0.0308413818353661, 0.032883011778, -0.0105974017850021) missing code h - wt.filter.qmf(g, inverse = TRUE) wt.filter - new(wt.filter, L = L, h = h, g = g, wt.class = class, wt.name = name, transform = transform) return(wt.filter) } d10.filter - function(mod = F) { class - Daubechies name - d10 L - as.integer(10) g - c(0.160102397974193, 0.60382926979719, 0.724308528437773, 0.138428145901320, -0.242294887066382, -0.0322448695846381, 0.0775714938400459, -0.0062414902127983, -0.012580751999082, 0.0033357252854738) if (modwt == TRUE) { g - g/sqrt(2) transform - modwt } else transform - dwt h - wt.filter.qmf(g, inverse = TRUE) wt.filter - new(wt.filter, L = L, h = h, g = g, wt.class = class, wt.name = name, transform = transform) return(wt.filter) } Make your own wt.filter with the missing code inserted and see if happiness prevails.When I apply the fix, I get: wt.filter(d8) An object of class wt.filter Slot L: [1] 8 Slot level: [1] 1 Slot h: [1] -0.01059740 -0.03288301 0.03084138 0.18703481 -0.02798377 -0.63088077 0.71484657 -0.23037781 Slot g: [1] 0.23037781 0.71484657 0.63088077 -0.02798377 -0.18703481 0.03084138 0.03288301 -0.01059740 Slot wt.class: [1] Daubechies Slot wt.name: [1] d8 Slot transform: [1] dwt By the way, there also appears to be no d2 and calling wt.filter with d2 also provokes an error. The proper manner for getting this addressed is to draw it to the attention of the package maintainer rather than posting a to whom it may concern message to the list. -- David Winsemius On Mar 4, 2009, at 12:36 AM, mau...@alice.it mau...@alice.it wrote: wt.filter(d8) HOW COME Error in validObject(.Object) : invalid class wt.filter object: invalid object for slot transform in class wt.filter: got class function, should be or extend class character wt.filter(d10) # OK An object of class wt.filter Slot L: [1] 10 wt.filter(d6) #OK An object of class wt.filter Slot L: [1] 6 Thank you in advance to anyone who takes care of reported bugs in CRAN packages. Maura tutti i telefonini TIM! [[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. tutti i telefonini TIM! [[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
[R] F test in lmer quasipoisson
Hello !! II'm trying to test for my fixed effects using an lmer with quasipoisson errors. Since my lmer model is corrected for overdispersion using this kind of errors, I should use during model simplification in my Anovas *F test *and not *Chi square test* to compare two models. So I write: anova(model,model2,test=F) but R keeps performing a Chi square instead of the F test I want... Any ideas why ? Thank you very much !!! Julien. -- Julien Vézilier Génétique et Evolution des Maladies Infectieuses (UMR 2724 CNRS-IRD) Centre de Recherche IRD 911 Avenue Agropolis 34394 Montpellier, France Tel: + 33 467 41 63 73 Fax: + 33 467 41 62 99 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R CMD check detects parse error, but in which file?
Matthieu Stigler wrote: Hello I looked on the archives but did not find answer for that... Running R CMD check for a package, i get an error: Error in parse(n = -1, file = file) : unexpected symbol at 3341: } But how can I find which file is guilty? What is this 3342 referring to? Given I remember correctly without looking into the details: It is the line number in the concatenated file (of all your .R files, by default sorted in a C locale). Finally the solution I found is to source() every file until I find the Yes, this is probably the quickest way. source() them using a loop that reports which one fails. You may want to try out R-devel which tells you which of your R files is the culprit. Uwe Ligges file where the problem is... Is there some better way to do it? With a debuger? thanks a lot! Matthieu Stigler __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] problems with exporting a chart
Please read the posting guide which asks you to answer basic questions such as: Which R / lattice versions are we talking about? Which is the any format? Are you using the Devices directly or are you using some other way to copy contents of one device into another device? What is the exact, minimal code (including data!) that reproduces your problem? It would be nice if we could copy and paste in it work on our machines. Why do you call plot.new()? Uwe Ligges Elena Wilson wrote: Dear R helpers, I have a problem with exporting a chart (to any format). The graphic device becomes inactive and I get the 'Error: invalid graphics state' error message. I searched the help, web and FAQ but couldn't find the solution. This is my code: I chart a histogram for differences in R2 by sample size (an extract from the data is below). Altogether I have n=2500 observations (n=500 per sample size) Size; Delta_R2 60; 0.0073842 60; 0.0007156 ... 70; 0.0049717 70; 0.0121892 ... 150; 0.0139615 150; 0.0088114 ... 250; 0.0027976 250; 0.0109080 ... 450; 0.0050917 450; 0.0088114 ... The histogram works ok and I can save or copy to pdf/jpeg/png etc with no problems library(lattice) plot.new() histogram(~Delta_R2|as.factor(Size), type=percent, col=red, xlab=Delta OLS - SV R squared, main=R Squared Deviations) Once I put the legends (5 text boxes) on the chart and I try to save or copy it as pdf / jpeg/png etc I get the above mentioned error message. This is the code for adding the legends: *The locations of the legends for each chart leg_loc=matrix(c( -0.1, 0.26, 0.62, -0.1, 0.26, 0.4, 0.4, 0.4, 1, 1),ncol=2, nrow=5, byrow=FALSE) *Calculate the statistics for each sample size to display on the legends for (i in 1:5) { nR=(i-1)*500+1 nR2=nR+499 z=data[nR:nR2,13] m-mean(z) std-sqrt(var(z)) iqr=IQR(z) median=median(z) *Adding to the chart legend(leg_loc[i,1],leg_loc[i,2], legend= paste( Mean=,round(m,3),'\n', SD=,round(std,3),'\n', Median =,round(median,3),'\n', IQR=, round(iqr,3)),bty=n) } Do you know why it is happening? Thank you in advance, Lena Elena Wilson DBM Consultants Pty Ltd 5-7 Guest Street, Hawthorn, Victoria 3122, Australia T: (61 3) 9819 1555 www.dbmconsultants.com Please consider the environment before printing this email. NOTICE - The information contained in this email may be confidential and/or privileged. You should only read, disclose, re-transmit, copy, distribute, act in reliance on or commercialise the information if you are authorised to do so. If you receive this email communication in error, please notify us immediately by email to d...@dbmcons.com.au, or reply by email direct to the sender and then destroy any electronic or paper copy of this message. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] PLS regression on near infrared (NIR) spectra data
Hi, take a look on pls package and it's documentation, there are examples also for NIR data. http://mevik.net/work/software/pls.html Article form Journal of Statistical Software http://www.jstatsoft.org/v18/i02 Also Caret package can be used to evaluate pls and other regreesion models: http://caret.r-forge.r-project.org/Classification_and_Regression_Training.html Best regards, Andris On Tue, Mar 3, 2009 at 4:49 PM, Paulo Ricardo Gherardi Hein phein1...@gmail.com wrote: Dear collegues, I´ ve worked with near infrared (NIR) spectroscopy to assess chemical, physical, mechanical and anatomical properties of wood. I use The Unscrambler software to correlate the matrix of dependent variables (Y) with the matrix of spectral data (X) and I would like to migrate to R. The matrix of spectral variables is very large (2345 columns and n lines, where n = samples), so we used Partial Least Squares Regression to predict a variable y (content of cellulose, for instance) based on the spectral variables, which are the NIR wavelengths. I am new here (since jan2009) and up to now, I not seen anyone commenting about principal component analysis and regression PLS to analyze spectral information in R system. Sorry, I am a R starter... Anybody have any package, or trick to suggest me? Grateful for yours information! -- Paulo Ricardo Gherardi Hein PhD candidate at University of Montpellier 2 CIRAD - PERSYST Department Research unit: Production and Processing of Tropical Woods - TA B-40/16 73 rue Jean-François Breton 34398 Montpellier Cedex 5, France phone: +33 4 67 61 44 51 skype: paulo_hein email: paulo.h...@cirad.fr [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R CMD check detects parse error, but in which file?
Matthieu Stigler wrote: Hello I looked on the archives but did not find answer for that... Running R CMD check for a package, i get an error: Error in parse(n = -1, file = file) : unexpected symbol at 3341: } But how can I find which file is guilty? What is this 3342 referring to? Finally the solution I found is to source() every file until I find the file where the problem is... Is there some better way to do it? With a debuger? thanks a lot! Hi Matthieu, My understanding (and I may get clipped up alongside the head if I'm wrong) is that R concatenates all the source code into one big file hen checking and the number is the line number in that file. The error message may mean that you have an extra right parenthesis in that line (or very near to). Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to generate fake population (ie. not sample) data?
On Wed, Mar 4, 2009 at 2:48 AM, Daniel Nordlund djnordl...@verizon.net wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of CB Sent: Tuesday, March 03, 2009 10:05 PM To: David Winsemius Cc: r-help@r-project.org Subject: Re: [R] How to generate fake population (ie. not sample) data? My understanding is that rnorm(n, x, s) will give me an n-sized sample from an (x, s) normal distribution. So the vector returned will have a mean from the sampling distribution of the mean. But what I want is a set of n numbers literally with a mean of x and sd of s. I am at the very beginning of my R journey, so my apologies if this is a particularly naive enquiry. 2009/3/4 David Winsemius dwinsem...@comcast.net: In what ways is rnorm not a satisfactory answer? -- David Winsemius On Mar 3, 2009, at 9:33 PM, CB wrote: This seems like it should be obvious, but searches I've tried all come up with rnorm etc. Is there a way of generating normally-distributed 'population' data with known parameters? Cheers, CB. Something like this may help get you started. std.pop - function(x,mu,stdev){ ((x-mean(x))/sd(x)*stdev)+mu } Note the scale function, i.e. the above can also be written: stdev * scale(x) + mu population - std.pop(rnorm(1000),10,5) Hope this is helpful, Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to reuse my self function?
Dear all, I wrote a function test1 in test1.R. Right, I am writing another function test2 on test2.R and trying to use test1 function. How can I do? Is there any similar way like including test1.R in test2.R file? Thank You Very Much. Jia-Ming $BD%2HLC(B Jia-Ming Chang PhD Student Comparative Bioinformatics Group Bioinformatics and Genomics Programme Centre de Regulacio Genomica (CRG) Dr. Aiguader, 88 08003 Barcelona Spain E-Mail: chang.jiam...@crg.es chang.jiam...@gmail.com Web: http://www.iis.sinica.edu.tw/~jmchang/ TEL: +34 933 160 223 ext. 1223 CellPhone:+34 637 180 355 [[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] info
Dear Sir or Madam, I've been using R for one year and I really appreciate it. I would like to know if a version performing parallel computations on multicore computers and computer clusters exists. Thank you very much. Yours sincerely. Enrico Giorgi _ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R CMD check detects parse error, but in which file?
Jim Lemon a écrit : Matthieu Stigler wrote: Hello I looked on the archives but did not find answer for that... Running R CMD check for a package, i get an error: Error in parse(n = -1, file = file) : unexpected symbol at 3341: } But how can I find which file is guilty? What is this 3342 referring to? Finally the solution I found is to source() every file until I find the file where the problem is... Is there some better way to do it? With a debuger? thanks a lot! Hi Matthieu, My understanding (and I may get clipped up alongside the head if I'm wrong) is that R concatenates all the source code into one big file hen checking and the number is the line number in that file. The error message may mean that you have an extra right parenthesis in that line (or very near to). yes I think you are right, as I received similar answer from Uwe Liggs: Given I remember correctly without looking into the details: It is the line number in the concatenated file (of all your .R files, by default sorted in a C locale). Uwe added, there is no method known to him to determine in which file the problem is, and he recommended to post to r-devel. I'll do in a while if there is no answer in r-help, to avoid cross-posting. Thanks to both of you! Matthieu Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] portable R editor
Many, many thanks for all the answers! Notepad++ looks very promising although it does not have a project file management facility. But it has a very clean appearance. I'll have to look into SciTE which also sounds quite good. There seem to be some good alternatives. Meanwhile, I found a freeware application which helps to make Tinn-R truly portable: JauntePE (http://www.portablefreeware.com/?id=1452) virtualizes access to the registry and file system and can easily be used to make also the ini settings portable. Thus, everything will be on the USB stick. Thanks again, Werner -- View this message in context: http://www.nabble.com/portable-R-editor-tp22291017p22328322.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] Diff btw percentile and quantile
To calculate Percentile for a set of observations Excel has percentile() function. R function quantile() does the same thing. Is there any significant difference btw percentile and quantile? Regrads, -- View this message in context: http://www.nabble.com/Diff-btw-percentile-and-quantile-tp22328375p22328375.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] ggplot2: annotated horizontal lines
That's great - thanks! On 4 Mar 2009, at 08:59, ONKELINX, Thierry wrote: Dear Dave, Another option would be to manually create the breaks of your plot. library(ggplot2) myBreaks - sort(c(pretty(mtcars$mpg), min(mtcars$mpg))) ggplot(aes(x = wt, y = mpg), data = mtcars) + geom_point() + geom_hline(yintercept = min(mtcars$mpg)) + scale_y_continuous(breaks = myBreaks) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] Namens baptiste auguie Verzonden: dinsdag 3 maart 2009 21:50 Aan: Dave Murray-Rust CC: R Help Onderwerp: Re: [R] ggplot2: annotated horizontal lines I see your problem (although label should be outside the mapping in your case, i think). A possible workaround is to provide some dummy data, as the default NULL doesn't seem to work, qplot( wt, mpg, data=mtcars ) + geom_text(data=data.frame(x=0,y=0),mapping=aes(x=1,y=0),label=test) I'm sure Hadley will come up with a better explanation. Best, baptiste On 3 Mar 2009, at 19:51, Dave Murray-Rust wrote: On 3 Mar 2009, at 18:41, baptiste auguie wrote: What's wrong with geom_text? my.value = 0.65 qplot(1,1)+geom_hline(v=0)+ geom_text(mapping=aes(x=1,y=0),label=paste(my.value),vjust=-1) Well, firstly I hadn't thought to use it. Ooops. Secondly, I can't make it just do a single value - it seems to want a value for every point in the dataset, e.g.: qplot( wt, mpg, data=mtcars ) + geom_text(mapping=aes(x=1,y=0,label=paste(0.5),vjust=-1)) Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 1, 32 Cheers, dave baptiste On 3 Mar 2009, at 18:10, Dave Murray-Rust wrote: Hello, I'm using geom_hline to add a minimum line to my plot (representing the best solution found so far by a search algorithm). I'd like to annotate this line with it's numerical value to save trying to read it off the graph, but I can't see a clear way to do this - any ideas? (Alternatively, if this is against the spirit of the grammar of graphics, is there a better way to represent the information?) Cheers, dave -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 reuse my self function?
Hi, I think you just have to call it with the correct arguments inside test2 function. So the arguments for test1 functions should be consider to be also arguments of test2 function. test2 - function( test1arguments, test2arguments ){ ... value - test1( test1arguments ) ... } Regards 2009/3/4 Chang Jia-Ming chang.jiam...@crg.es Dear all, I wrote a function test1 in test1.R. Right, I am writing another function test2 on test2.R and trying to use test1 function. How can I do? Is there any similar way like including test1.R in test2.R file? Thank You Very Much. Jia-Ming ¼Òã Jia-Ming Chang PhD Student Comparative Bioinformatics Group Bioinformatics and Genomics Programme Centre de Regulacio Genomica (CRG) Dr. Aiguader, 88 08003 Barcelona Spain E-Mail: chang.jiam...@crg.es chang.jiam...@gmail.com Web: http://www.iis.sinica.edu.tw/~jmchang/http://www.iis.sinica.edu.tw/%7Ejmchang/ TEL: +34 933 160 223 ext. 1223 CellPhone:+34 637 180 355 [[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. -- Patricia Garc¨ªa [[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] PLS regression on near infrared (NIR) spectra data
Paulo Ricardo Gherardi Hein phein1...@gmail.com writes: I am new here (since jan2009) and up to now, I not seen anyone commenting about principal component analysis and regression PLS to analyze spectral information in R system. Sorry, I am a R starter... Anybody have any package, or trick to suggest me? There is the package 'pls', with Principal Component Regression (PCR) and Partial Least Squares Regression (PLSR). It also contains a couple of plots that are useful for princomp() or prcomp() analyses (PCA). -- Bjørn-Helge Mevik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] PLS regression on near infrared (NIR) spectra data
Hi Paulo, You might also want to look at something like the glmnet package (Friedman, Hastie, and Tibshirani). This carries out penalized regression, is designed to work with high numbers of predictors/inputs/columns and relatively few samples/obervations/rows, and is very fast. See: http://www-stat.stanford.edu/~hastie/Papers/glmnet.pdf HTH, Mark. Paulo Ricardo Gherardi Hein wrote: Dear collegues, I´ ve worked with near infrared (NIR) spectroscopy to assess chemical, physical, mechanical and anatomical properties of wood. I use The Unscrambler software to correlate the matrix of dependent variables (Y) with the matrix of spectral data (X) and I would like to migrate to R. The matrix of spectral variables is very large (2345 columns and n lines, where n = samples), so we used Partial Least Squares Regression to predict a variable y (content of cellulose, for instance) based on the spectral variables, which are the NIR wavelengths. I am new here (since jan2009) and up to now, I not seen anyone commenting about principal component analysis and regression PLS to analyze spectral information in R system. Sorry, I am a R starter... Anybody have any package, or trick to suggest me? Grateful for yours information! -- Paulo Ricardo Gherardi Hein PhD candidate at University of Montpellier 2 CIRAD - PERSYST Department Research unit: Production and Processing of Tropical Woods - TA B-40/16 73 rue Jean-François Breton 34398 Montpellier Cedex 5, France phone: +33 4 67 61 44 51 skype: paulo_hein email: paulo.h...@cirad.fr [[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. -- View this message in context: http://www.nabble.com/PLS-regression-on-near-infrared-%28NIR%29-spectra-data-tp22311467p22328510.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 and Citrix - Lotus notes
Dear All, 1. Does anyone have experience of running R on a server inside a Citrix shell - I'd like to get R onto the server and would be greatful for any tips or direction on the matter. 2. This may seem like a silly question so forgive my ignornace. Most of the data I currently work with is held on a number of Lotus Notes (LN) Databases (well it's called a DB here but it's really a document management system) and in this environment I have to export files to text and then read the file. Is it possible to access LN tables directly using R - has anyone tried or is there a package that'll help? thanks Gerard ** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. It is the policy of the Department of Justice, Equality and Law Reform and the Agencies and Offices using its IT services to disallow the sending of offensive material. Should you consider that the material contained in this message is offensive you should contact the sender immediately and also mailminder[at]justice.ie. Is le haghaidh an duine nó an eintitis ar a bhfuil sí dírithe, agus le haghaidh an duine nó an eintitis sin amháin, a bheartaítear an fhaisnéis a tarchuireadh agus féadfaidh sé go bhfuil ábhar faoi rún agus/nó faoi phribhléid inti. Toirmisctear aon athbhreithniú, atarchur nó leathadh a dhéanamh ar an bhfaisnéis seo, aon úsáid eile a bhaint aisti nó aon ghníomh a dhéanamh ar a hiontaoibh, ag daoine nó ag eintitis seachas an faighteoir beartaithe. Má fuair tú é seo trí dhearmad, téigh i dteagmháil leis an seoltóir, le do thoil, agus scrios an t-ábhar as aon ríomhaire. Is é beartas na Roinne Dlí agus Cirt, Comhionannais agus Athchóirithe Dlí, agus na nOifígí agus na nGníomhaireachtaí a úsáideann seirbhísí TF na Roinne, seoladh ábhair cholúil a dhícheadú. Más rud é go measann tú gur ábhar colúil atá san ábhar atá sa teachtaireacht seo is ceart duit dul i dteagmháil leis an seoltóir láithreach agus le mailminder[ag]justice.ie chomh maith. *** __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 reuse my self function?
Hi, You can use the source() function to load functions from other files, like: source(test1.R) cheers, Paul Chang Jia-Ming wrote: Dear all, I wrote a function test1 in test1.R. Right, I am writing another function test2 on test2.R and trying to use test1 function. How can I do? Is there any similar way like including test1.R in test2.R file? Thank You Very Much. Jia-Ming $BD%2HLC(B Jia-Ming Chang PhD Student Comparative Bioinformatics Group Bioinformatics and Genomics Programme Centre de Regulacio Genomica (CRG) Dr. Aiguader, 88 08003 Barcelona Spain E-Mail: chang.jiam...@crg.es chang.jiam...@gmail.com Web: http://www.iis.sinica.edu.tw/~jmchang/ TEL: +34 933 160 223 ext. 1223 CellPhone:+34 637 180 355 [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Filtering R lists
Hello I am am new to R and any help with the following would be appreciated: I have a list (example attached) and I would like to create a new list which is a filtered version of this list. I.e I would like a list that only contains elements with this value: Chr 10 : 21853562 - 21855482 Any pointers/tips would be great. Thanks! Nikol -- Bioinformatician/Computer Associate Cambridge Institute for Medical Research University of Cambridge Wellcome Trust/MRC Building Hills Road Cambridge CB2 0XY 01223 762111 [[1]] human../US45102804_251757910002_S01_CGH-v4_95_Feb07.chr10.cher1 Chr 10 : 21853562 - 21855482 Antibody : ./US45102804_251757910002_S01_CGH-v4_95_Feb07 Maximum level = 0.5370385 Score = 3.193875 Spans 19 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2649]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher18 Chr X : 72387424 - 72387712 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.3504706 Score = 0.4045575 Spans 4 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2650]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher19 Chr X : 129037305 - 129037494 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.4718157 Score = 0.5751177 Spans 3 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2651]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher20 Chr X : 129048386 - 129048865 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.3711013 Score = 0.4121159 Spans 5 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2652]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher21 Chr X : 129065300 - 129066038 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.4387153 Score = 1.515073 Spans 8 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 CMD check detects parse error, but in which file?
Matthieu Stigler wrote: Jim Lemon a écrit : Matthieu Stigler wrote: Hello I looked on the archives but did not find answer for that... Running R CMD check for a package, i get an error: Error in parse(n = -1, file = file) : unexpected symbol at 3341: } But how can I find which file is guilty? What is this 3342 referring to? Finally the solution I found is to source() every file until I find the file where the problem is... Is there some better way to do it? With a debuger? thanks a lot! Hi Matthieu, My understanding (and I may get clipped up alongside the head if I'm wrong) is that R concatenates all the source code into one big file hen checking and the number is the line number in that file. The error message may mean that you have an extra right parenthesis in that line (or very near to). yes I think you are right, as I received similar answer from Uwe Liggs: Given I remember correctly without looking into the details: It is the line number in the concatenated file (of all your .R files, by default sorted in a C locale). Uwe added, there is no method known to him to determine in which file NO, I said something different (maybe my English is too bad so you misunderstood): I said I'd use your method of source()ing all files separately (i.e. using a for loop) and looking which file fails (with curretn versions of R) and I said that R-devel (i.e. the current development version of R) tells you in which file the error is. So please try R-devel to be R-2.9.0 in roughly 1-2 months. Uwe Ligges the problem is, and he recommended to post to r-devel. I'll do in a while if there is no answer in r-help, to avoid cross-posting. Thanks to both of you! Matthieu Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] locfit smoothing question (package maintainer not reachable)
On Tue, 03 Mar 2009 22:10:42 +0100, David Winsemius dwinsem...@comcast.net wrote: That is what I thought to be the critical paragraph. The variance is assumed to be = 1 when you use family=gaussian rather than the default of family=qgauss. You give it a vector, 1000*rnorm(100), that ranges widely and a small (relative) variance is assumed and so the confidence intervals are plotted as very narrow. This does not seem surprising given the functions documented design. I have the book and do not think I even need to pull it off the shelf since the help pages appear fully informative in this instance. I get an rv of 1 with the gaussian option and an rv of nearly 1000 when the default is used. Thank you, that is helpful. I guess I am wondering under what circumstance would it be appropriate to assume that the data had a variance of 1 and use the family=gaussian option. Perhaps this is for normalized data ? Suresh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Filtering R lists
Hi r-help-boun...@r-project.org napsal dne 04.03.2009 13:18:30: Hello I am am new to R and any help with the following would be appreciated: I have a list (example attached) and I would like to create a new list which is a filtered version of this list. I.e I would like a list that only contains elements with this value: Chr 10 : 21853562 - 21855482 Lists can have quite complicated structure so here is only a small suggestion lapply(your.list, function(x) x==desired.value) This shall give you list of logical values if your list has only one level. Something like pts - list(x=mtcars[,1], y=mtcars[,2], z=mtcars[,10]) pts[which(unlist(lapply(pts, function(x) sum(x==4)0)))] Regards Petr Any pointers/tips would be great. Thanks! Nikol -- Bioinformatician/Computer Associate Cambridge Institute for Medical Research University of Cambridge Wellcome Trust/MRC Building Hills Road Cambridge CB2 0XY 01223 762111 [[1]] human../US45102804_251757910002_S01_CGH-v4_95_Feb07.chr10.cher1 Chr 10 : 21853562 - 21855482 Antibody : ./US45102804_251757910002_S01_CGH-v4_95_Feb07 Maximum level = 0.5370385 Score = 3.193875 Spans 19 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2649]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher18 Chr X : 72387424 - 72387712 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.3504706 Score = 0.4045575 Spans 4 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2650]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher19 Chr X : 129037305 - 129037494 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.4718157 Score = 0.5751177 Spans 3 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2651]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher20 Chr X : 129048386 - 129048865 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.3711013 Score = 0.4121159 Spans 5 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2652]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher21 Chr X : 129065300 - 129066038 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.4387153 Score = 1.515073 Spans 8 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Descriptive stats for factors in SEM
John Fox wrote: Dear Sebastian, What you're looking for are factor-score coefficients, which would allow you to estimate the values of the factors from the observed variables. Then, given the original dataset from which the input-covariance matrix to sem() was computed, you could find the factor scores. The sem packages doesn't provide factor-score coefficients, but this is a reasonable request, and I'll add it to my to-do list. I can't promise when I'll get this done. I'm not sure why you want the means, standard deviations, and correlations of the latent variables. In most models, the means will be 0. You could figure out the covariance matrix of the latent variables; sem()doesn't provide that either. I was looking at Piccolo, R. F. COLQUITT, J. A. TRANSFORMATIONAL LEADERSHIP AND JOB BEHAVIORS: THE MEDIATING ROLE OF CORE JOB CHARACTERISTICS Academy of Management Journal, 2006, 49, 327-34 and other articles using SEM and they provide those factor-score coefficents. (pdf for article here: http://www.ximb.ac.in/~jgeorge/transforjobbehavior.pdf , table on p.8) I have never published an SEM model before, so I assume it is standard to provide those. Anyway, thank you for your hint, and thanks for putting it on your TODO list. I am amazed by the speed you were replying, much appreciated. I have just ordered another of your books :-). Sebastian Spaeth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Descriptive stats for factors in SEM
Dear Sebastian, What you're looking for are factor-score coefficients, which would allow you to estimate the values of the factors from the observed variables. Then, given the original dataset from which the input-covariance matrix to sem() was computed, you could find the factor scores. The sem packages doesn't provide factor-score coefficients, but this is a reasonable request, and I'll add it to my to-do list. I can't promise when I'll get this done. I'm not sure why you want the means, standard deviations, and correlations of the latent variables. In most models, the means will be 0. You could figure out the covariance matrix of the latent variables; sem()doesn't provide that either. Regards, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Sebastian Spaeth Sent: March-04-09 5:20 AM To: r-help@r-project.org Subject: [R] Descriptive stats for factors in SEM I feel really dumb for having to ask this, but here I go anyway... I perform structural equation modeling on a survey, using about 25 variables that create a total of 5 latent variables (factors). Applying sem (using the sem package) was a piece of cake, even for an (SEM) layman, thanks for THE excellent work here. I have all the variable/path coefficients, A- and P-matrix etc. But now I am stuck with a seemingly simple task. How do I compute the values of my latent variables, using the data I have? I need a table for my factors, showing mean, st.dev, and correlations, as seems common in journals. But I don't seem able to calculate the values that my factors take. How would I go best about to get descriptive statistics and a correlation table for my factors? I searched the archives and read as many articles by John Fox as I could, but this seems way to basic to deserve any mention :-). Thanks for any hint, Sebastian Spaeth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] sorting out partially nested mixed effects in lme4
In lme4 I wamnt to analyse a dataset in which the random effects are somewhat intricate. The nearest approximation of what I want to know is lmer(hr~hpos+((bin==b)|VP)+(1|(VP:exp)), data) In this design VP denotes the subject variable, and exp the experimental unit (which is obviously nested in VP). The comparison is true in 2/3 of cases. The most interesting outcome are the sd and the BLUPs for this factor with treatment contrast. The problem with this, that the uninteresting intercept term from the first random factor is doubled, because the term 1|(VP:exp) of the second rndom term already estimates individual intercepts for each experimental unit. What is worrying me is that it happens sometimes the lmer summary may look as Formula: hl ~ hpos * vpos + ((bin == b) | VP) + (1 | (VP:exp)) Data: subset(mean2, bin != r) AIC BIC logLik deviance REMLdev 42959 43014 -2147142959 42941 Random effects: Groups NameVariance Std.Dev. Corr (VP:exp) (Intercept) 6.56e+06 2.56e+03 VP (Intercept) 2.54e-08 1.59e-04 bin == b1 8.30e+01 9.11e+00 0.000 Residual 5.43e+04 2.33e+02 Number of obs: 3077, groups: (VP:exp), 81; VP, 17 or sometimes as Formula: hr ~ hpos * vpos + ((bin == b) | VP) + (1 | (VP:exp)) Data: subset(mean2, bin != l) AIC BIC logLik deviance REMLdev 40009 40063 -1999540010 39991 Random effects: Groups NameVariance Std.Dev. Corr (VP:exp) (Intercept) 1.30e+06 1141.39 VP (Intercept) 7.61e+06 2758.21 bin == b1 8.07e+018.99 -0.779 Residual 4.35e+04 208.47 Number of obs: 2914, groups: (VP:exp), 81; VP, 17 In the first case the 2nd intercept is estimated as nearly zero, in the other of substantial size, but the data themselves should be quite similar, because they are measured in the same experiments, one on the right eye, the other on the left. I did not find a way the eliminate the estimation this term. -- Dipl.-Math. Wilhelm Bernhard Kloke Leibniz-Institut fuer Arbeitsforschung an der TU Dortmund Ardeystrasse 67, D-44139 Dortmund, Tel. 0231-1084-373 PGP: http://vestein.arb-phys.uni-dortmund.de/~wb/mypublic.key __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Filtering R lists
Dear Nikol, Try this: do.call(c,lapply(yourlist,function(x) x[2] )) HTH, Jorge On Wed, Mar 4, 2009 at 7:18 AM, Nikol Simecek ns...@cam.ac.uk wrote: Hello I am am new to R and any help with the following would be appreciated: I have a list (example attached) and I would like to create a new list which is a filtered version of this list. I.e I would like a list that only contains elements with this value: Chr 10 : 21853562 - 21855482 Any pointers/tips would be great. Thanks! Nikol -- Bioinformatician/Computer Associate Cambridge Institute for Medical Research University of Cambridge Wellcome Trust/MRC Building Hills Road Cambridge CB2 0XY 01223 762111 [[1]] human../US45102804_251757910002_S01_CGH-v4_95_Feb07.chr10.cher1 Chr 10 : 21853562 - 21855482 Antibody : ./US45102804_251757910002_S01_CGH-v4_95_Feb07 Maximum level = 0.5370385 Score = 3.193875 Spans 19 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2649]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher18 Chr X : 72387424 - 72387712 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.3504706 Score = 0.4045575 Spans 4 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2650]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher19 Chr X : 129037305 - 129037494 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.4718157 Score = 0.5751177 Spans 3 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2651]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher20 Chr X : 129048386 - 129048865 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.3711013 Score = 0.4121159 Spans 5 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type [[2652]] human../US45102804_252058310010_S01_CGH-v4_95_Feb07.chrX.cher21 Chr X : 129065300 - 129066038 Antibody : ./US45102804_252058310010_S01_CGH-v4_95_Feb07 Maximum level = 0.4387153 Score = 1.515073 Spans 8 probes. Defined extras: typeUpstream, typeInside, distMid2TSS, upSymbol, inSymbol, type __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to reuse my self function?
Hello, If test2 and test1 functions are in two files like test2.R and test1.R, how could I do to let test2 know test1 function? Cheers, Jia Ming 2009/3/4 Usuario R r.user.sp...@gmail.com Hi, I think you just have to call it with the correct arguments inside test2 function. So the arguments for test1 functions should be consider to be also arguments of test2 function. test2 - function( test1arguments, test2arguments ){ ... value - test1( test1arguments ) ... } Regards 2009/3/4 Chang Jia-Ming chang.jiam...@crg.es Dear all, I wrote a function test1 in test1.R. Right, I am writing another function test2 on test2.R and trying to use test1 function. How can I do? Is there any similar way like including test1.R in test2.R file? Thank You Very Much. Jia-Ming ¼Òã Jia-Ming Chang PhD Student Comparative Bioinformatics Group Bioinformatics and Genomics Programme Centre de Regulacio Genomica (CRG) Dr. Aiguader, 88 08003 Barcelona Spain E-Mail: chang.jiam...@crg.es chang.jiam...@gmail.com Web: http://www.iis.sinica.edu.tw/~jmchang/http://www.iis.sinica.edu.tw/%7Ejmchang/ TEL: +34 933 160 223 ext. 1223 CellPhone:+34 637 180 355 [[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. -- Patricia Garc¨ªa -- Jia-Ming ¼Òã Jia-Ming Chang PhD Student Comparative Bioinformatics Group Bioinformatics and Genomics Programme Centre de Regulacio Genomica (CRG) Dr. Aiguader, 88 08003 Barcelona Spain E-Mail: chang.jiam...@crg.es chang.jiam...@gmail.com Web: http://www.iis.sinica.edu.tw/~jmchang/ TEL: +34 933 160 223 ext. 1223 CellPhone:+34 637 180 355 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to reuse my self function?
I usually use the ?source function. so at the top of your test2.R file, you would put a line like: source('C:\\test1.R') but with the correct path to where ever you have stored your test1.R file. Hope that helps a little, Tony On 4 Mar, 10:29, Chang Jia-Ming chang.jiam...@crg.es wrote: Dear all, I wrote a function test1 in test1.R. Right, I am writing another function test2 on test2.R and trying to use test1 function. How can I do? Is there any similar way like including test1.R in test2.R file? Thank You Very Much. Jia-Ming 張家銘 Jia-Ming Chang PhD Student Comparative Bioinformatics Group Bioinformatics and Genomics Programme Centre de Regulacio Genomica (CRG) Dr. Aiguader, 88 08003 Barcelona Spain E-Mail: chang.jiam...@crg.es chang.jiam...@gmail.com Web:http://www.iis.sinica.edu.tw/~jmchang/ TEL: +34 933 160 223 ext. 1223 CellPhone:+34 637 180 355 [[alternative HTML version deleted]] __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] inserting lines in large data set
Hello, I need to insert a line after every eigth row (group/suset) which should contains the following: (an incremented ID),0,1,1,1,1 I have two problems with constructing my code: 1. I am getting NAs in three of the columns and 2) I can not find a way to write the ID (group name) at the beginning of the inserted line. Below the # sign I show one of the ways I tried from a variation of a script I found searching the r list-help page. This is a small example of my data set. hcmid1[1:24,] ID dose Avep1 Avep2 Avep3 Avep4 1 50676 A 110 76.6030534351145 70.9993322946806 72.3357981731187 83.0880635365569 2 50676 A 150 12.08015267175577.6118406409971 7.69899956502827 17.7762205092268 3 50676 A 175 1.35496183206107 1.13788114845315 2.34884732492388 4.97547302032236 4 50676 A 1 100 0.598759541984733 0.567549521477854 0.622553284036538 2.03807521607101 5 50676 A 1 120 0.65601145038168 0.0584242154462498 1.40550239234450 0.908082223779492 6 50676 A 1 140 0.846851145038168 0.303249499221010 0.266420182688125 1.86580238262088 7 50676 A 1 160 0.372137404580153 1.00990429557089 0.492061765985211 2.42641906096706 8 50676 A 1 200 0.319656488549619 0.614845314934342 0.58721183123097 1.07159542163046 11 50676 A 210 84.1897233201581 85.3687739463602 87.1918801353311 90.1436464088398 12 50676 A 250 18.4106511337633 17.0019157088123 16.2155630739488 24.6408839779006 13 50676 A 275 1.91387559808613 1.96360153256705 1.1599806669 2.43093922651934 14 50676 A 2 100 0.434262533804868 1.39 0.700821652972451 1.13812154696133 15 50676 A 2 120 0.309444560016643 0.58668582375479 0.640405993233447 1.30386740331492 16 50676 A 2 140 0.306844185562721 0.562739463601533 0.447075882068633 0.674033149171271 17 50676 A 2 160 0.260037445392137 0.311302681992337 0.809569840502659 0.773480662983426 18 50676 A 2 200 0.473268150613689 0.454980842911878 0.749154180763654 0.895027624309393 21 50676 A 310 88.8305225324855 74.5594713656388 83.3893050891243 81.4887848163668 22 50676 A 350 14.5700857063865 16.5198237885463 20.5114957375355 22.8493961054967 23 50676 A 375 0.940005529444292 2.175110132158592.9708085765952 1.72541286665024 24 50676 A 3 100 0.708460049764999 0.85352422907489 0.800826659777836 0.665516391422234 25 50676 A 3 120 0.63588609344761 0.49559471365639 0.561870317747353 0.391298989401036 26 50676 A 3 140 0.311031241360244 0.385462555066082 0.213123223973134 0.289622874044861 27 50676 A 3 160 0.228089576997513 0.426762114537447 0.180831826401447 0.511461671185606 28 50676 A 3 200 0.124412496544098 0.357929515418503 0.0129165590286748 0.406704461424698 . . . This is the script I used to obtain the output below. --- .row - rep(1,6*1) dim(.row)-c(1,6) .row - data.frame(.row) names(.row) - names(hcmid1) .row$ID - hcmid1$ID[1] .row$dose - 1.0 .row$Avep1 - 0.0 .row$Avep2 - 0.0 .row$Avep3 - 0.0 .row$Avep4 - 0.0 do.call(rbind,lapply(split(hcmid1, hcmid1$ID), function(x) rbind(x,.row))) ID dose Avep1 Avep2 Avep3 Avep4 50676 A 1 .1 50676 A 110 76.6030534351145 70.9993322946806 72.3357981731187 83.0880635365569 50676 A 1 .2 50676 A 150 12.08015267175577.6118406409971 7.69899956502827 17.7762205092268 50676 A 1 .3 50676 A 175 1.35496183206107 1.13788114845315 2.34884732492388 4.97547302032236 50676 A 1 .4 50676 A 1 100 0.598759541984733 0.567549521477854 0.622553284036538 2.03807521607101 50676 A 1 .5 50676 A 1 120 0.65601145038168 0.0584242154462498 1.40550239234450 0.908082223779492 50676 A 1 .6 50676 A 1 140 0.846851145038168 0.303249499221010 0.266420182688125 1.86580238262088 50676 A 1 .7 50676 A 1 160 0.372137404580153 1.00990429557089 0.492061765985211 2.42641906096706 50676 A 1 .8 50676 A 1 200 0.319656488549619 0.614845314934342 0.58721183123097 1.07159542163046 50676 A 1 .9 50676 A 1 NA 0 NA NA 0 50676 A 2 .11 50676 A 210 84.1897233201581 85.3687739463602 87.1918801353311 90.1436464088398 50676 A 2 .12 50676 A 250 18.4106511337633 17.0019157088123 16.2155630739488 24.6408839779006 50676 A 2 .13 50676 A 275 1.91387559808613 1.96360153256705 1.1599806669 2.43093922651934 50676 A 2 .14 50676 A 2 100 0.434262533804868 1.39 0.700821652972451 1.13812154696133 50676 A 2 .15 50676 A 2 120 0.309444560016643 0.58668582375479 0.640405993233447 1.30386740331492 50676 A 2 .16 50676 A 2 140 0.306844185562721 0.562739463601533 0.447075882068633 0.674033149171271 50676 A 2 .17 50676 A 2 160 0.260037445392137 0.311302681992337 0.809569840502659 0.773480662983426 50676 A 2 .18 50676 A 2 200 0.473268150613689 0.454980842911878
[R] error in mood.test
Dear list, when running a mood.test() (part of package stats) on slightly longer vectors (than the example from the help-page) we get the error-message shown below : once both vectors tested are of length 50 this error oocurs. Note, that this problem didn't occur with R-2.7.x (or even older versions). x - rnorm(50,10,5) y - rnorm(50,2,5) mood.test( x[1:45], y[1:45])# works OK Mood two-sample test of scale data: x[1:45] and y[1:45] Z = -0.1556, p-value = 0.8763 alternative hypothesis: two.sided mood.test( x, y)# works ONLY on R-2.7.x but NOT on R-2.8.x Mood two-sample test of scale data: x and y Z = NA, p-value = NA alternative hypothesis: two.sided Warning message: In m * n * (N + 1L) * (N + 2L) * (N - 2L) : NAs produced by integer overflow # for completness sessionInfo() R version 2.8.1 (2008-12-22) i386-pc-mingw32 locale: LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252 attached base packages: [1] stats graphics grDevices datasets tcltk utils methods base other attached packages: [1] svSocket_0.9-5 svIO_0.9-5 R2HTML_1.59svMisc_0.9-5 svIDE_0.9-5 loaded via a namespace (and not attached): [1] tools_2.8.1 Thank's in advance, Wolfgang and David . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD Laboratoire de BioInformatique et Génomique Intégratives CNRS UMR7104, IGBMC 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France Tel (+33) 388 65 3300 Fax (+33) 388 65 3276 wolfgang.raffelsberger (at) igbmc.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to dump plots as bas64 strings?
Hello My question might sound awkward, but I am looking for a way to somehow convert a plot in R into a base64 string. Here's an idea, but it is not at all satisfying. 1. write the plot to the harddisk: --- png(toto.png) plot(c(1,2,3)) dev.off() --- 2. somehow reload that file from the disk and transform it into a base64 string: --- bin-readBin(file(toto.png,rb), raw(), n=1000,endian = little) ... --- Using the disk to perform this is not elegant, I don't know what value to put for n, and I don't like the general idea. Does anyone have a better suggestion? I have already searched on the internet and in the mailing list, and I just found something on a caTools package containing a base64encode base64decode function. Thanx for any ideas ... Patrick __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Filtering R lists
Nikol Simecek wrote: Hello I am am new to R and any help with the following would be appreciated: I have a list (example attached) and I would like to create a new list which is a filtered version of this list. I.e I would like a list that only contains elements with this value: Chr 10 : 21853562 - 21855482 Filter provides a generic approach to filtering: Filter(x=your list, f=function(element) does element contain 'Chr 10 : 21853562 - 21855482'?) where you have to implement the filtering function. if each element in your list is a string (a character vector of length 1), you can also use grep: grep('Chr 10 : 21853562 - 21855482', your list, value=TRUE) if each element in your list is a character vector, a list, a data frame, or something else (not just a single string), you may use a combination of grep and lapply, but i think the Filter approach is in this case cleaner. see ?Filter and ?grep. vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Odp: Filtering R lists
Petr PIKAL wrote: Hi r-help-boun...@r-project.org napsal dne 04.03.2009 13:18:30: Hello I am am new to R and any help with the following would be appreciated: I have a list (example attached) and I would like to create a new list which is a filtered version of this list. I.e I would like a list that only contains elements with this value: Chr 10 : 21853562 - 21855482 Lists can have quite complicated structure so here is only a small suggestion lapply(your.list, function(x) x==desired.value) This shall give you list of logical values if your list has only one level. Something like pts - list(x=mtcars[,1], y=mtcars[,2], z=mtcars[,10]) pts[which(unlist(lapply(pts, function(x) sum(x==4)0)))] pts[sapply(pts, function(x) sum(x==4)0)] will gladly do the same. vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Diff btw percentile and quantile
megh megh74 at yahoo.com writes: To calculate Percentile for a set of observations Excel has percentile() function. R function quantile() does the same thing. Is there any significant difference btw percentile and quantile? If you check the documentation of quantile, you will note that there are 9 variants of quantile which may give different values for small sample sizes and many ties. I found a German page that explains the algorithm Excel uses: http://www.excel4managers.de/index.php?page=quantile01 but I did not check if which of the R-variants this is equivalent to. 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] R: flaw in CRAN package wavelets: Daubechies d8 not recognized by function wt.filter
download the source tarball - everything should be in there. On Wed, Mar 4, 2009 at 5:15 AM, mau...@alice.it wrote: Thank you. I do not know where the source code is available.I never uploaded anything to CRAN. I am just an R user so far. Can you please tell me ? I did notify the package maintainer mentioned in the package on-line documentation, namely Eric Aldrich eldr...@gmail.com, twice. I suspect hic contact information is obsolete because he never got back to me or the R forum. Moreover, his web site does not exist and his name cannot be found in the University of Washington directory. Best regards, Maura -Messaggio originale- Da: David Winsemius [mailto:dwinsem...@comcast.net] Inviato: mer 04/03/2009 7.20 A: mau...@alice.it Cc: r-help@r-project.org; eldr...@gmail.com Oggetto: Re: [R] flaw in CRAN package wavelets: Daubechies d8 not recognized by function wt.filter You can look at the code yourself. The d8 filter appears to have a deletion mutation making it different than the other d-series and the fix looks feasible for testing: d6.filter - function(mod = F) { class - Daubechies name - d6 L - as.integer(6) g - c(0.332670552950083, 0.806891509311093, 0.459877502118491, -0.135011020010255, -0.0854412738820267, 0.0352262918857096) if (modwt == TRUE) { g - g/sqrt(2) transform - modwt } else transform - dwt h - wt.filter.qmf(g, inverse = TRUE) wt.filter - new(wt.filter, L = L, h = h, g = g, wt.class = class, wt.name = name, transform = transform) return(wt.filter) } d8.filter - function(mod = F) { class - Daubechies name - d8 L - as.integer(8) g - c(0.230377813307443, 0.714846570548406, 0.630880767935879, -0.0279837694166834, -0.187034811717913, 0.0308413818353661, 0.032883011778, -0.0105974017850021) missing code h - wt.filter.qmf(g, inverse = TRUE) wt.filter - new(wt.filter, L = L, h = h, g = g, wt.class = class, wt.name = name, transform = transform) return(wt.filter) } d10.filter - function(mod = F) { class - Daubechies name - d10 L - as.integer(10) g - c(0.160102397974193, 0.60382926979719, 0.724308528437773, 0.138428145901320, -0.242294887066382, -0.0322448695846381, 0.0775714938400459, -0.0062414902127983, -0.012580751999082, 0.0033357252854738) if (modwt == TRUE) { g - g/sqrt(2) transform - modwt } else transform - dwt h - wt.filter.qmf(g, inverse = TRUE) wt.filter - new(wt.filter, L = L, h = h, g = g, wt.class = class, wt.name = name, transform = transform) return(wt.filter) } Make your own wt.filter with the missing code inserted and see if happiness prevails.When I apply the fix, I get: wt.filter(d8) An object of class wt.filter Slot L: [1] 8 Slot level: [1] 1 Slot h: [1] -0.01059740 -0.03288301 0.03084138 0.18703481 -0.02798377 -0.63088077 0.71484657 -0.23037781 Slot g: [1] 0.23037781 0.71484657 0.63088077 -0.02798377 -0.18703481 0.03084138 0.03288301 -0.01059740 Slot wt.class: [1] Daubechies Slot wt.name: [1] d8 Slot transform: [1] dwt By the way, there also appears to be no d2 and calling wt.filter with d2 also provokes an error. The proper manner for getting this addressed is to draw it to the attention of the package maintainer rather than posting a to whom it may concern message to the list. -- David Winsemius On Mar 4, 2009, at 12:36 AM, mau...@alice.it mau...@alice.it wrote: wt.filter(d8) HOW COME Error in validObject(.Object) : invalid class wt.filter object: invalid object for slot transform in class wt.filter: got class function, should be or extend class character wt.filter(d10) # OK An object of class “wt.filter” Slot L: [1] 10 wt.filter(d6) #OK An object of class “wt.filter” Slot L: [1] 6 Thank you in advance to anyone who takes care of reported bugs in CRAN packages. Maura tutti i telefonini TIM! [[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. tutti i telefonini TIM! [[alternative HTML version deleted]] __
Re: [R] reading scanned graphs
Frank E Harrell Jr f.harrell at vanderbilt.edu writes: For Linux I recommend the engauge-digitizer package. It's Java and works under Windows. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] dotplot
Hi,I would like to fill the dots in this graph. I would appreciate help to do that if possible. If fill is not possible, can I make it bright? I do NOT want to increase the size. __ dotplot(hu.event~fitted.adj.cat,data=risk.benefit.cast,groups=treat, auto.key=list(space=right)) -- Thanks. Chetty -- Professor of Family Medicine Boston University Tel: 617-414-6221, Fax:617-414-3345 emails: chett...@gmail.com,vche...@bu.edu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Selecting one row or multiple rows per ID
On Wed, Mar 4, 2009 at 12:09 AM, Vedula, Satyanarayana sved...@jhsph.edu wrote: Hi, Could someone help with coding this in R? I need to select one row per patient i in clinic j. The data is organized similar to that shown below. Two columns - patient i in column j identify each unique patient. There are two columns on outcome. Some patients have multiple rows with each row representing one visit, coded for in the column, visit. Some patients have just one row indicating data from a single visit. I need to select one row per patient i in clinic j using the following algorithm: If patient has outcome recorded at visit 2, then outcome = outcome columns at visit 2 If patient does not have visit 2, then outcome = outcome at visit 5 If patient does not have visit 2 and visit 5, then outcome = outcome at visit 4 If patient does not have visits 2, 5, and 4, then outcome = outcome at visit 3 If patient does not have visits 2, 5, 4, and 3, then outcome = outcome at visit 1 If patient does not have any of the visits, outcome = missing Patient Clinic Visit Outcome_left Outcome_right patient 1 clinic 1 visit 2 22 21 patient 1 clinic 3 visit 1 21 21 patient 1 clinic 3 visit 2 21 22 patient 1 clinic 3 visit 3 20 22 patient 3 clinic 5 visit 1 24 21 patient 3 clinic 5 visit 3 21 22 patient 3 clinic 5 visit 4 22 23 patient 3 clinic 5 visit 5 22 22 I need to select just the first row for patient 1/clinic 1; the second row (visit 2) for patient 1/clinic 3; and the fourth row (visit 5) for patient 3/clinic 5. I'd approach this problem in the following way: df - read.csv(textConnection( Patient,Clinic,Visit,Outcome_left,Outcome_right patient 1,clinic 1,visit 2,22,21 patient 1,clinic 3,visit 1,21,21 patient 1,clinic 3,visit 2,21,22 patient 1,clinic 3,visit 3,20,22 patient 3,clinic 5,visit 1,24,21 patient 3,clinic 5,visit 3,21,22 patient 3,clinic 5,visit 4,22,23 patient 3,clinic 5,visit 5,22,22 ), header = T) closeAllConnections() # With a single patient it's pretty easy to find the preferred visit preferred_visit - paste(visit, c(2, 5, 4, 3, 1)) one - subset(df, Patient == patient 3 Clinic == clinic 5) best_visit - na.omit(match(preferred_visit, one$Visit))[1] one[best_visit, ] # We then turn this into a function find_best_visit - function(one) { best_visit - na.omit(match(preferred_visit, one$Visit))[1] one[best_visit, ] } # Then apply it to every combination of patient and clinic with plyr ddply(df, .(Patient, Clinic), find_best_visit) # You can learn more about plyr at http://had.co.nz/plyr 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.
[R] how to estimate distribution?
Dear R-Experts, I have an empirical dataset with 150 subjects for 24 observations. In each observation, each subject can have a score in the range 0:3. I made then a simple index making the sum of the values in each row, so each subject have a score between 0 and 72. I was thinking about what kind of theoretical distribution such an index should have, so I try to make things random like: data-array(0,c(150,24)) data2-array(0, c(150, 100)) for (prova in 1:100){ for (i in 1:24){ for (q in 1:150){ data[q,i]-sample(0:3, 1) } } for (riga in 1:150){ data2[riga,prova]-sum(data[riga,]) } } now here you can find the plotted theoretical values (black) against the empirical ones (red): http://www.digitaldust.it/papers/indice.png How can I estimate the density of both distribution? because the red one looks like a pareto distribution, but I am not an expert... many thanks, Simone __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dotplot
Hi, I think you need to set the parameter pch to 19. - pch=19: solid circle, - pch=20: bullet (smaller circle), - pch=21: circle, - pch=22: square, - pch=23: diamond, - pch=24: triangle point-up, - pch=25: triangle point down. Regards 2009/3/4 Veerappa Chetty chett...@gmail.com Hi,I would like to fill the dots in this graph. I would appreciate help to do that if possible. If fill is not possible, can I make it bright? I do NOT want to increase the size. __ dotplot(hu.event~fitted.adj.cat,data=risk.benefit.cast,groups=treat, auto.key=list(space=right)) -- Thanks. Chetty -- Professor of Family Medicine Boston University Tel: 617-414-6221, Fax:617-414-3345 emails: chett...@gmail.com,vche...@bu.edu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with integration
Dear all, I have a problem with the integration of the following function. Could you please give some suggestions? Thank you very much!!! y-rnorm(n=100) f-function(x,xi,h){ n-length(xi) Ke-c() for(t in 1:n) { Ke[t]-dnorm((x-xi[t])/h) } fke-sum(Ke)*(1/(n*h)) fke-fke^2 return(fke) } integrate(f,-Inf,Inf,xi=y,h=0.32) I obtained this error: evaluation of function gave a result of wrong length In addition: There were 50 or more warnings (use warnings() to see the first 50) 50: In Ke[t] - dnorm((x - xi[t])/h) : number of items to replace is not a multiple of replacement length __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Filtering R lists
Many thanks for all your suggestions - much appreciated! Nikol __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] arima additive vs multiplicative seasonality
Hello! I would like to ask whether the seasonality implemented in arima() is additive or multiplicative? I searched a lot, but I could not find an answer to that question, although it has been asked other times too. Thank you very much for your attention. Regards, Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R under Citrix and access to Lotus notes
Dear All, 1. Does anyone have experience of running R on a server inside a Citrix shell - I'd like to get R onto the server and would be greatful for any tips or direction on the matter. 2. This may seem like a silly question so forgive my ignornace. Most of the data I currently work with is held on a number of Lotus Notes (LN) Databases (well it's called a DB here but it's really a document management system) and in this environment I have to export files to text and then read the file. Is it possible to access LN tables directly using R - has anyone tried or is there a package that'll help? thanks Gerard ** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. It is the policy of the Department of Justice, Equality and Law Reform and the Agencies and Offices using its IT services to disallow the sending of offensive material. Should you consider that the material contained in this message is offensive you should contact the sender immediately and also mailminder[at]justice.ie. Is le haghaidh an duine nó an eintitis ar a bhfuil sí dírithe, agus le haghaidh an duine nó an eintitis sin amháin, a bheartaítear an fhaisnéis a tarchuireadh agus féadfaidh sé go bhfuil ábhar faoi rún agus/nó faoi phribhléid inti. Toirmisctear aon athbhreithniú, atarchur nó leathadh a dhéanamh ar an bhfaisnéis seo, aon úsáid eile a bhaint aisti nó aon ghníomh a dhéanamh ar a hiontaoibh, ag daoine nó ag eintitis seachas an faighteoir beartaithe. Má fuair tú é seo trí dhearmad, téigh i dteagmháil leis an seoltóir, le do thoil, agus scrios an t-ábhar as aon ríomhaire. Is é beartas na Roinne Dlí agus Cirt, Comhionannais agus Athchóirithe Dlí, agus na nOifígí agus na nGníomhaireachtaí a úsáideann seirbhísí TF na Roinne, seoladh ábhair cholúil a dhícheadú. Más rud é go measann tú gur ábhar colúil atá san ábhar atá sa teachtaireacht seo is ceart duit dul i dteagmháil leis an seoltóir láithreach agus le mailminder[ag]justice.ie chomh maith. *** __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with integration
andrea.tor...@apat.it wrote: Dear all, I have a problem with the integration of the following function. Could you please give some suggestions? Thank you very much!!! y-rnorm(n=100) f-function(x,xi,h){ n-length(xi) Ke-c() for(t in 1:n) { Ke[t]-dnorm((x-xi[t])/h) } fke-sum(Ke)*(1/(n*h)) fke-fke^2 return(fke) } integrate(f,-Inf,Inf,xi=y,h=0.32) integrate expects to work on a function f that works on a vector of x values (rather than just a scalar x), hence you probably want (somewhat rewritten): f - function(x, xi, h){ n - length(xi) Ke - dnorm((x - xi) / h) fke - sum(Ke) * (1 / (n*h)) return(fke^2) } f2 - function(x,xi,h){ sapply(x, f, xi = xi, h = h) } integrate(f2, -Inf, Inf, xi=y, h=0.32) Uwe Ligges I obtained this error: evaluation of function gave a result of wrong length In addition: There were 50 or more warnings (use warnings() to see the first 50) 50: In Ke[t] - dnorm((x - xi[t])/h) : number of items to replace is not a multiple of replacement length __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] R: flaw in CRAN package wavelets: Daubechies d8 not recognized by function wt.filter
To see the code (in this case at any rate) you just type the name of the function. I produced a snippet from what appeared on my screen. I then copy-pasted to a text-editor, copy-pasted the missing section to the d8 segment and assigned the to to wt.filter, which effectively overwrote the original and made the new code the working one. The source of the code will be in the R libraries and is brought in from those files at the time the package is loaded. Given that the code is just text you can fix it yourself. I just added the missing code to a local copy, but a more durable fix would be to edit the files. The process of getting code when the functions are S3 or S4 functions is a bit more complex but there is a very helpful RNews article on that topic. Regarding no response from the author/maintainer: I am not sure you have given the process sufficient time. Perhaps he is on holiday or will reply when he gets a free moment. -- David Winsemius On Mar 4, 2009, at 5:15 AM, mau...@alice.it wrote: Thank you. I do not know where the source code is available.I never uploaded anything to CRAN. I am just an R user so far. Can you please tell me ? I did notify the package maintainer mentioned in the package on-line documentation, namely Eric Aldrich eldr...@gmail.com, twice. I suspect hic contact information is obsolete because he never got back to me or the R forum. Moreover, his web site does not exist and his name cannot be found in the University of Washington directory. Best regards, Maura -Messaggio originale- Da: David Winsemius [mailto:dwinsem...@comcast.net] Inviato: mer 04/03/2009 7.20 A: mau...@alice.it Cc: r-help@r-project.org; eldr...@gmail.com Oggetto: Re: [R] flaw in CRAN package wavelets: Daubechies d8 not recognized by function wt.filter You can look at the code yourself. The d8 filter appears to have a deletion mutation making it different than the other d-series and the fix looks feasible for testing: d6.filter - function(mod = F) { class - Daubechies name - d6 L - as.integer(6) g - c(0.332670552950083, 0.806891509311093, 0.459877502118491, -0.135011020010255, -0.0854412738820267, 0.0352262918857096) if (modwt == TRUE) { g - g/sqrt(2) transform - modwt } else transform - dwt h - wt.filter.qmf(g, inverse = TRUE) wt.filter - new(wt.filter, L = L, h = h, g = g, wt.class = class, wt.name = name, transform = transform) return(wt.filter) } d8.filter - function(mod = F) { class - Daubechies name - d8 L - as.integer(8) g - c(0.230377813307443, 0.714846570548406, 0.630880767935879, -0.0279837694166834, -0.187034811717913, 0.0308413818353661, 0.032883011778, -0.0105974017850021) missing code h - wt.filter.qmf(g, inverse = TRUE) wt.filter - new(wt.filter, L = L, h = h, g = g, wt.class = class, wt.name = name, transform = transform) return(wt.filter) } d10.filter - function(mod = F) { class - Daubechies name - d10 L - as.integer(10) g - c(0.160102397974193, 0.60382926979719, 0.724308528437773, 0.138428145901320, -0.242294887066382, -0.0322448695846381, 0.0775714938400459, -0.0062414902127983, -0.012580751999082, 0.0033357252854738) if (modwt == TRUE) { g - g/sqrt(2) transform - modwt } else transform - dwt h - wt.filter.qmf(g, inverse = TRUE) wt.filter - new(wt.filter, L = L, h = h, g = g, wt.class = class, wt.name = name, transform = transform) return(wt.filter) } Make your own wt.filter with the missing code inserted and see if happiness prevails.When I apply the fix, I get: wt.filter(d8) An object of class wt.filter Slot L: [1] 8 Slot level: [1] 1 Slot h: [1] -0.01059740 -0.03288301 0.03084138 0.18703481 -0.02798377 -0.63088077 0.71484657 -0.23037781 Slot g: [1] 0.23037781 0.71484657 0.63088077 -0.02798377 -0.18703481 0.03084138 0.03288301 -0.01059740 Slot wt.class: [1] Daubechies Slot wt.name: [1] d8 Slot transform: [1] dwt By the way, there also appears to be no d2 and calling wt.filter with d2 also provokes an error. The proper manner for getting this addressed is to draw it to the attention of the package maintainer rather than posting a to whom it may concern message to the list. -- David Winsemius On Mar 4, 2009, at 12:36 AM, mau...@alice.it mau...@alice.it wrote: wt.filter(d8) HOW COME Error in validObject(.Object) : invalid class wt.filter object:
Re: [R] Inference for R Spam
Rolf == Rolf Turner r.tur...@auckland.ac.nz writes: On 4/03/2009, at 11:50 AM, Michael A. Miller wrote: Sports scores are not statistics, they are measurements (counts) of the number of times each team scores. There is no sampling and vanishingly small possibility of systematic error in the measurement. I think this comment indicates a fundamental misunderstanding of the nature of statistics in general and the concept of variability in particular. Measurement error is only *one possible* source of variability and is often a minor --- or as in the case of sports scores a non-existent --- source. Would you elaborate Rolf? I'm was referring to measurements, not statistics. Isn't calling scores statistics similar to saying that the values of some response in an individual subject before and after treatment are statistics? I think they are just measured values and that if they are measured accurately enough, they can be precisely known. It is in considering the distribution of similar measurements obtained in repeated trials that statistics come into play. From my perspective as a baseball fan (I know I'm in Indiana and I aught to be more of a basketball fan, but I grew up as a Cubs watcher and still can't shake it), it doesn't seem to me that the purpose of the score is to allow for some inference about the overall population of teams. It is about which team beats the other one and entertainment (and hot dogs) for the fans. Mike -- Michael A. Miller mmill...@iupui.edu Department of Radiology, Indiana University School of Medicine __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Inefficiency of SAS Programming
Dear Ajay, just to deny the implicit statement 'corporate user'='moron' surfacing here and there in this interesting thread :^). This might be a statistical regularity but should by no means be considered a theorem, as there are counter-examples available. You can find people willing to learn both languages, appreciate the difference between them and use each where it is particularly strong even in corporations and burosaurs of any kind. IMVHO, acceptance of R in the corporate world has little to do with syntax and much with legacies, (discharge of-) responsibilities and the distance between the decision maker/buyer and those who are actually working with the SW. Else, assuming that 'corporate users' are not at a significant cerebral disadvantage (which I like to), the penetration of R in education, small and large companies should be the same, which I'm afraid is not. So I believe it boils down to industrial organization and the open source vs. commercial development model, rather than to some kind of (more or less appropriate) function rebranding. It is the *difference* in syntax w.r.t. SAS that prompted the shift to R, in my case at least. It was its ease and 'cleanliness' of installation (no registry entries, no access to forbidden directories required) which allowed me to experiment with it without having to mess with the IT Dept. (which would probably have put an end to my quest). It was its open source nature that allowed me to install it anywhere I liked to. My 2 Euro-Cents Giovanni Disclaimer: just thinking of the Proc Step gives me shivers; yet I recognize SAS is fast and powerful. I could understand somebody wanting to execute SAS through R syntax, but the opposite is beyond my grasp. -- Message: 72 Date: Wed, 4 Mar 2009 08:44:51 +1300 From: Rolf Turner r.tur...@auckland.ac.nz Subject: Re: [R] Inefficiency of SAS Programming To: Ajay ohri ohri2...@gmail.com Cc: r-help-boun...@r-project.org r-help-boun...@r-project.org, Gerard M. Keogh gmke...@justice.ie, list r-h...@stat.math.ethz.ch, R, Greg Snow greg.s...@imail.org Message-ID: 8993cba0-46a3-41de-abbb-29db205fb...@auckland.ac.nz Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On 3/03/2009, at 5:58 PM, Ajay ohri wrote: for an inefficient language , it sure has dominated the predictive analytics world for 3 plus decades. I referred once to intellectual jealousy between newton and liebnitz. i am going ahead and creating the R package called Anne. It basically is meant only for SAS users who want to learn R , without upsetting the schedule of the corporate users. Simply put , it is a wrapper on SAS language using the function command...ie procunivariate function in Anne package would call the summary function and so on... Reminds me of fortune(38). cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:13}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to generate fake population (ie. not sample) data?
-Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: Wednesday, March 04, 2009 3:17 AM To: Daniel Nordlund Cc: r-help@r-project.org Subject: Re: [R] How to generate fake population (ie. not sample) data? On Wed, Mar 4, 2009 at 2:48 AM, Daniel Nordlund djnordl...@verizon.net wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of CB Sent: Tuesday, March 03, 2009 10:05 PM To: David Winsemius Cc: r-help@r-project.org Subject: Re: [R] How to generate fake population (ie. not sample) data? My understanding is that rnorm(n, x, s) will give me an n-sized sample from an (x, s) normal distribution. So the vector returned will have a mean from the sampling distribution of the mean. But what I want is a set of n numbers literally with a mean of x and sd of s. I am at the very beginning of my R journey, so my apologies if this is a particularly naive enquiry. 2009/3/4 David Winsemius dwinsem...@comcast.net: In what ways is rnorm not a satisfactory answer? -- David Winsemius On Mar 3, 2009, at 9:33 PM, CB wrote: This seems like it should be obvious, but searches I've tried all come up with rnorm etc. Is there a way of generating normally-distributed 'population' data with known parameters? Cheers, CB. Something like this may help get you started. std.pop - function(x,mu,stdev){ ((x-mean(x))/sd(x)*stdev)+mu } Note the scale function, i.e. the above can also be written: stdev * scale(x) + mu Gabor, Thanks for pointing out the scale() function for the OP. I suspected that something like that existed, but in a (very) quick look around didn't find it. Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Diff btw percentile and quantile
Yes, I aware of those definitions. However I wanted to know the difference btw the words Percentile and quantile, if any. Secondly your link navigates to some non-english site, which I could not understand. Dieter Menne wrote: megh megh74 at yahoo.com writes: To calculate Percentile for a set of observations Excel has percentile() function. R function quantile() does the same thing. Is there any significant difference btw percentile and quantile? If you check the documentation of quantile, you will note that there are 9 variants of quantile which may give different values for small sample sizes and many ties. I found a German page that explains the algorithm Excel uses: http://www.excel4managers.de/index.php?page=quantile01 but I did not check if which of the R-variants this is equivalent to. 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. -- View this message in context: http://www.nabble.com/Diff-btw-percentile-and-quantile-tp22328375p22333142.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lattice: remove box around a wireframe
#Hi, # #somebody knows how to remove the outer box around a wireframe and reduce the height # # test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c(x, y, z) require(lattice) wireframe(z ~ x*y, data = test, par.box = c(col = transparent) ) #not this one but the remaining outer box. Thanks in advance Thomas Roth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Diff btw percentile and quantile
On 04-Mar-09 16:10:29, megh wrote: Yes, I aware of those definitions. However I wanted to know the difference btw the words Percentile and quantile, if any. Secondly your link navigates to some non-english site, which I could not understand. Percentile and quantile are in effect the same thing. The difference is in how they express what they refer to. For example, the Median of a distribution is the 0.5 Quantile, and is the 50% percentile. So, for 0 = p = 1, refer to either the p-th quantile, or to the (100*p)-th percentile. Thus R has the function quantile(), whose ?quantile states: The generic function 'quantile' produces sample quantiles corresponding to the given probabilities. The smallest observation corresponds to a probability of 0 and the largest to a probability of 1. R (in its basic distribution) does now have a function percentile(), but, given a series P of percentages, e.g. P - c(1,5,10,25,50,75,90,95,99) one could obtain the equivalent as quantile(X,probs=P/100). So, with reference to your original question Excel has percentile() function. R function quantile() does the same thing. Is there any significant difference btw percentile and quantile? the answer is that they in effect give the same results, though differ with respect to how they are to be fed (quantile eats probabilities, percentile eats percentages). [Though (since I am not familiar with Excel) I cannot rule out that Excel's percentile() function also eats probabilities; in which case its name would be an example of sloppy nomenclature on Excel's part; which I cannot rule out on general grounds either]. Ted. Dieter Menne wrote: megh megh74 at yahoo.com writes: To calculate Percentile for a set of observations Excel has percentile() function. R function quantile() does the same thing. Is there any significant difference btw percentile and quantile? If you check the documentation of quantile, you will note that there are 9 variants of quantile which may give different values for small sample sizes and many ties. I found a German page that explains the algorithm Excel uses: http://www.excel4managers.de/index.php?page=quantile01 but I did not check if which of the R-variants this is equivalent to. Dieter E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 04-Mar-09 Time: 16:31:42 -- 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] Error in -class : invalid argument to unary operator
Hi guys I have been using R for a few months now and have come across an error that I have been trying to fix for a week or so now.I am trying to build a classifer that will classify the wine dataset using Naive Bayes. My code is as follows library (e1071) wine- read.csv(C:\\Rproject\\Wine\\wine.csv) split-sample(nrow(wine), floor(nrow(wine) * 0.5)) wine_training - wine[split, ] wine_testing - iris[-split, ] naive_bayes -naiveBayes(class~.,data=wine_training) x_testing - subset(wine_testing, select = -class) y_testing - wine_testing$class # just grab Species variable of iris_training pred - predict(naive_bayes, x_testing) tab-table(pred, y_testing) ca - classAgreement(tab) print(tab) print(ca) when I enter this code in I get the error Error in -class : invalid argument to unary operator If anybody could give me anysort of advice this would be most welcome,Thanks -- View this message in context: http://www.nabble.com/Error-in--class-%3A-invalid-argument-to-unary-operator-tp22333600p22333600.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] adding value labels on Interaction Plot
Hello - and sorry for what might look like a simple graphics question. I am building an interaction plot for d: d=data.frame(xx=c(3,3,2,2,1,1),yy=c(4,3,4,3,4,3),zz=c(5.1,4.4,3.5,3.3,-1.1,-1.3)) d[[1]]-as.factor(d[[1]]) d[[2]]-as.factor(d[[2]]) print(d) interaction.plot(d$xx, d$yy, d$zz, type=b, col=c(red,blue), legend=F, lty=c(1,2), lwd=2, pch=c(18,24), xlab=X Label, ylab=Y Label, main=Chart Label) I am trying and not succeeding in adding Y values (value labels in Excel speak) near the data points on 3 lines of the graph. I understand that I might have to use text. But how do I tell text to use the actual coordinates of the dots on the lines? Thank you very much! -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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] Diff btw percentile and quantile
(Ted Harding) wrote: snip So, with reference to your original question Excel has percentile() function. R function quantile() does the same thing. Is there any significant difference btw percentile and quantile? the answer is that they in effect give the same results, though differ with respect to how they are to be fed (quantile eats probabilities, percentile eats percentages). [Though (since I am not familiar with Excel) I cannot rule out that Excel's percentile() function also eats probabilities; in which case its name would be an example of sloppy nomenclature on Excel's part; which I cannot rule out on general grounds either]. i am not familiar enough with excel to prove or disprove what you say above, but in general such claims should be grounded in the respective documentations. there are a number of ways to compute empirical quantiles (see, e.g., [1]), and it's possible that the one used by r's quantile by default (see ?quantile) is not the one used by excel (where you probably have no choice; help in oocalc does not specify the method, and i guess that excel's does not either). have you actually confirmed that excel's percentile() does the same as r's quantile() (modulo the scaling)? vQ [1] http://www.jstor.org/stable/2684934 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] readline in vi mode on OSX
Hi All, This is a slightly arcane question, but I'm wondering if anyone else uses vi mode with R? On my platform, across several versions, there is some broken behaviour. When executing commands like 'df)' (to delete up to the next bracket) the cursor moves to the next ), but nothing is deleted. In general, many delete/replace commands work only as movement. Has anyone else come across this, and if so, did you find a fix? The same commands work correctly on the command line, so I'm assuming R has it's own built in version of readline, which is causing problems. I'm currently running R2.8.1 on OSX 10.5.6, but the bug has been there for both R and OSX upgrades. It isn't present on Linux. Cheers, dave -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lattice: remove box around a wireframe
(Sorry for the repeat. Forgot to copy R-help) Try, test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c(x, y, z) require(lattice) wireframe(z ~ x*y, data = test, par.settings = list(axis.line = list(col = transparent)), par.box = c(col = transparent) ) --sundar On Wed, Mar 4, 2009 at 8:17 AM, Thomas Roth (geb. Kaliwe) hamstersqu...@web.de wrote: #Hi, # #somebody knows how to remove the outer box around a wireframe and reduce the height # # test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c(x, y, z) require(lattice) wireframe(z ~ x*y, data = test, par.box = c(col = transparent) ) #not this one but the remaining outer box. Thanks in advance Thomas Roth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] behavior of squishplot in TeachingDemos
Thank you for finding this. Yes in some cases the parameter settings need to be updated by a call to plot.new for the calculations to be correct (if you carried out your example 2 more times you would see that the 3rd plot is also incorrect since it is still using the dimensions of the 2nd plot in the calculations). I have added a call to plot.new inside of the squishplot function for the next version, but until that comes out (I have been meaning to get it out for a while, but don't have a specific time frame) the work around that you found of calling plot.new before squishplot is the best thing to do. Thanks, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Stephen Tucker Sent: Tuesday, March 03, 2009 9:17 AM To: r-help@r-project.org Subject: [R] behavior of squishplot in TeachingDemos Hi list, I wonder if anyone has had this experience with squishplot() in the TeachingDemos package. Taking the example from the ?image help page, library(TeachingDemos) x - 10*(1:nrow(volcano)) y - 10*(1:ncol(volcano)) layout(matrix(c(1,2,3,4),ncol=2,byrow=TRUE),height=c(2,1)) ## 1st plot op - squishplot(range(x),range(y),1) image(x, y, volcano, col = terrain.colors(100)) par(op) ## 2nd plot op - squishplot(range(x),range(y),1) image(x, y, volcano, col = terrain.colors(100)) par(op) The second plot comes out looking as expected, but the first plot is not squished in the desired proportions. I tried tracking the modifications to par('pin') and par('plt') in the function but gave up midway through in desire for haste - not sure what is going on but I did find that taking advantage of the behavior above, calling plot.new(); par(new=TRUE) before the first plot makes things work as expected. So the full code would be layout(matrix(c(1,2,3,4),ncol=2,byrow=TRUE),height=c(2,1)) ## 1st plot op - squishplot(range(x),range(y),1) plot.new() par(new=TRUE) image(x, y, volcano, col = terrain.colors(100)) par(op) ## 2nd plot op - squishplot(range(x),range(y),1) image(x, y, volcano, col = terrain.colors(100)) par(op) +++ I wonder if this behavior is not surprising? It is a great function overall though - thanks for the contribution. Stephen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Diff btw percentile and quantile
On 04-Mar-09 16:56:14, Wacek Kusnierczyk wrote: (Ted Harding) wrote: snip So, with reference to your original question Excel has percentile() function. R function quantile() does the same thing. Is there any significant difference btw percentile and quantile? the answer is that they in effect give the same results, though differ with respect to how they are to be fed (quantile eats probabilities, percentile eats percentages). [Though (since I am not familiar with Excel) I cannot rule out that Excel's percentile() function also eats probabilities; in which case its name would be an example of sloppy nomenclature on Excel's part; which I cannot rule out on general grounds either]. i am not familiar enough with excel to prove or disprove what you say above, but in general such claims should be grounded in the respective documentations. there are a number of ways to compute empirical quantiles (see, e.g., [1]), and it's possible that the one used by r's quantile by default (see ?quantile) is not the one used by excel (where you probably have no choice; help in oocalc does not specify the method, and i guess that excel's does not either). have you actually confirmed that excel's percentile() does the same as r's quantile() (modulo the scaling)? vQ I have now googled around a bit. All references to the Excel percentile() function say that you feed it the fractional value corresponding to the percentage. So, for example, to get the 80-th percentile you would give it 0.8. Hence Excel should call it quantile! As to the algorithm, Wikipedia states the following (translated into R syntax): Many software packages, such as Microsoft Excel, use the following method recommended by NIST[4] to estimate the value, vp, of the pth percentile of an ascending ordered dataset containing N elements with values v[1],v[2],...,v[N]: n = (p/100)*(N-1) + 1 n is then split into its integer component, k and decimal component, d, such that n = k + d. If k = 1, then the value for that percentile, vp, is the first member of the ordered dataset, v[1]. If k = N, then the value for that percentile, vp, is the Nth member of the ordered dataset, v[N]. Otherwise, 1 k N and vp = v[k] + d*(v[k + 1] - v[k]). Note that the Wikipedia article uses the % interpretation of p-th percentile, i.e. the point which is (p/100) of the way along the distribution. It looks as though R's quantile with type=4 might be the same, since it is explained as linear interpolation of the empirical cdf, which is what the above description of Excel's method does. However, R's default type is 7, which is different. Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 04-Mar-09 Time: 17:29:50 -- 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] regular expression question
Here is another approach that still uses strspit if you want to stay with that: tmp - '(-0.791,-0.263].(-38,-1.24].(0.96,2.43]' strsplit(tmp, '\\.(?=\\()', perl=TRUE) [[1]] [1] (-0.791,-0.263] (-38,-1.24] (0.96,2.43] This uses the Perl 'look-ahead' indicator to say only match on a period that is followed by a '(', but don't include the '(' in the match. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of markle...@verizon.net Sent: Monday, March 02, 2009 11:17 PM To: r-help@r-project.org Subject: [R] regular expression question can someone show me how to use a regular expression to break the string at the bottom up into its three components : (-0.791,-0.263] (-38,-1.24] (0.96,2.43] I tried to use strplit because of my regexpitis ( it's not curable. i've been to many doctors all over NYC. they tell me there's no cure ) but it doesn't work because there also dots inside the brackets. Thanks. (-0.791,-0.263].(-38,-1.24].(0.96,2.43] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] lattice: remove box around a wireframe
:-) works! Sundar Dorai-Raj schrieb: (Sorry for the repeat. Forgot to copy R-help) Try, test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c(x, y, z) require(lattice) wireframe(z ~ x*y, data = test, par.settings = list(axis.line = list(col = transparent)), par.box = c(col = transparent) ) --sundar On Wed, Mar 4, 2009 at 8:17 AM, Thomas Roth (geb. Kaliwe) hamstersqu...@web.de wrote: #Hi, # #somebody knows how to remove the outer box around a wireframe and reduce the height # # test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c(x, y, z) require(lattice) wireframe(z ~ x*y, data = test, par.box = c(col = transparent) ) #not this one but the remaining outer box. Thanks in advance Thomas Roth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] dividing time series of different frequencies
Hello, I have two time series objects, 1 is yearly (population) and the other is quarterly (bankruptcy statistics). I would like to produce a quarterly time series object that consists of bankruptcy/population. Is there a pre-built function to intelligently divide these time series. The series I want is: br2001Q1/pop2001 , br2001Q2/pop2001, br2001Q3/pop2001, br2001Q4/pop2001, br2002Q1/pop2001, br2002Q2/pop2002, etc. This would not be too difficult to write but does anything like this already exist? -stephen [[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] regular expression question
Greg Snow wrote: Here is another approach that still uses strspit if you want to stay with that: tmp - '(-0.791,-0.263].(-38,-1.24].(0.96,2.43]' strsplit(tmp, '\\.(?=\\()', perl=TRUE) [[1]] [1] (-0.791,-0.263] (-38,-1.24] (0.96,2.43] This uses the Perl 'look-ahead' indicator to say only match on a period that is followed by a '(', but don't include the '(' in the match. right; you could extend this pattern to split the string by every dot that does not separate two digits, for example: strsplit(tmp, '(?!\\d)\\.(?!\\d)', perl=TRUE) of course, this fails if there are numbers without a leading zero, e.g., .11 vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Unrealistic dispersion parameter for quasibinomial
For the record residuals(model) 1 2 3 4 5 5.55860143 -0.00073852 2.49255235 -1.41987341 -0.00042425 6 7 8 -0.94389158 2.72987046 -1.15760836 residuals(model, pearson) 1 2 3 4 5 3.5362e+03 -5.e-04 2.3366e+00 -1.0080e+00 -2.e-04 6 7 8 -8.8378e-01 2.4038e+00 -1.1646e+00 fitted(model) 1 2 3 4 5 1.5994e-08 5.0502e-09 4.9946e-01 1.5873e-02 3.2140e-09 6 7 8 2.0924e-02 8.0191e-01 6.1900e-01 so according to the model a very rare event occurred. That is what is 'unrealistic' (and Ben Bolker supposed correctly). How dispersion should be estimated is a matter of some debate (see e.g. McCullagh and Nelder), but the model here is simply inadequate. On Mon, 2 Mar 2009, Menelaos Stavrinides wrote: I am running a binomial glm with response variable the no of mites of two species y-cbind(mitea,miteb) against two continuous variables (temperature and predatory mites) - see below. My model shows overdispersion as the residual deviance is 48.81 on 5 degrees of freedom. If I use quasibinomial to account for overdispersion the dispersion parameter estimate is 2501139, which seems unrealistic. Any ideas as to why I am getting such a huge dispersion parameter? y-cbind(psmno,wsmno) ldhours-log(idhours+1) lwpm-log(wpm2wkb+1) y psmno wsmno [1,] 1 4 [2,] 054 [3,] 8 1 [4,] 063 [5,] 028 [6,] 4 291 [7,]46 3 [8,] 11785 ldhours [1] 0.00 2.308567 5.078473 4.875035 2.339399 3.723039 5.572344 5.250384 lwpm [1] 0.6931472 2.1972246 0.000 0.6931472 2.3025851 0.000 0.000 [8] 0.000 model-glm(y~ldhours+lwpm,binomial) summary(model) Call: glm(formula = y ~ ldhours + lwpm, family = binomial) Deviance Residuals: 1 2 3 4 5 6 5.5586025 -0.0007385 2.4925511 -1.4198734 -0.0004242 -0.9438916 7 8 2.7298663 -1.1576062 Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept) -14.4029 1.3705 -10.509 2e-16 *** ldhours 2.8357 0.2656 10.677 2e-16 *** lwpm -5.1188 1.4689 -3.485 0.000492 *** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 441.20 on 7 degrees of freedom Residual deviance: 48.81 on 5 degrees of freedom AIC: 70.398 Number of Fisher Scoring iterations: 8 model2-glm(y~ldhours+lwpm,quasibinomial) summary(model2) Call: glm(formula = y ~ ldhours + lwpm, family = quasibinomial) Deviance Residuals: 1 2 3 4 5 6 5.5586025 -0.0007385 2.4925511 -1.4198734 -0.0004242 -0.9438916 7 8 2.7298663 -1.1576062 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -14.403 2167.435 -0.0070.995 ldhours2.836420.015 0.0070.995 lwpm -5.119 2323.044 -0.0020.998 (Dispersion parameter for quasibinomial family taken to be 2501139) Null deviance: 441.20 on 7 degrees of freedom Residual deviance: 48.81 on 5 degrees of freedom AIC: NA Number of Fisher Scoring iterations: 8 Thanks, Mel -- Menelaos Stavrinides Ph.D. Candidate Environmental Science, Policy and Management 137 Mulford Hall MC #3114 University of California Berkeley, CA 94720-3114 USA Tel: 510 717 5249 [[alternative HTML version deleted]] -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with GAM
Hi I'm trying to do a GAM analysis and have the following codes entered into R (density is = sample number, alive are the successes) density-as.real(density) y-cbind(alive,density-alive) library(mgcv) m1-gam(y~s(density),binomial) at which point I get the following error message Error in smooth.construct.tp.smooth.spec(object, dk$data, dk$knots) : A term has fewer unique covariate combinations than specified maximum degrees of freedom What am I doing wrong? Please help! Thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] change individual label colours in a cluster plot?
Hi Jim, How are you? I saw your posting. I am trying to do clustering for co authorship.What I have is undirected graph .I want to have clusters for 393 nodes. I am attaching the file along with this mail.If you move to the section Cluster I am looking to do something like that.Is it something you are familiar with. Can you tell me how you did it in R. Nathan Jim Ottaway wrote: patricia garcía gonzález kurtney...@hotmail.com writes: Hi, If you have a variable, that defines what you want to differentiate (sociology, economics etc.) then you can add color depending on the value of that variable. You will have to convert it to numeric if it is not. An example would be plot( iris[ , 1 ], iris[ , 2], col = iris[ , 3 ] ) Thank you. I'm not sure that I can do that with an hclust object, though: perhaps something using the text function and the order data in the hclust object might work? Currently, I'm good getting results using a script to edit the postscript output, but I'm keen to find an R solution, if only to improve my understanding of R graphicss. Yours sincerely, -- Jim Ottaway __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. http://www.nabble.com/file/p22336078/Clustering%2BTechnique.pdf Clustering+Technique.pdf -- View this message in context: http://www.nabble.com/change-individual-label-colours-in-a-cluster-plot--tp21852671p22336078.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] best fit line
Dear R Community, I am plotting this simple x-y plot (raw data plot attached). I cant fit a linear regression line to it. I have to figure out what is the best fit for this graph. Is there a way to tell which regression to use for this kind of data? Also, after selecting the best fit model, I need to extrapolate what could be the other possible data points. I am new to R. Could anyone please help? Thanks. Anuj http://www.nabble.com/file/p22336095/plot.jpg -- View this message in context: http://www.nabble.com/best-fit-line-tp22336095p22336095.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Table Transformation
Dear R-experts, recently, I started to discover the world of R. I came across a problem, that I was unable to solve by myself (including searches in R-help, etc.) I have a flat table similar to key1key2value1 abcd_1 BP 10 abcd_1 BSMP1A abcd_1 PD 25 abcd_2 BP 20 abcd_3 BP 80 abcd_4 IA 30 abcd_4 PD 70 abcd_4 PS N I wish to transform this table to obtain the following result: key2 key1BP BSMPIA PD PS abcd_1 101A 25 abcd_2 20 abcd_3 80 abcd_4 3070N I considered table and xtabs but I could not get the desired result: I received cross-tables key1 vs. key2 that contained counts within the cells. Can anybody help me? Best wishes, Christian -- View this message in context: http://www.nabble.com/Table-Transformation-tp22335545p22335545.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] Colormap that look good in gray scale
Hi, I am looking for a colormap (in color) that look like a gradient in gray scale. It is to allow people without color printer to print the color graph and have something meaningful in gray scale. It can be something like this plot(1:6,col=c(1,7,5,3,2,4),pch=c(1,20,20,20,20,20)) but with an arbitrary number of different colors, not just six. Thanks -- View this message in context: http://www.nabble.com/Colormap-that-look-good-in-gray-scale-tp22336097p22336097.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] adding value labels on Interaction Plot
On Wed, Mar 4, 2009 at 10:52 AM, Dimitri Liakhovitski ld7...@gmail.com wrote: Hello - and sorry for what might look like a simple graphics question. I am building an interaction plot for d: d=data.frame(xx=c(3,3,2,2,1,1),yy=c(4,3,4,3,4,3),zz=c(5.1,4.4,3.5,3.3,-1.1,-1.3)) d[[1]]-as.factor(d[[1]]) d[[2]]-as.factor(d[[2]]) print(d) interaction.plot(d$xx, d$yy, d$zz, type=b, col=c(red,blue), legend=F, lty=c(1,2), lwd=2, pch=c(18,24), xlab=X Label, ylab=Y Label, main=Chart Label) I am trying and not succeeding in adding Y values (value labels in Excel speak) near the data points on 3 lines of the graph. I understand that I might have to use text. But how do I tell text to use the actual coordinates of the dots on the lines? Thank you very much! I'm not understanding your trouble, exactly. I had not heard of interaction.plot before and so I've run your code and it is an interesting function. Thanks for providing the working example. I can help you with the text. It is easy to add text. A commmands like text( 1.3, 1, whatever, pos=3) will put the word whatever on top of coordinates x and y. (you leave out pos=3 and R centes the text on the coordinates). If you need to find out x , y before running that, you can. the locator function will return coordinates. Run locator(1) and then left click on a point in the graph. Coordinates will pop out on the screen. And you can make the text placement depend on locator text(locator(1), whatever, pos=3) I don't think you want to do that work interactively, however. It can be automated. You can add a column of names in your data frame and more or less automate the plotting as well. I did this to test. mylabels - c(A,B,C,D,E,F) text(d$xx,d$zz, mylabels, pos=3) This almost works perfectly, but it plops the labels in the wrong spots. I'd like to change the command so that the position of the text for the red line would be on the right, while the position of the text for the blue line is on the left. It appears to me your variable yy is the one that separates the 2 lines. Correct? I observe: as.numeric(d$yy) [1] 2 1 2 1 2 1 We want the blue ones on the left, for them we need pos=2. For the others, we want pos=4 Ach. I tried this text( d$xx, d$zz, mylabels, pos=2*as.numeric(d$yy)) but it comes out backward. So how about this: text( d$xx, d$zz, mylabels, pos=as.numeric(d$yy)) That positions the red ones below the line and the blue ones to the left. That doesn't look too bad to me. Anyway, I think you get the idea. If you wanted to simply stop plotting the circles, and put the letters right on the spot, that would be easy as well. -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Table Transformation
See ?reshape Uwe Ligges Christian Pilger wrote: Dear R-experts, recently, I started to discover the world of R. I came across a problem, that I was unable to solve by myself (including searches in R-help, etc.) I have a flat table similar to key1key2value1 abcd_1 BP 10 abcd_1 BSMP1A abcd_1 PD 25 abcd_2 BP 20 abcd_3 BP 80 abcd_4 IA 30 abcd_4 PD 70 abcd_4 PS N I wish to transform this table to obtain the following result: key2 key1BP BSMPIA PD PS abcd_1 10 1A 25 abcd_2 20 abcd_3 80 abcd_4 30 70 N I considered table and xtabs but I could not get the desired result: I received cross-tables key1 vs. key2 that contained counts within the cells. Can anybody help me? Best wishes, Christian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scatter plot question
At 12:19 AM 3/4/2009, you wrote: plot(x,rho,pch=id) Or this. Tim dat id x rho 1 A 1 0.1 2 B 20 0.5 3 C 2 0.9 labels-dat$id labels [1] A B C plot(dat$x,dat$rho,pch=labels) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Colormap that look good in gray scale
On Wed, 4 Mar 2009, thibert wrote: Hi, I am looking for a colormap (in color) that look like a gradient in gray scale. It is to allow people without color printer to print the color graph and have something meaningful in gray scale. It can be something like this plot(1:6,col=c(1,7,5,3,2,4),pch=c(1,20,20,20,20,20)) but with an arbitrary number of different colors, not just six. There is some discussion of this in our manuscript Achim Zeileis, Kurt Hornik, and Paul Murrell Escaping RGBland: Selecting colors for statistical graphics which is forthcoming in CSDA (Computational Statistics Data Analysis), for a preprint see http://statmath.wu-wien.ac.at/~zeileis/papers/Zeileis+Hornik+Murrell-2008.pdf This discusses choice of the color, especially for shading areas. If you want to use this for shading points or lines, I would recommend to use relatively dark and colorful colors and different plotting characters. R packages that provide useful tools for coloring graphics include colorspace, RColorBrewer, ggplot2, and plotrix. hth, Z Thanks -- View this message in context: http://www.nabble.com/Colormap-that-look-good-in-gray-scale-tp22336097p22336097.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] best fit line
anujgoel wrote: Dear R Community, I am plotting this simple x-y plot (raw data plot attached). I cant fit a linear regression line to it. I have to figure out what is the best fit for this graph. Is there a way to tell which regression to use for this kind of data? Also, after selecting the best fit model, I need to extrapolate what could be the other possible data points. I am new to R. Could anyone please help? Homework? PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Uwe Ligges Thanks. Anuj http://www.nabble.com/file/p22336095/plot.jpg __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] dividing ts objects of different frequencies
Hello, I have two time series objects, 1 is yearly (population) and the other is quarterly (bankruptcy statistics). I would like to produce a quarterly time series object that consists of bankruptcy/population. Is there a pre-built function to intelligently divide these time series: br.ts = ts(data=br.df[,-1], frequency = 4, start=c(2001,1), end=c(2008,2)) distPop.ts = ts(data=distPop.df[,-1], frequency=1, start=(2000)) The time series I want is: br.ts[2001Q1]/distPop.ts[2001] , br.ts[2001Q2]/distPop[2001], br.ts[2001Q3]/distPop.ts[2001] , br.ts[2001Q4]/distPop[2001], br.ts[2002Q1]/distPop.ts[2002] , br.ts[2002Q2]/distPop[2002], etc. This would not be too difficult to write but does anything like this already exist? Thank you, -stephen -- == Stephen J. Barr University of Washington Dept. of Applied and Computational Math Sciences Dept. of Economics WEB: www.econsteve.com == [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] arima additive seasonality
Hello! I asked in this forum about what kind of seasonality the function arima() from stats implements. Now that I have been answered that it implements the Box-Jenkins multiplicative seasonality, I would like to ask whether there is in R possibility to model ARIMA with additive seasonality. I mean whether there is a function or package that implements additive seasonality. In case there is no such function, I would be thankful if someone suggests some code for the purpose. Thank you very much for your attention. Regards, Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] best fit line
On Mar 4, 2009, at 1:22 PM, anujgoel wrote: Dear R Community, I am plotting this simple x-y plot (raw data plot attached). I cant fit a linear regression line to it. I have to figure out what is the best fit for this graph. That is virtually impossible to define rigorously. The best fit would go through all the points precisely, the extreme form of overfitting, but the mathematical result would not be informative at all. Where did these data come from? What domain of science are you working on? You want a result that incorporates the relationships known to exist in your domain of investigation and summarizes the data without overfitting. I am being intentionally vague in what follows because this looks like homework. Is there a way to tell which regression to use for this kind of data? Not really. Looks rather hyperbolic, so you might think about the formula for hyperbola and then use the lm function. Also, after selecting the best fit model, I need to extrapolate what could be the other possible data points. The predict functions are used for this purpose. Consult you documentation. ?predict -- David Winsemius I am new to R. Could anyone please help? Thanks. Anuj http://www.nabble.com/file/p22336095/plot.jpg -- View this message in context: http://www.nabble.com/best-fit-line-tp22336095p22336095.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Grouped Boxplot
Pls forgive me heavy-handed data generation -- newby ;-) ### start ### # example data g - rep.int(c(A, B, C, D), 125) t - rnorm(5000) a - sample(t, 500, replace=TRUE) b - sample(t, 500, replace=TRUE) # what I actually want to have: boxplot(a | b ~ g) # but that does obviously not produce what I want, instead i - data.frame(g, a, rep(one, length(g))) j - data.frame(g, b, rep(two, length(g))) names(i) - c(Group, Number, Word) names(j) - c(Group, Number, Word) k - as.data.frame(rbind(i, j)) boxplot(k$Number ~ k$Word * k$Group) ### end ### Questions: (1) Is there an easier way? (2) How can I get additional space between the A:D groups? Thank you Sören __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Diff btw percentile and quantile
Excel 2003's help for percentile just says it interpolates between the quantiles in the data: Array is the array or range of data that defines relative standing. K is the percentile value in the range 0..1, inclusive. If array is empty or contains more than 8,191 data points, PERCENTILE returns the #NUM! error value. If k is nonnumeric, PERCENTILE returns the #VALUE! error value. If k is 0 or if k 1, PERCENTILE returns the #NUM! error value. If k is not a multiple of 1/(n - 1), PERCENTILE interpolates to determine the value at the k-th percentile. so some experimenation is on order. I found that the call to R's quantile gives a different result for each of the 9 documented values of the type argument: x-c(1,1,2,3,3,5,8,8,9,10) quantile(x, probs=(0:8)/8, type=types[i]) E.g., sapply(1:9,function(type)quantile(x=x,probs=(0:8)/8,type=type)) type=1 type=2 type=3 type=4 type=5 type=6 type=7type=8 type=9 0% 1 1 1 1.00 1.00 1.000 1.000 1.00 1.0 12.5% 1 1 1 1.00 1.00 1.000 1.125 1.00 1.0 25%2 2 1 1.50 2.00 1.750 2.250 1.916667 1.93750 37.5% 3 3 3 2.75 3.00 3.000 3.000 3.00 3.0 50%3 4 3 3.00 4.00 4.000 4.000 4.00 4.0 62.5% 8 8 5 5.75 7.25 7.625 6.875 7.375000 7.34375 75%8 8 8 8.00 8.00 8.250 8.000 8.08 8.06250 87.5% 9 9 9 8.75 9.25 9.625 8.875 9.375000 9.34375 100% 10 10 10 10.00 10.00 10.000 10.000 10.00 10.0 I entered the same x into Excel 2003 and used the formulae =percentile(A1:10,0), =percentile(A1:A10,.125), ..., =percentile(A1:A10,1) and got the results 1, 1.125, 2.25, 3, 4, 6.875, 8, 8.875, 10 This matches only R's type 7, the default. They also match S+'s default quantile calculation. Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com Ted Harding wrote: On 04-Mar-09 16:56:14, Wacek Kusnierczyk wrote: (Ted Harding) wrote: snip So, with reference to your original question Excel has percentile() function. R function quantile() does the same thing. Is there any significant difference btw percentile and quantile? the answer is that they in effect give the same results, though differ with respect to how they are to be fed (quantile eats probabilities, percentile eats percentages). [Though (since I am not familiar with Excel) I cannot rule out that Excel's percentile() function also eats probabilities; in which case its name would be an example of sloppy nomenclature on Excel's part; which I cannot rule out on general grounds either]. i am not familiar enough with excel to prove or disprove what you say above, but in general such claims should be grounded in the respective documentations. there are a number of ways to compute empirical quantiles (see, e.g., [1]), and it's possible that the one used by r's quantile by default (see ?quantile) is not the one used by excel (where you probably have no choice; help in oocalc does not specify the method, and i guess that excel's does not either). have you actually confirmed that excel's percentile() does the same as r's quantile() (modulo the scaling)? vQ I have now googled around a bit. All references to the Excel percentile() function say that you feed it the fractional value corresponding to the percentage. So, for example, to get the 80-th percentile you would give it 0.8. Hence Excel should call it quantile! As to the algorithm, Wikipedia states the following (translated into R syntax): Many software packages, such as Microsoft Excel, use the following method recommended by NIST[4] to estimate the value, vp, of the pth percentile of an ascending ordered dataset containing N elements with values v[1],v[2],...,v[N]: n = (p/100)*(N-1) + 1 n is then split into its integer component, k and decimal component, d, such that n = k + d. If k = 1, then the value for that percentile, vp, is the first member of the ordered dataset, v[1]. If k = N, then the value for that percentile, vp, is the Nth member of the ordered dataset, v[N]. Otherwise, 1 k N and vp = v[k] + d*(v[k + 1] - v[k]). Note that the Wikipedia article uses the % interpretation of p-th percentile, i.e. the point which is (p/100) of the way along the distribution. It looks as though R's quantile with type=4 might be the same, since it is explained as linear interpolation of the empirical cdf, which is what the above description of Excel's method does. However, R's default type is 7, which is different. Ted. E-Mail: (Ted Harding) Ted.Harding at manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 04-Mar-09 Time: 17:29:50 -- XFMail