Re: [R] HOw to delete a row in the data matrix and change the order of the row ???
Assign new row names? Uwe Ligges ychu066 wrote: hi, i delete row 65,70,75 in my data data- data[-c(65,70,75),] But i also want the order of the row to match up eg: 67 11111111111111 1 68 11111111111111 1 69 11111111111111 1 71 11111111111111 1 72 11111111111111 1 73 11111111111111 1 74 11111111111111 1 76 11111111111111 1 77 11111111111111 1 I dont want this , I don't want a gap between 69-71 , 73-74 and 74-76. i want it like this 67 11111111111111 1 68 11111111111111 1 69 11111111111111 1 70 11111111111111 1 71 11111111111111 1 72 11111111111111 1 73 11111111111111 1 74 11111111111111 1 75 11111111111111 1 please help me ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question about function heatmap
Copied form the R-help messages' footer: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Uwe Ligges Waverley @ Palo Alto wrote: Hi, I am using the function heatmap(stats) to draw a microarray heatmap, columns are samples and rows are gene features. I did a 2D clustering during the heatmap drawing. The features and samples indeed cluster into several blocks both vertically and horizontally. I can get the index of re-ordered rows and columns after the heatmap drawing by typing the the return variable of the heatmap function. However, I cannot separate these index by the the dendro tree. All the indexes labeled at the bottom and right of the plot all jammed together. I cannot by looking at the plot to find where the borders are. Can someone help? Essentially I want the dendro tree of the genes which are grouped after the clustering so that, e.g., I want to check whether genes clustered together are in the same pathway etc. Thanks in advance. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Perform operations on dataframes called with paste in loops
separent wrote: In a loop, I compose the name of a csv file using paste, then read it (e.g., dataset1.csv, dataset2.csv, etc). The name of the dataframe assigned to the imported csv is also composed with paste (e.g., dataset1, dataset2, etc.). Now I want to perform operations on the dataframes dataset1, dataset2, etc. However, the paste function only renders a string on which I can not, for example, do operations like plot(paste(dataset,i,[,1],sep=),paste(dataset,i,[,2],sep=)). How could I call the dataframe instead of the string representing its name? 1. consider to read the csv files into a *list* of dataframes and loop over that list. 2. if you do not want to follow 1., see ?get Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] recode according to old levels
Dear R-users, i try to recode a factor according to old levels F - factor(sample(c(rep(A, 4), rep(B,2), rep(C,5 recode(F, levels(F)[c(1,3)]='X'; else='Y') i tried to work with eval or expression around levels(F)[c(1,3)], but nothing seems to work. Many thanks if anyone could tell me what i've missed and what's the problem here. best regards Andreas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Relase positive with log and zero of negative with 0
PE == Peter Ehlers ehl...@ucalgary.ca on Mon, 16 Nov 2009 06:55:00 -0700 writes: PE David Winsemius wrote: On Nov 15, 2009, at 10:18 AM, rkevinbur...@charter.net wrote: This is a very simple question but I couldn't form a site search quesry that would return a reasonable result set. Say I have a vector: x - c(0,2,3,4,5,-1,-2) I want to replace all of the values in 'x' with the log of x. Naturally this runs into problems since some of the values are negative or zero. So how can I replace all of the positive elements of x with the log(x) and the rest with zero? x - c(0,2,3,4,5,-1,-2) x - ifelse(x0, log(x), 0) Warning message: In log(x) : NaNs produced x [1] 0.000 0.6931472 1.0986123 1.3862944 1.6094379 0.000 0.000 The warning is harmless as you can see, but if you wanted to avoid it, then: x[x=0] - 0; x[x0] -log(x[x0]) In the second command, you need to have the logical test on both sides to avoid replacement out of synchrony. PE Here is one more way, somewhat less transparent, motivated PE by the examples on the ?ifelse page: PE x - log(ifelse(x 0, x, 1)) Yes, indeed. And this one pretty clearly demonstrates that -- from an analytic point of view -- this is really in most cases a non-sense transformation: one and all negative numbers are mapped to zero; the rest is log transformed: Look at its graph via curve(log(ifelse(x 0, x, 1)), -2, 3) Rather log(abs(x)) or log(abs(x + eps)) {eps = 1 or eps = 1e-10 or ...} typically are more useful for what I guess the OP wants the trafo to use for... or then, if you think further and want a - monotone - continuous and even smooth (once-differentiable) log-like transformation then consider using the u.log() function I have written some 13 years ago, (inspired by coffebreak discussions with Werner Stahel) available from install.packages(sfsmisc) require(sfsmisc) curve(u.log, -2, 3, col=2) curve(u.log(x, c=0.5), add=TRUE, col=3) ?u.log Martin Maechler, ETH Zurich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Normal distribution test
Thank you for all the answers! Kjetil, I am not sure if we are talking about the same thing. I only have a two dimensional normal distribution which leads to three dimensional data. You mean with reject I should not do such a test? My data files contain about 26 points which I can reduce to the half. The data is created through a sum of two dim. Gaussian profiles (or just one). It is easy to fit a 2 dim. Gaussian function but this does not take material properties into account so I cannot be sure that the points are realy normal distributed. What I want to do with that is to proof that the model (at least one 2D Gaussian function) is working correctly or if I have to think of a different one. Regards, Markus Kjetil Halvorsen schrieb: On Tue, Nov 17, 2009 at 11:17 AM, Markus Mehrwald mehrw...@ira.uka.de wrote: Hi all, I am completely new to R and my knowledge of statistics is quite small so I hope you can help my. I have three dimensional point data which represents (and this is what I do not know for sure) a normal distribution. Now I want to test if this is true I suppose you want to say you have a sample of three-dim data, say represented be vectors x1,x2,x3, and your question is if this data (x1|_1,x2_1, x3_1),...,(x1_n,x2_n, x3_n) are generated by a three-dim multinormal distribution. That is very simple, a very good test is to simply say reject. I have never seen three-dim data which are truly multinormal. So a better question is to ask if amultinormal distribution can be an acceptable approximation, but then we need to know what is your purpose of analysis! If you are interested in extremes or extrere quantiles, then a normal approx is never safe. If you want a statistical test, then a multivariate extension of shapiro-wilk is in install.packages(mvnormtest, dep=TRUE) library(mvnormtest) ?mshapiro.test kjetil or not and as I can remember from statistics lessons I can use Chi-Square test for distribution test. BUT: I have realy no idea how to do this with R and additionally if my assumptions are correct and if this is possible with R at all. Thank you very much in advance for any answer. Markus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dipl.-Inform. Med. Markus Mehrwald Institut für Prozessrechentechnik, Automation und Robotik Medizin-Gruppe Universität Karlsruhe (TH) Gebäude 40.28, Zimmer 110 Engler-Bunte-Ring 8 76131 Karlsruhe Fon: +49 (721) 608-7113 Fax: +49 (721) 608-7141 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Importing tRNA data into R ?
Hello dear R help group, I would like to download the tRNA data on: http://gtrnadb.ucsc.edu/download.html And then import it into R. Can anyone direct me as to how to do so? Thanks, Tal -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] getting the name of a single object in R for debugging output
I often use a debug flag (set to TRUE) to turn on various debugging print statements in my R scripts. I was thinking I should create a function debugPrint(object,debugFlag), to print out the object name and contents if the debugFlag is set to TRUE. Then I wouldn't have to make my script ugly(..er) than it already is by adding IF statements all over the place. I've seen how ls() dumps object names, but how do I get access to the character representation of the name of an object. E.g. myVar- 10 print(myVar) produces 10 I'd like to print out something like myVar : 10 I'd appreciate any suggestions. Regards, Andrew [[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] Switch Help
Dear Rexperts, Given, aar -function(command) { switch(command, {scrn = cat(scrn :Screening,\n)} {dx = cat(dx:Diagnosis,\n)} {df = cat(df:Don't Forget,\n)} ) } I want to be able to do: aar(dx) # function does cat(dx:Diagnosis,\n) aar(c(dx,df)) # function does cat(dx:Diagnosis,\n) # function does df = cat(df:Don't Forget,\n) BUT IT IS NOT WORKING FOR ME. Please help:-) -- Oscar Oscar A. Linares, MD Translational Medicine Unit LaPlaisance Bay, Bolles Harbor Monroe, Michigan [[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] Lattice plot
Hi, ggplot2 can also split the graphs in different panels, d= read.table(textConnection( chr start1 end1 meth positive 1 1 10 20 1.5y 2 2 12 18 -0.7n 3 3 22 34 2.0y 4 1 35 70 3.0y 5 1120 140 -1.3n 6 1180 190 0.2y 7 2220 300 0.4y), head=T) library(ggplot2) ggplot(data=d) + facet_grid(.~chr) + geom_segment(aes(x=start1, xend=end1, y=meth, yend=meth)) HTH, baptiste 2009/11/17 Tim Smith tim_smith_...@yahoo.com: Hi, I was trying to get a graph in lattice with the following data frame (7 rows, 5 cols): chr start1 end1 meth positive 1 1 10 20 1.5 y 2 2 12 18 -0.7 n 3 3 22 34 2.0 y 4 1 35 70 3.0 y 5 1 120 140 -1.3 n 6 1 180 190 0.2 y 7 2 220 300 0.4 y I wanted the panels to be organized by 'chr' - which is ok. Further, I wanted the lines to be discontinuous. For example, in the first row, the x co-ordinate starts with a value of 10 (2nd column) and ends with a value of 20 (3rd column). The corresponding y value for this range of x values is 1.5 (4th column). Similarly, for the same panel (i.e chr=1), the fourth row would have x co-ordinate range from 35 to 70 with a y co-ordinate of 3. If it were only one panel, a similar result could be achieved for the data x2: x2 chr start1 end1 meth positive 1 1 10 20 1.5 y 4 1 35 70 3.0 y 5 1 120 140 -1.3 n 6 1 180 190 0.2 y ## Code courtesy of BAPTISTE AUGUIE library(ggplot2) ggplot(data=x2) + geom_segment(aes(x=start1, xend=end1, y=meth, yend=meth)) - Can I get lattice to do a similar graph for the panels? 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.
[R] Odp: recode according to old levels
Hi r-help-boun...@r-project.org napsal dne 18.11.2009 09:24:40: Dear R-users, i try to recode a factor according to old levels F - factor(sample(c(rep(A, 4), rep(B,2), rep(C,5 recode(F, levels(F)[c(1,3)]='X'; else='Y') i tried to work with eval or expression around levels(F)[c(1,3)], but nothing seems to work. I am not sure if recode does not want as an input a numeric vector. However for recoding levels of factor you can add a vector of new levels in correct order. set.seed(111) F - factor(sample(c(rep(A, 4), rep(B,2), rep(C,5 levels(F)-c(X,X,Y) F [1] Y Y X X X Y X X X Y Y Levels: X Y or maybe levels(F)- ifelse(levels(F) %in% c(A,B), X, Y) Regards Petr Many thanks if anyone could tell me what i've missed and what's the problem here. best regards Andreas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] recode according to old levels
Andreas Wittmann wrote: Dear R-users, i try to recode a factor according to old levels F - factor(sample(c(rep(A, 4), rep(B,2), rep(C,5 recode(F, levels(F)[c(1,3)]='X'; else='Y') i tried to work with eval or expression around levels(F)[c(1,3)], but nothing seems to work. I assume that you mean the recode() function in pkg:car? (You really should say so.) Here are a couple of ways to recode the factor: set.seed(6931) F - factor(sample(rep(c(A,B,C), c(4,2,5 lev - levels(F) # 1: using car:::recode F - recode(F, lev[c(1,3)] = 'X'; else = 'Y') # 2: using base:::levels levels(F) - list(X = lev[c(1,3)], Y = lev[-c(1,3)]) -Peter Ehlers Many thanks if anyone could tell me what i've missed and what's the problem here. best regards Andreas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Switch Help
I think you just missed some commas out... aar - function(command = c(scrn, dx, df)) { command - match.arg(command) switch(command, scrn = cat(scrn :Screening,\n), dx = cat(dx:Diagnosis,\n), df = cat(df:Don't Forget,\n) ) } Colin. Ps you don't need the curly brackets here if theres only one expresion, and sometimes its good to restrict the inputs to only those you want So that aar(something wrong) # Error in match.arg(command) : 'arg' should be one of scrn, dx, df -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of oscar linares Sent: 18 November 2009 10:40 To: r-help@r-project.org Subject: [R] Switch Help Dear Rexperts, Given, aar -function(command) { switch(command, {scrn = cat(scrn :Screening,\n)} {dx = cat(dx:Diagnosis,\n)} {df = cat(df:Don't Forget,\n)} ) } I want to be able to do: aar(dx) # function does cat(dx:Diagnosis,\n) aar(c(dx,df)) # function does cat(dx:Diagnosis,\n) # function does df = cat(df:Don't Forget,\n) BUT IT IS NOT WORKING FOR ME. Please help:-) -- Oscar Oscar A. Linares, MD Translational Medicine Unit LaPlaisance Bay, Bolles Harbor Monroe, Michigan [[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. __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Switch Help
If you want type twice commands in function aar, you could try this: aar -function(command) { switch(command, scrn = cat(scrn :Screening,\n), dx = cat(dx:Diagnosis,\n), df = cat(df:Don't Forget,\n)) } invisible(Vectorize(aar)(c('dx', 'df'))) On Wed, Nov 18, 2009 at 8:39 AM, oscar linares wins...@gmail.com wrote: Dear Rexperts, Given, aar -function(command) { switch(command, {scrn = cat(scrn :Screening,\n)} {dx = cat(dx :Diagnosis,\n)} {df = cat(df :Don't Forget,\n)} ) } I want to be able to do: aar(dx) # function does cat(dx :Diagnosis,\n) aar(c(dx,df)) # function does cat(dx :Diagnosis,\n) # function does df = cat(df :Don't Forget,\n) BUT IT IS NOT WORKING FOR ME. Please help:-) -- Oscar Oscar A. Linares, MD Translational Medicine Unit LaPlaisance Bay, Bolles Harbor Monroe, Michigan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Switch Help
And if you want to do both do invisible( lapply(c(scrn,dx), aar) ) but I think you will have to use multiple ifs rather than switch if you intend to add more functionality... . . . I think you just missed some commas out... aar - function(command = c(scrn, dx, df)) { command - match.arg(command) switch(command, scrn = cat(scrn :Screening,\n), dx = cat(dx:Diagnosis,\n), df = cat(df:Don't Forget,\n) ) } Colin. Ps you don't need the curly brackets here if theres only one expresion, and sometimes its good to restrict the inputs to only those you want So that aar(something wrong) # Error in match.arg(command) : 'arg' should be one of scrn, dx, df -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of oscar linares Sent: 18 November 2009 10:40 To: r-help@r-project.org Subject: [R] Switch Help Dear Rexperts, Given, aar -function(command) { switch(command, {scrn = cat(scrn :Screening,\n)} {dx = cat(dx:Diagnosis,\n)} {df = cat(df:Don't Forget,\n)} ) } I want to be able to do: aar(dx) # function does cat(dx:Diagnosis,\n) aar(c(dx,df)) # function does cat(dx:Diagnosis,\n) # function does df = cat(df:Don't Forget,\n) BUT IT IS NOT WORKING FOR ME. Please help:-) -- Oscar Oscar A. Linares, MD Translational Medicine Unit LaPlaisance Bay, Bolles Harbor Monroe, Michigan [[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. __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] getting the name of a single object in R for debugging output
Try this: debugPrint - function(x, ...){ print(sprintf(%s: %d, deparse(substitute(x)), x), ...) } On Wed, Nov 18, 2009 at 8:35 AM, Andrew nodeco...@yahoo.com wrote: I often use a debug flag (set to TRUE) to turn on various debugging print statements in my R scripts. I was thinking I should create a function debugPrint(object,debugFlag), to print out the object name and contents if the debugFlag is set to TRUE. Then I wouldn't have to make my script ugly(..er) than it already is by adding IF statements all over the place. I've seen how ls() dumps object names, but how do I get access to the character representation of the name of an object. E.g. myVar- 10 print(myVar) produces 10 I'd like to print out something like myVar : 10 I'd appreciate any suggestions. Regards, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (exact) confidence bounds for lognormal parameters \mu and \sigma
Thank you, it is what I was looking for: library(fitdistrplus) x-rlnorm(100) res-mledist(x, distr=lnorm) res Anyway, the results do not provide confidence intervals, but mle estimates and the hessian matrix, whose extradiagonal elements are null... is it correct? http://www.weibull.com/LifeDataWeb/confidence_bounds_log.htm http://www.weibull.com/LifeDataWeb/confidence_bounds_log.htm I will investigate... David Scott-6 wrote: Krusty the Klown wrote: Dear all, a statistical question: how can I compute exact confidence intervals for the lognormal distribution parameters? I found something only on www.weibull.com www.weibull.com . Does exist a package in R which can compute them? Thanks in advance, KTK I think fitdistrplus can do this David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email:d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://old.nabble.com/%28exact%29-confidence-bounds-for-lognormal-parameters-%5Cmu-and-%5Csigma-tp26394177p26404934.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to install older version of R?
Dear list This is much like a linux problem, but I can't find any reference for it. My OS is ubuntu 9.04 and a version of 2.9.2 of R has been already installed in. Now, I need to install the version of 2.7.1. I google a lot of websites and it seems like without a painless way provided me to do it. If any one offer me some suggestions/reference, I will appreciate. Jia-Chiun Pan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (exact) confidence bounds for lognormal parameters \mu and \sigma
Sorry, probbaly it is...:blush: Krusty the Klown wrote: Anyway, the results do not provide confidence intervals, but mle estimates and the hessian matrix, whose extradiagonal elements are null... is it correct? http://www.weibull.com/LifeDataWeb/confidence_bounds_log.htm http://www.weibull.com/LifeDataWeb/confidence_bounds_log.htm -- View this message in context: http://old.nabble.com/%28exact%29-confidence-bounds-for-lognormal-parameters-%5Cmu-and-%5Csigma-tp26394177p26404958.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] Switch Help
I believe that is what you want: aar -function(command) { for(i in command){ cat(i,:,switch(EXPR=i, scrn = Screening, dx = Diagnosis, df = Don't Forget), \n) } } aar(c(dx,df)) dx : Diagnosis df : Don't Forget Alain oscar linares wrote: Dear Rexperts, Given, aar -function(command) { switch(command, {scrn = cat(scrn :Screening,\n)} {dx = cat(dx:Diagnosis,\n)} {df = cat(df:Don't Forget,\n)} ) } I want to be able to do: aar(dx) # function does cat(dx:Diagnosis,\n) aar(c(dx,df)) # function does cat(dx:Diagnosis,\n) # function does df = cat(df:Don't Forget,\n) BUT IT IS NOT WORKING FOR ME. Please help:-) -- Alain Guillet Statistician and Computer Scientist SMCS - Institut de statistique - Université catholique de Louvain Bureau c.316 Voie du Roman Pays, 20 B-1348 Louvain-la-Neuve Belgium tel: +32 10 47 30 50 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 plot
On Wed, Nov 18, 2009 at 4:14 AM, Tim Smith tim_smith_...@yahoo.com wrote: Hi, I was trying to get a graph in lattice with the following data frame (7 rows, 5 cols): chr start1 end1 meth positive 1 1 10 20 1.5 y 2 2 12 18 -0.7 n 3 3 22 34 2.0 y 4 1 35 70 3.0 y 5 1 120 140 -1.3 n 6 1 180 190 0.2 y 7 2 220 300 0.4 y I wanted the panels to be organized by 'chr' - which is ok. Further, I wanted the lines to be discontinuous. For example, in the first row, the x co-ordinate starts with a value of 10 (2nd column) and ends with a value of 20 (3rd column). The corresponding y value for this range of x values is 1.5 (4th column). Similarly, for the same panel (i.e chr=1), the fourth row would have x co-ordinate range from 35 to 70 with a y co-ordinate of 3. You could do it with library(latticeExtra) segplot(meth ~ start1 + end1 | factor(chr), bar, type = g) but as Baptiste said, ggplot2 can do conditioning just as well. -Deepayan If it were only one panel, a similar result could be achieved for the data x2: x2 chr start1 end1 meth positive 1 1 10 20 1.5 y 4 1 35 70 3.0 y 5 1 120 140 -1.3 n 6 1 180 190 0.2 y ## Code courtesy of BAPTISTE AUGUIE library(ggplot2) ggplot(data=x2) + geom_segment(aes(x=start1, xend=end1, y=meth, yend=meth)) - Can I get lattice to do a similar graph for the panels? 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] lattice barchart
On Tue, Nov 17, 2009 at 3:31 PM, Wilberforce will.pa...@matrixknowledge.com wrote: I have a data frame with two factors and want to create panel barcharts with one factor defining the panels and the other the vertical categories by which I can count the rows of data in each combination of factors. How do I do this? I have been trying to use barchart(~factor1|factor2) but it does not give the panels as I want them. The data looks like this: Factor1 Factor2 A y B y A x B y C x etc... You need to tabulate your data first; barchart() won't do that for you. Start with barchart(xtabs(~Factor1 + Factor2, your.data)) and try using as.data.frame(xtabs(~Factor1 + Factor2, your.data)) as the data= argument for more flexibility. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] specifying group plots using panel.groups
On Mon, Nov 16, 2009 at 9:47 PM, wintere ericawint...@gmail.com wrote: Hi, I am trying to plot two types of data on the same graph: points and distributions. I am attempting to use the panel.groups function, but cannot seem to get it to work. I have a melted data set and put in a FLAG column to separate my data into the two groups that I would like to plot, point data (FLAG=0) and the distribution(FLAG=1). Here is the code i am using in R: Reproducible example please. -Deepayan stripplot( variable~value, conf(RunlogBootCL), groups=FLAG, panel=panel.superpose, panel.groups=function(x,y, group.number, ...){ if(group.number==1)panel.xyplot(x,y, group.number...) else if(group.number==0)panel.covplot(x,y, group.number...)}, ref=1, cex = 0.5, col=black, main='Covariate Effects on Clearance', xlab='relative clearance', fill='transparent' ) For some reason I can only get one or the other to plot!! (points or distributions). Can you please direct me to my error?! thanks! -- View this message in context: http://old.nabble.com/specifying-group-plots-using-panel.groups-tp26374674p26374674.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] boxplot
Hi, I have simple query In which package drawBoxplot function is available? Regards, Sukhbir Singh Rattan [[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] parsing numeric values
Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax =1.3770E-03 bx =3.4644E-07 ay =1.9412E-04 by =4.8840E-08 other text aax =1.3770E-03 bbx =3.4644E-07 aay =1.9412E-04 bby =4.8840E-08)) ## this is what I want results - c(as.numeric(strsplit(grep(ax, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(ay, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(aax, input,val=T), )[[1]][9]), as.numeric(strsplit(grep(aay, input,val=T), )[[1]][9]) ) ## [1] 0.00137700 0.00019412 0.00137700 0.00019412 The use of strsplit is not ideal here as there is a different number of space characters in the lines containing ax and aax for instance (hence the indices 8 and 9 respectively). I tried to use gsubfn for a cleaner construct, strapply(input, ax += +([0-9.]+), c, simplify=rbind,combine=as.numeric) but I can't seem to find the correct regular expression to deal with the exponent. Any tips are welcome! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot
I believe drawBoxplot doesn't exist. Are you looking for ?boxplot ? Tal -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Nov 18, 2009 at 1:41 PM, Sukhbir Rattan sukhbir.rat...@gmail.comwrote: Hi, I have simple query In which package drawBoxplot function is available? Regards, Sukhbir Singh Rattan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting Histogram using histogram() and for loop and Iwant to save the histogram individually ... HELP
Change the factor names of var in: y~x | var Tal -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Nov 18, 2009 at 3:17 AM, ychu066 ychu...@aucklanduni.ac.nz wrote: Hi again, do you know how can I use the main function to change the title for eac h histogram. i.e that first graph show have a title Index 1 but because the variable name column starts the 8th the title shows up as Index 8 , i have tried use main = colnames(data)[i-1] but it result errors Colin Millar wrote: Or alternatively store as a list and export later if you want ... after some tidying ... library(lattice) columns - 8:153 plots - vector(list, length(columns)) j - 0 for (i in columns) { plots[[ j - j+1 ]] - histogram( ~ data[,i] | data[,2], ylab = Frequency, xlab = Score, xlim = c(1,5), ylim = c(0,100), main = colnames(data)[i] ) } print(plots[[1]]) # or export for (i in seq_along(plots)) { png(paste(hist, i, .png, sep = )) print(plots[[i]]) dev.off() } HTH Colin. Incidentally, You put what you want to export between png(..) and dev.off() If you supply the data explicitly it doesn't make any sense to pass the data through the data argument. No need for paste(x) if is x is already a character vector. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tal Galili Sent: 17 November 2009 12:15 To: ychu066 Cc: r-help@r-project.org Subject: Re: [R] Plotting Histogram using histogram() and for loop and Iwant to save the histogram individually ... HELP I know how you feel, I came a cross the same problem once, which took sometime to find a solution for. What you need to do is put the hist into a variable and then plot it, for example: library(lattice) for(i in 8:153){ hist.to.plot - histogram(~ data[,i] | data[,2], data=data,,ylab=Frequency,xlim=c(1,5),xlab=Score,ylim=c(0,100)),main =paste(colnames(data)[i],sep=) plot(hist.to.plot) } Cheers, Tal -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Tue, Nov 17, 2009 at 7:09 AM, ychu066 ychu...@aucklanduni.ac.nz wrote: tried but still doesnt work ... very weird ... ychu066 wrote: here is the codes that i tried. png(paste(hist,i,.png,sep=) + library(lattice) Error: unexpected symbol in: png(paste(hist,i,.png,sep=) library for(i in 8:153){ + histogram(~ data[,i] | data[,2], data=data,ylab=Frequency,xlim=c(1,5),xlab=Score,ylim=c(0,100))) Error: unexpected ')' in: for(i in 8:153){ histogram(~ data[,i] | data[,2], data=data,ylab=Frequency,xlim=c(1,5),xlab=Score,ylim=c(0,100))) } Error: unexpected '}' in } dev.off() Error in dev.off() : cannot shut down device 1 (the null device) ychu066 wrote: still doesnt work ... Karl Ove Hufthammer wrote: On Thu, 12 Nov 2009 19:10:52 -0800 (PST) ychu066 ychu066 @aucklanduni.ac.nz wrote: And I also want to save each histogram in each separate pdf file using the following codes ?. png(hist.png[i]) dev.off() Try png(paste(hist,i,.png,sep=) instead. -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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://old.nabble.com/Plotting-Histogram-using-histogram%28%29-and-for-l oop-and-I-want-to-save-the-histogram-individually-...-HELP-tp26328734p26 384489.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
[R] reduce matrix
I am trying to reduce the dimension of matrix by removing zero elements and creating a sub-matrix. For example: A= [1,0,0,3; 0,1,2,0; 0,0,3,5] then the new matrix B would be: B= [1,3;1,2;3,5] There are the same number of zero elements in each row of A so dimension of B will not be a problem. Is there a straightforward way to do this in R without writing a function using loops etc? Any help or suggestions would be appreciated! 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] reduce matrix
one way is the following: A - rbind(c(1,0,0,3), c(0,1,2,0), c(0,0,3,5)) t(apply(A, 1, function (x) x[x != 0])) I hope it helps. Best, Dimitris lloyd barcza wrote: I am trying to reduce the dimension of matrix by removing zero elements and creating a sub-matrix. For example: A= [1,0,0,3; 0,1,2,0; 0,0,3,5] then the new matrix B would be: B= [1,3;1,2;3,5] There are the same number of zero elements in each row of A so dimension of B will not be a problem. Is there a straightforward way to do this in R without writing a function using loops etc? Any help or suggestions would be appreciated! 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. -- 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] parsing numeric values
Try this: strapply(input, ([0-9]+\\.[0-9]+E-[0-9]+), c, simplify = rbind, combine = as.numeric) On Wed, Nov 18, 2009 at 9:57 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax = 1.3770E-03 bx = 3.4644E-07 ay = 1.9412E-04 by = 4.8840E-08 other text aax = 1.3770E-03 bbx = 3.4644E-07 aay = 1.9412E-04 bby = 4.8840E-08)) ## this is what I want results - c(as.numeric(strsplit(grep(ax, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(ay, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(aax, input,val=T), )[[1]][9]), as.numeric(strsplit(grep(aay, input,val=T), )[[1]][9]) ) ## [1] 0.00137700 0.00019412 0.00137700 0.00019412 The use of strsplit is not ideal here as there is a different number of space characters in the lines containing ax and aax for instance (hence the indices 8 and 9 respectively). I tried to use gsubfn for a cleaner construct, strapply(input, ax += +([0-9.]+), c, simplify=rbind,combine=as.numeric) but I can't seem to find the correct regular expression to deal with the exponent. Any tips are welcome! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Optimal parameters for Savitzky-Golay smoothing filter (loop)
Hi I am running a Savitzky-Golay smoothing filter (http://tolstoy.newcastle.edu.au/R/help/04/02/0385.html) for variables in my dataset, dim (272:90). I managed to run the code for individual variables in the dataset and then combine the results into a single dataset. My novice attempt at this task is shown below csg-NULL for (i in 1:ncol(data.all)) { sg-sav.gol(data.all[,i],1,forder=2,dorder=0) csg[i]-data.frame(sg) dat-do.call(cbind,(csg)) } I eventually plan to test whether there is a significant difference between the original noisy dataset (data.all) and the Savitzky-Golay datasets(dat 1,dat2, ...). To create the Savitzky-Golay datasets I plan to change the size of the filter (j) so how would I create the new datasets with the changing filter size ? csg-NULL for (i in 1:ncol(data.all)) for(j in 1:10) { sg-sav.gol(data.all[,i],j,forder=2,dorder=0) csg[i]-data.frame(sg) dat-do.call(cbind,(csg)) } And Is there anyway that I can combine the results into a single dataset (data frame) or store them as separate objects in the workspace ? Regards Riyad # Scanned by MailMarshal - Marshal's comprehensive email content security solution. Download a free evaluation of MailMarshal at www.marshal.com # __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] re placing the dates format in R for exporting the data set...
?write.table If you read the help file, and do a little experimenting, you will see that there is a parameter 'rownames=FALSE' that may answer your question. Also since you did not have column names on your input, you get V1, V2,... You can put your own column names. It helps again to read the help file on 'read.table' and look at the parameter 'col.names'. There is also the colnames function. It also might help to (re)read the Intro to R. On Tue, Nov 17, 2009 at 8:27 PM, ychu066 ychu...@aucklanduni.ac.nz wrote: Moreover, I want to rename the column name V1,V2,V3,V4.V146. how do i write the code in R ??? thanks everyone that look at the thread/ ychu066 wrote: hi everyone, i am having difficulties with replacing the dates format in R for exporting the data set... eg: the code that i used was toms_dat- replace(toms_dat, toms_dat ==2009-08-06, 2) toms_dat- replace(toms_dat, toms_dat ==2009-08-04, 1) but when i export the data as into txt file or excel file the dates come up with very large numbers .:drunk: please help me ...=) http://old.nabble.com/file/p26400792/what.csv what.csv -- View this message in context: http://old.nabble.com/replacing-the-dates-format-in-R-for-exporting-the-data-set...-tp26396492p26400792.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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Presentation of data in Graphical format
Thanx but I am not able to find a graph that wud suit my data Regards Our Thoughts have the Power to Change our Destiny. Sunita On Sun, Nov 15, 2009 at 8:54 PM, milton ruser milton.ru...@gmail.comwrote: Google R graph grallery Google R ggplot2 Google R lattice and good luck milton On Sun, Nov 15, 2009 at 7:48 AM, Sunita22 sunita...@gmail.com wrote: Hello My data contains following columns: 1st column: Posts (GM, Secretary, AM, Office Boy) 2nd Column: Dept (Finance, HR, ...) 3rd column: Tasks (Open the door, Fix an appointment, Fill the register, etc.) depending on the post 4th column: Average Time required to do the task So the sample data would look like PostsDeptTask Average time Office Boy HR Open the door 00:00:09 Secretary FinanceFix an appointment00.00.30 . .. I am trying to represent this data in Graphical format, I tried graphs like Mosaic plot, etc. But it does not represent the data correctly. My aim is to check the amount of time and its variability for groups of tasks Thank you in advance Regards Sunita -- View this message in context: http://old.nabble.com/Presentation-of-data-in-Graphical-format-tp26358857p26358857.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] parsing numeric values
A minor variant might be the following: library(gsubfn) strapply(input, \\d+\\.\\d+E[-+]?\\d+, as.numeric, simplify = rbind) where: - as.numeric is used in place of c in which case we do not need combine - \\d+ matches one or more digits - \\. matches a decimal point - [-+]? matches -, + or nothing (i.e. an optional sign). - parentheses around the regular expression not needed On Wed, Nov 18, 2009 at 7:28 AM, Henrique Dallazuanna www...@gmail.com wrote: Try this: strapply(input, ([0-9]+\\.[0-9]+E-[0-9]+), c, simplify = rbind, combine = as.numeric) On Wed, Nov 18, 2009 at 9:57 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax = 1.3770E-03 bx = 3.4644E-07 ay = 1.9412E-04 by = 4.8840E-08 other text aax = 1.3770E-03 bbx = 3.4644E-07 aay = 1.9412E-04 bby = 4.8840E-08)) ## this is what I want results - c(as.numeric(strsplit(grep(ax, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(ay, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(aax, input,val=T), )[[1]][9]), as.numeric(strsplit(grep(aay, input,val=T), )[[1]][9]) ) ## [1] 0.00137700 0.00019412 0.00137700 0.00019412 The use of strsplit is not ideal here as there is a different number of space characters in the lines containing ax and aax for instance (hence the indices 8 and 9 respectively). I tried to use gsubfn for a cleaner construct, strapply(input, ax += +([0-9.]+), c, simplify=rbind,combine=as.numeric) but I can't seem to find the correct regular expression to deal with the exponent. Any tips are welcome! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Importing tRNA data into R ?
readFASTA in the BioConductor Biostrings package. b On Nov 18, 2009, at 8:14 AM, Tal Galili wrote: Hello dear R help group, I would like to download the tRNA data on: http://gtrnadb.ucsc.edu/download.html And then import it into R. Can anyone direct me as to how to do so? Thanks, Tal -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SVM Param Tuning with using SNOW package
Hi Charlie, Yes, you are perfectly right, when I make the clusters I should put 2, not 10 (it remained 10 from previous trials with 10 slaves). cl- makeCluster(2, type=SOCK ) To tell the truth I do not understand very well what the 2nd parameter for clusterApplyLB() has to be. If the function sv.lin has just 1 parameter, sv.lin(c), where c is the cost, how should I call clusterApplyLB? ? clusterApply LB(cl, ?,sv.lin, c=cost1) ? Below, I am providing a working example, using the gasoline data that comes in the pls package. Thank you for your time! library(e1071) library(snow) library(pls) data(gasoline) X=gasoline$NIR Y=gasoline$octane NR=10 cost1=seq(0.5,30, length=NR) sv.lin- function(c) { for (i in 1:NR) { ind=sample(1:60,50) gTest- data.frame(Y=I(Y[-ind]),X=I(X[-ind,])) gTrain- data.frame(Y=I(Y[ind]),X=I(X[ind,])) svm.lin - svm(gTrain$X,gTrain$Y, kernel=linear,cost=c[i], cross=5) results.lin - predict(svm.lin, gTest$X) e.test.lin - sqrt(sum((results.lin-gTest$Y)^2)/length(gTest$Y)) return(e.test.lin) } } cl- makeCluster(2, type=SOCK ) clusterEvalQ(cl,library(e1071)) clusterExport(cl,c(NR,Y,X)) RMSEP-clusterApplyLB(cl,?,sv.lin,c=cost1) stopCluster(cl) cls59 wrote: raluca wrote: Hello, Is the first time I am using SNOW package and I am trying to tune the cost parameter for a linear SVM, where the cost (variable cost1) takes 10 values between 0.5 and 30. I have a large dataset and a pc which is not very powerful, so I need to tune the parameters using both CPUs of the pc. Somehow I cannot manage to do it. It seems that both CPUs are fitting the model for the same values of cost1, I guess the first 5, but not for the last 5. Please, can anyone help me! Here is the code: data - data.frame(Y=I(Y),X=I(X)) data.X-data$X data.Y-data$Y Helping you will be difficult as we're only three lines into your example and already I have no idea what the data you are using looks like. Example code needs to be fully reproducible-- that means a small slice of representative data needs to be provided or faked using an appropriate random number generator. Some things did jump out at me about your approach and I've made some notes below. raluca wrote: NR=10 cost1=seq(0.5,30, length=NR) sv.lin- function(cl,c) { for (i in 1:NR) { ind=sample(1:414,276) hogTest- data.frame(Y=I(data.Y[-ind]),X=I(data.X[-ind,])) hogTrain- data.frame(Y=I(data.Y[ind]),X=I(data.X[ind,])) svm.lin- svm(hogTrain$X,hogTrain$Y, kernel=linear,cost=c[i], cross=5) results.lin - predict(svm.lin, hogTest$X) e.test.lin - sqrt(sum((results.lin-hogTest$Y)^2)/length(hogTest$Y)) return(e.test.lin) } } cl- makeCluster(10, type=SOCK ) If your machine has two cores, why are you setting up a cluster with 10 nodes? Usually the number of nodes should equal the number of cores on your machine in order to keep things efficient. raluca wrote: clusterEvalQ(cl,library(e1071)) clusterExport(cl,c(data.X,data.Y,NR,cost1)) RMSEP-clusterApplyLB(cl,cost1,sv.lin) Are you sure this evaluation even produces results? sv.lin() is a function you defined above that takes two parameters-- cl and c. clusterApplyLB() will feed values of cost1 into sv.lin() for the argument cl, but it has nothing to give for c. At the very least, it seems like you would need something like: RMSEP - clusterApplyLB( cl, cost1, sv.lin, c = someVector ) raluca wrote: stopCluster(cl) Sorry I can't be very helpful, but with no data and no apparent way to legally call sv.lin() the way you have it set up, I can't investigate the problem to see if I get the same results you described. If you could provide a complete working example, then there's a better chance that someone on this list will be able to help you. Good luck! -Charlie -- View this message in context: http://old.nabble.com/SVM-Param-Tuning-with-using-SNOW-package-tp26399401p26406709.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] where can I download package svIO?
Hello, today I upgraded R to 2.10 and Tinn-R to 2.3.3.1. Tinn-R needs the package svIO, but it is not available anymore on the package lists. Every session I start R and chose the CRAN-Mirror I receive the following warning: Bitte einen CRAN Spiegel für diese Sitzung auswählen --- Warnmeldung: In getDependencies(pkgs, dependencies, available, lib) : package svIO is not available Lade Tcl/Tk Interface ... fertig Fehler in library(svIO) : es gibt kein Paket 'svIO' I found a similar problem for svMisc a few weeks ago (http://www.mail-archive.com/r-help@r-project.org/msg74057.html). Will there be a new svIO-package the next weeks or is it included anywhere elso now? Thanks for your help, dagmar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Spectrum confidence interval
Dear useRs, I'd like to plot a confidence interval on a periodogram. My problem is that spec.pgram(sunspots,ci=0.95,log=yes) gives me a blue error bar on the plot, but spec.pgram(sunspots,ci=0.95,log=no) does not. My questions are: 1. how should I plot the confidence interval with log=no? 2. how should I get the min and max values of the confidence interval? Many thanks for your help! Clement Poirier __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Effective measurement of point-polygon distance
Dear list I have two datasets, one with a large number of point coordinates, the other with spatial polygons. I want to measure the shortest distance from each point to the border of all polygons, and then store the results as a column in a data frame. (Or a vector that can be turned into a column in a data frame). The points and polygons represent different types of events, happening at different times. My next step will therefore be to add dates to each event pair in order to measure the distance in space and time. Both are stored in datasets, so that each row represents one event. I have (i think) the distance measurement in order, the problem is to get the results into the data frame in an efficient manner. I am thinking of something like a double for-loop, but can't get it to work. I am also having problems reproducing my list of spatial polygons in a simple way here, but hope that my explanation is sufficient. # Making two test areas: library(sp) w1 - SpatialLines(list(Lines(list(Line(cbind( c(80,85,87,90,85,80), c(10,15,17,15,10,10) )) w2 - SpatialLines(list(Lines(list(Line(cbind( c(65,67,76,68,65), c(30,29,24,22,30) )) # Test points: x = c(5, 7, 35, 28) y = c(60, 70, 90, 85) xy - SpatialPoints(cbind(y,x)) distance - rep(NA, 4) for (i in 1:4){distance[i] - min(spDistsN1(coordinates(spsample((w1), n=50, type = regular)), coordinates(xy[i,]), longlat=T))} for (i in 1:4){distance[i] - min(spDistsN1(coordinates(spsample((w2), n=50, type = regular)), coordinates(xy[i,]), longlat=T))} distance # What I need, is a for-loop (or something similar) that goes through the list of polygons, checks the minimum # distance to each point for each polygon, and stores the results as a vector/variable of length (number of polygons * number of points.), # so that the final result after going through all the events of both types look somewhat like wanted. wanted - c(2066.438, 1671.135, 1829.517, 1013.759, 2290.192, 1150.286, 2013.819, 1247.204) wanted # It sounds, and probably is, quite simple - yet I'm completely stuck... - Neru [[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] Switch Help
Thanks for the Rxpert advice! I am up and running again... Oscar On Wed, Nov 18, 2009 at 5:57 AM, Colin Millar c.mil...@marlab.ac.uk wrote: I think you just missed some commas out... aar - function(command = c(scrn, dx, df)) { command - match.arg(command) switch(command, scrn = cat(scrn :Screening,\n), dx = cat(dx:Diagnosis,\n), df = cat(df:Don't Forget,\n) ) } Colin. Ps you don't need the curly brackets here if theres only one expresion, and sometimes its good to restrict the inputs to only those you want So that aar(something wrong) # Error in match.arg(command) : 'arg' should be one of scrn, dx, df -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of oscar linares Sent: 18 November 2009 10:40 To: r-help@r-project.org Subject: [R] Switch Help Dear Rexperts, Given, aar -function(command) { switch(command, {scrn = cat(scrn :Screening,\n)} {dx = cat(dx:Diagnosis,\n)} {df = cat(df:Don't Forget,\n)} ) } I want to be able to do: aar(dx) # function does cat(dx:Diagnosis,\n) aar(c(dx,df)) # function does cat(dx:Diagnosis,\n) # function does df = cat(df:Don't Forget,\n) BUT IT IS NOT WORKING FOR ME. Please help:-) -- Oscar Oscar A. Linares, MD Translational Medicine Unit LaPlaisance Bay, Bolles Harbor Monroe, Michigan [[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. __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ -- Oscar Oscar A. Linares, MD Translational Medicine Unit LaPlaisance Bay, Bolles Harbor Monroe, Michigan [[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] parsing numeric values
Thanks a lot, both of you. Incidentally, I made R crash when I forgot the X argument to strapply, library(gsubfn) Loading required package: tcltk Loading Tcl/Tk interface ... done strapply(test, as.numeric) *** caught bus error *** address 0x13c, cause 'non-existent physical address' Traceback: 1: .External(dotTclcallback, ..., PACKAGE = tcltk) 2: .Tcl.callback(x, e) 3: makeAtomicCallback(x, e) 4: makeCallback(get(value, envir = ref), get(envir, envir = ref)) 5: FUN(X[[3L]], ...) 6: lapply(val, val2obj) 7: .Tcl.args.objv(...) 8: structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class = tclObj) 9: .Tcl.objv(.Tcl.args.objv(...)) 10: tcl(set, e, e) 11: strapply1(x, pattern, backref, ignore.case) 12: FUN(test[[1L]], ...) 13: lapply(X, FUN, ...) 14: sapply(X, ff, simplify = is.logical(simplify) simplify, USE.NAMES = USE.NAMES) 15: strapply(test, as.numeric) Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace sessionInfo() R version 2.10.0 (2009-10-26) i386-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets grid methods [8] base other attached packages: [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9 proto_0.3-8fortunes_1.3-6 2009/11/18 Gabor Grothendieck ggrothendi...@gmail.com: A minor variant might be the following: library(gsubfn) strapply(input, \\d+\\.\\d+E[-+]?\\d+, as.numeric, simplify = rbind) where: - as.numeric is used in place of c in which case we do not need combine - \\d+ matches one or more digits - \\. matches a decimal point - [-+]? matches -, + or nothing (i.e. an optional sign). - parentheses around the regular expression not needed On Wed, Nov 18, 2009 at 7:28 AM, Henrique Dallazuanna www...@gmail.com wrote: Try this: strapply(input, ([0-9]+\\.[0-9]+E-[0-9]+), c, simplify = rbind, combine = as.numeric) On Wed, Nov 18, 2009 at 9:57 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax = 1.3770E-03 bx = 3.4644E-07 ay = 1.9412E-04 by = 4.8840E-08 other text aax = 1.3770E-03 bbx = 3.4644E-07 aay = 1.9412E-04 bby = 4.8840E-08)) ## this is what I want results - c(as.numeric(strsplit(grep(ax, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(ay, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(aax, input,val=T), )[[1]][9]), as.numeric(strsplit(grep(aay, input,val=T), )[[1]][9]) ) ## [1] 0.00137700 0.00019412 0.00137700 0.00019412 The use of strsplit is not ideal here as there is a different number of space characters in the lines containing ax and aax for instance (hence the indices 8 and 9 respectively). I tried to use gsubfn for a cleaner construct, strapply(input, ax += +([0-9.]+), c, simplify=rbind,combine=as.numeric) but I can't seem to find the correct regular expression to deal with the exponent. Any tips are welcome! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Presentation of data in Graphical format
I would start with ?boxplot -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Nov 18, 2009 at 2:47 PM, Sunita Patil sunita...@gmail.com wrote: Thanx but I am not able to find a graph that wud suit my data Regards Our Thoughts have the Power to Change our Destiny. Sunita On Sun, Nov 15, 2009 at 8:54 PM, milton ruser milton.ru...@gmail.com wrote: Google R graph grallery Google R ggplot2 Google R lattice and good luck milton On Sun, Nov 15, 2009 at 7:48 AM, Sunita22 sunita...@gmail.com wrote: Hello My data contains following columns: 1st column: Posts (GM, Secretary, AM, Office Boy) 2nd Column: Dept (Finance, HR, ...) 3rd column: Tasks (Open the door, Fix an appointment, Fill the register, etc.) depending on the post 4th column: Average Time required to do the task So the sample data would look like PostsDeptTask Average time Office Boy HR Open the door 00:00:09 Secretary FinanceFix an appointment00.00.30 . .. I am trying to represent this data in Graphical format, I tried graphs like Mosaic plot, etc. But it does not represent the data correctly. My aim is to check the amount of time and its variability for groups of tasks Thank you in advance Regards Sunita -- View this message in context: http://old.nabble.com/Presentation-of-data-in-Graphical-format-tp26358857p26358857.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 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. [[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] where can I download package svIO?
Hello, All sv packages are undergoing a major revision that makes them incompatible for some functions with the previous ones (among them, functions that were used by Tinn-R. However, Tinn-R is now supposed to use its own TinnR packages that uses its own version of the old functions, so that refarctoring of new ones is possible. On CRAN, you find this description: TinnR: Resources of Tinn-R GUI/Editor for R Environment Implements a set of customized functions, adapted from svIDE, svMisc and svIO packages of Philippe Grosjean, necessary to Tinn-R GUI/Editor for R environment Version:1.0.3 Depends:R (? 2.6.0), utils, tcltk, Hmisc, R2HTML Published: 2009-02-10 Author: Jose Claudio Faria, based on the sources of Philippe Grosjean Maintainer: Jose Claudio Faria joseclaudio.faria at gmail.com License:GPL (? 2) Citation: TinnR citation info CRAN checks:TinnR results So, you are better to contact Jose Claudio Faria, because you should not have a dependecy on svIO any more for Tinn-R. Abest, Philippe Grosjean ..°})) ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. Dagmar Orlikowski wrote: Hello, today I upgraded R to 2.10 and Tinn-R to 2.3.3.1. Tinn-R needs the package svIO, but it is not available anymore on the package lists. Every session I start R and chose the CRAN-Mirror I receive the following warning: Bitte einen CRAN Spiegel für diese Sitzung auswählen --- Warnmeldung: In getDependencies(pkgs, dependencies, available, lib) : package ‘svIO’ is not available Lade Tcl/Tk Interface ... fertig Fehler in library(svIO) : es gibt kein Paket 'svIO' I found a similar problem for svMisc a few weeks ago (http://www.mail-archive.com/r-help@r-project.org/msg74057.html). Will there be a new svIO-package the next weeks or is it included anywhere elso now? Thanks for your help, dagmar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] reduce matrix
On Wed, 18 Nov 2009 04:18:08 -0800 (PST) lloyd barcza floyd...@yahoo.com wrote: I am trying to reduce the dimension of matrix by removing zero elements and creating a sub-matrix. For example: A= [1,0,0,3; 0,1,2,0; 0,0,3,5] then the new matrix B would be: B= [1,3;1,2;3,5] There are the same number of zero elements in each row of A so dimension of B will not be a problem. This should work: B=matrix(t(A)[t(A)!=0], nrow=nrow(A), byrow=TRUE) -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Importing tRNA data into R ?
Hi Tal, Tal Galili wrote: Hello dear R help group, I would like to download the tRNA data on: http://gtrnadb.ucsc.edu/download.html And then import it into R. Can anyone direct me as to how to do so? You probably want the readFASTA() function in Biostrings, which is part of Bioconductor. There are several packages in BioC that are useful for doing things with sequence data once read in, depending on what your purpose is. Further questions should probably be directed to the BioC listserv bioconduc...@stat.math.ethz.ch. Best, Jim Thanks, Tal -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- James W. MacDonald, M.S. Biostatistician Douglas Lab University of Michigan Department of Human Genetics 5912 Buhl 1241 E. Catherine St. Ann Arbor MI 48109-5618 734-615-7826 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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 system is computationally singular by using function dmvnorm
Dear R users, i try to use function dmvnorm(x, mean, sigma, log=FALSE) from R package mvtnorm to calculate the probability of x under the multivariate normal distribution with mean equal to mean and covariance matrix sigma. I become the following Error in solve.default(cov, ...) : system is computationally singular: reciprocal condition number = 1.81093e-19 What could be the reason of it? Thank you in Advance, Alla. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xts timeseries
Hi, I try to calculate the correlation between macroeconomic data from FRED vs Market Data However, since the timeseries are not in synch, the correlation fails. require(quantmod) USPBS =get(getSymbols(USPBS, src=FRED )) USPBS = USPBS['1983-1-1::'] monDMANEMP = Cl(to.monthly(USPBS)) length(monDMANEMP) [1] 312 head(monDMANEMP) USPBS.Close Oct 19838192 Nov 19838231 Dec 19838265 Jan 19848309 Feb 19848344 Mar 19848382 symbol = getSymbols(^DJA,from = 1983-01-01,to=Sys.Date()) market = Cl(get(symbol)) monMarket = Cl(to.monthly(market)) length(monMarket) [1] 314 head(monMarket) market.Close Oct 1983 494.18 Nov 1983 510.77 Dec 1983 502.94 Jan 1984 483.46 Feb 1984 454.97 Mar 1984 456.65 Now I try to calculate the correlation cor(monMarket, monDMANEMP) Error in cor.default(monMarket, monDMANEMP) : incompatible dimensions #This makes sense since my Market data is two data points longer. #However if I try to merge them to get them aligned on one time axis, I get this head(merge.xts(monMarket, monDMANEMP)) market.Close USPBS.Close Oct 1983 494.18 NA Nov 1983 NA8192 Nov 1983 510.77 NA Dec 1983 NA8231 Dec 1983 502.94 NA Jan 1984 NA8265 #If I try cbind the same happens head(cbind(monMarket, monDMANEMP)) market.Close USPBS.Close Oct 1983 494.18 NA Nov 1983 NA8192 Nov 1983 510.77 NA Dec 1983 NA8231 Dec 1983 502.94 NA Jan 1984 NA8265 #If I then continue to align both of the timeseries on one standard axis l= (round(Sys.Date()-as.Date(01JAN1983, %d%b%Y))) timeline = to.monthly(xts(1:l, as.Date(01JAN1983, %d%b%Y)+1:l)) alignbar = xts(, index(timeline)) alMonMarket = merge.xts(alignbar, monMarket) almonDMANEMP = merge.xts(alignbar, monDMANEMP) x = merge.xts(alMonMarket, almonDMANEMP) head(x) market.Close USPBS.Close Jan 1983 NA NA Feb 1983 NA NA Mar 1983 NA NA Apr 1983 NA NA May 1983 NA NA Jun 1983 NA NA Any pointer towards the error is highly appreciated Jan [[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] A combinatorial optimization problem: finding the best permutation of a complex vector
Hi Erwin, Thank you for the information about Cplex. It seems quite impressive. Is it a proprietary software? I saw that there is a Matlab interface to it. Is there an R interface? Thanks, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erwin Kalvelagen Sent: Wednesday, November 18, 2009 12:20 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] A combinatorial optimization problem: finding the best permutation of a complex vector Ravi Varadhan rvaradhan at jhmi.edu writes: When I increased N = 1000, the time was about 1400 seconds! Not sure of this is important for you: This can be solved much faster. A good solver can solve the n=1000 problem in less than 2 seconds. The Cplex network code shows: Network - Optimal: Objective = 1.6173194067e+003 Network time =1.58 sec. Iterations = 209126 (102313) Even solved as an LP this takes about 150 seconds. (The solutions are the same as reported by solve_LSAP). Erwin Kalvelagen Amsterdam Optimization Modeling Group er...@amsterdamoptimization.com http://amsterdamoptimization.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] Importing tRNA data into R ?
A warm thank you to both James and Benilton. James, I will go on that list and start looking around. Best, Tal -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Nov 18, 2009 at 4:27 PM, James W. MacDonald jmac...@med.umich.eduwrote: Hi Tal, Tal Galili wrote: Hello dear R help group, I would like to download the tRNA data on: http://gtrnadb.ucsc.edu/download.html And then import it into R. Can anyone direct me as to how to do so? You probably want the readFASTA() function in Biostrings, which is part of Bioconductor. There are several packages in BioC that are useful for doing things with sequence data once read in, depending on what your purpose is. Further questions should probably be directed to the BioC listserv bioconduc...@stat.math.ethz.ch. Best, Jim Thanks, Tal -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- James W. MacDonald, M.S. Biostatistician Douglas Lab University of Michigan Department of Human Genetics 5912 Buhl 1241 E. Catherine St. Ann Arbor MI 48109-5618 734-615-7826 [[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] SVM Param Tuning with using SNOW package
I cannot really be sure what you are trying to do, but doing a bit of surgery on your code lets it run on a multicore Mac: library(e1071) library(snow) library(pls) data(gasoline) X=gasoline$NIR Y=gasoline$octane NR=10 cost1=seq(0.5,30, length=NR) sv.lin- function(c) { for (i in 1:NR) { ind=sample(1:60,50) gTest- data.frame(Y=I(Y[-ind]),X=I(X[-ind,])) gTrain- data.frame(Y=I(Y[ind]),X=I(X[ind,])) svm.lin - svm(gTrain$X,gTrain$Y, kernel=linear,cost=c[i], cross=5) results.lin - predict(svm.lin, gTest$X) e.test.lin - sqrt(sum((results.lin-gTest$Y)^2)/length(gTest$Y)) return(e.test.lin) } } cl- makeCluster(2, type=SOCK ) clusterEvalQ(cl, library(e1071)) cost1=seq(0.5,30, length=NR) clusterExport(cl,c(NR,Y,X, cost1)) # Pretty sure you need a copy of cost1 on each node. RMSEP-clusterApply(cl, cost1, sv.lin) # I thought the second argument was the matrix or vector over which to iterate. stopCluster(cl) # Since I don't know what the model meant, I cannot determine whehter this result is interpretable RMSEP [[1]] [1] 0.1921887 [[2]] [1] 0.1924917 [[3]] [1] 0.1885066 [[4]] [1] 0.1871466 [[5]] [1] 0.3550932 [[6]] [1] 0.1226460 [[7]] [1] 0.2426345 [[8]] [1] 0.2126299 [[9]] [1] 0.2276286 [[10]] [1] 0.2064534 -- David Winsemius, MD On Nov 18, 2009, at 7:09 AM, raluca wrote: Hi Charlie, Yes, you are perfectly right, when I make the clusters I should put 2, not 10 (it remained 10 from previous trials with 10 slaves). cl- makeCluster(2, type=SOCK ) To tell the truth I do not understand very well what the 2nd parameter for clusterApplyLB() has to be. If the function sv.lin has just 1 parameter, sv.lin(c), where c is the cost, how should I call clusterApplyLB? ? clusterApply LB(cl, ?,sv.lin, c=cost1) ? Below, I am providing a working example, using the gasoline data that comes in the pls package. Thank you for your time! library(e1071) library(snow) library(pls) data(gasoline) X=gasoline$NIR Y=gasoline$octane NR=10 cost1=seq(0.5,30, length=NR) sv.lin- function(c) { for (i in 1:NR) { ind=sample(1:60,50) gTest- data.frame(Y=I(Y[-ind]),X=I(X[-ind,])) gTrain- data.frame(Y=I(Y[ind]),X=I(X[ind,])) svm.lin - svm(gTrain$X,gTrain$Y, kernel=linear,cost=c[i], cross=5) results.lin - predict(svm.lin, gTest$X) e.test.lin - sqrt(sum((results.lin-gTest$Y)^2)/length(gTest$Y)) return(e.test.lin) } } cl- makeCluster(2, type=SOCK ) clusterEvalQ(cl,library(e1071)) clusterExport(cl,c(NR,Y,X)) RMSEP-clusterApplyLB(cl,?,sv.lin,c=cost1) stopCluster(cl) cls59 wrote: raluca wrote: Hello, Is the first time I am using SNOW package and I am trying to tune the cost parameter for a linear SVM, where the cost (variable cost1) takes 10 values between 0.5 and 30. I have a large dataset and a pc which is not very powerful, so I need to tune the parameters using both CPUs of the pc. Somehow I cannot manage to do it. It seems that both CPUs are fitting the model for the same values of cost1, I guess the first 5, but not for the last 5. Please, can anyone help me! Here is the code: data - data.frame(Y=I(Y),X=I(X)) data.X-data$X data.Y-data$Y Helping you will be difficult as we're only three lines into your example and already I have no idea what the data you are using looks like. Example code needs to be fully reproducible-- that means a small slice of representative data needs to be provided or faked using an appropriate random number generator. Some things did jump out at me about your approach and I've made some notes below. raluca wrote: NR=10 cost1=seq(0.5,30, length=NR) sv.lin- function(cl,c) { for (i in 1:NR) { ind=sample(1:414,276) hogTest- data.frame(Y=I(data.Y[-ind]),X=I(data.X[-ind,])) hogTrain- data.frame(Y=I(data.Y[ind]),X=I(data.X[ind,])) svm.lin - svm(hogTrain$X,hogTrain$Y, kernel=linear,cost=c[i], cross=5) results.lin - predict(svm.lin, hogTest$X) e.test.lin - sqrt(sum((results.lin-hogTest$Y)^2)/ length(hogTest$Y)) return(e.test.lin) } } cl- makeCluster(10, type=SOCK ) If your machine has two cores, why are you setting up a cluster with 10 nodes? Usually the number of nodes should equal the number of cores on your machine in order to keep things efficient. raluca wrote: clusterEvalQ(cl,library(e1071)) clusterExport(cl,c(data.X,data.Y,NR,cost1)) RMSEP-clusterApplyLB(cl,cost1,sv.lin) Are you sure this evaluation even produces results? sv.lin() is a function you defined above that takes two parameters-- cl and c. clusterApplyLB() will feed values of cost1 into sv.lin() for the argument cl, but it has nothing to give for c. At the very least, it seems like you would need something like: RMSEP - clusterApplyLB( cl, cost1, sv.lin, c = someVector ) raluca wrote: stopCluster(cl) Sorry I can't be very helpful, but with no data and no apparent way to legally call sv.lin() the way you have it set up, I can't investigate the
Re: [R] A combinatorial optimization problem: finding the best permutation of a complex vector
I just saw that Cplex is a commercial software from ILOG/IBM, and that there is an R interface, Rcplex, for it. While this is bad news, it is still encouraging to know that the LSAP problem can be solved faster. I will keep looking for better/faster open source algorithms. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ravi Varadhan Sent: Wednesday, November 18, 2009 9:39 AM To: 'Erwin Kalvelagen'; r-h...@stat.math.ethz.ch Subject: Re: [R] A combinatorial optimization problem: finding the best permutation of a complex vector Hi Erwin, Thank you for the information about Cplex. It seems quite impressive. Is it a proprietary software? I saw that there is a Matlab interface to it. Is there an R interface? Thanks, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erwin Kalvelagen Sent: Wednesday, November 18, 2009 12:20 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] A combinatorial optimization problem: finding the best permutation of a complex vector Ravi Varadhan rvaradhan at jhmi.edu writes: When I increased N = 1000, the time was about 1400 seconds! Not sure of this is important for you: This can be solved much faster. A good solver can solve the n=1000 problem in less than 2 seconds. The Cplex network code shows: Network - Optimal: Objective = 1.6173194067e+003 Network time =1.58 sec. Iterations = 209126 (102313) Even solved as an LP this takes about 150 seconds. (The solutions are the same as reported by solve_LSAP). Erwin Kalvelagen Amsterdam Optimization Modeling Group er...@amsterdamoptimization.com http://amsterdamoptimization.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error system is computationally singular by using function dmvnorm
It means that your covariance matrix sigma is numerically singular. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alla Bulashevska Sent: Wednesday, November 18, 2009 9:11 AM To: r-help@r-project.org Subject: [R] Error system is computationally singular by using function dmvnorm Dear R users, i try to use function dmvnorm(x, mean, sigma, log=FALSE) from R package mvtnorm to calculate the probability of x under the multivariate normal distribution with mean equal to mean and covariance matrix sigma. I become the following Error in solve.default(cov, ...) : system is computationally singular: reciprocal condition number = 1.81093e-19 What could be the reason of it? Thank you in Advance, Alla. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] levelplot
Hi, R Users When I use the default package lattice, I found a problem about adjusting the Figure Margin that can be changed by par(mai or mar) in traditional plots. So it's hard for me to add top and right axis. Any suggestions will be appreciated. -- Wenjun [[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] foor loop - undefined columns selected error
Dear R-Help Members, I am trying to read and analyse a set of 100 csv files. I need work only on some columns in each of those, so I decided to use a for loop, isolate the column in each file to work on, but then an error mesage appear: undefined columns selected Here is my code: setwd(F:/Data/) a-list.files() for (x in a) { u-read.csv(x, header=T, sep=,, check.names=FALSE) #it give me the same problem using read.table h-u[,2] } Error in `[.data.frame`(u, , 2) : undefined columns selected It does not give me any problem selecting ane entire row (e.g. u[2,]) or a single value (e.g. [5,2]) If I try to select a column after the for loop I does not show any problem, e.g.: a-list.files() for (x in a) { u-read.csv(x, header=T, sep=,, check.names=FALSE) } h-u[,2] I would appreciate any suggestion or pointer to solve the problem or to do the same thing in a different way. Thanks for your consideration -- Michela Leonardi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Presentation of data in Graphical format
Yes I tried all the basic ones like box plot, pie chart, etc but the data representation isnt that clear. Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 7:20 PM, Tal Galili tal.gal...@gmail.com wrote: I would start with ?boxplot -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Nov 18, 2009 at 2:47 PM, Sunita Patil sunita...@gmail.com wrote: Thanx but I am not able to find a graph that wud suit my data Regards Our Thoughts have the Power to Change our Destiny. Sunita On Sun, Nov 15, 2009 at 8:54 PM, milton ruser milton.ru...@gmail.com wrote: Google R graph grallery Google R ggplot2 Google R lattice and good luck milton On Sun, Nov 15, 2009 at 7:48 AM, Sunita22 sunita...@gmail.com wrote: Hello My data contains following columns: 1st column: Posts (GM, Secretary, AM, Office Boy) 2nd Column: Dept (Finance, HR, ...) 3rd column: Tasks (Open the door, Fix an appointment, Fill the register, etc.) depending on the post 4th column: Average Time required to do the task So the sample data would look like PostsDeptTask Average time Office Boy HR Open the door 00:00:09 Secretary FinanceFix an appointment00.00.30 . .. I am trying to represent this data in Graphical format, I tried graphs like Mosaic plot, etc. But it does not represent the data correctly. My aim is to check the amount of time and its variability for groups of tasks Thank you in advance Regards Sunita -- View this message in context: http://old.nabble.com/Presentation-of-data-in-Graphical-format-tp26358857p26358857.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 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. [[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] Problems by saving Rprofile.site under vista
Hello, I found a solution to the problem, quite easy. The R paste was on read-only, so I went to the properties/security. Apparently he considers me as a user and not an administrator when I open the files so I just gave the users ( me) the authorization to modificate and it worked. anna_l wrote: Hi Charles, I´ve already been running it as an administrator this is why I don´t understand it. Charles Annis, P.E. wrote: You may have to run R as Administrator (right-click, choose run as administrator) to make these kinds of changes. After you have things the way you like them, run R in the usual way by clicking on the icon. Charles Annis, P.E. charles.an...@statisticalengineering.com 561-352-9699 http://www.StatisticalEngineering.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of anna_l Sent: Friday, November 13, 2009 11:46 AM To: r-help@r-project.org Subject: [R] Problems by saving Rprofile.site under vista Hello, I am trying to save some changes I have done on the Rprofile.site under vista and it doesn´t let me save the file saying that it can´t create the following file (Rprofile.site) and that I should check the pathfile or the file name. -- View this message in context: http://old.nabble.com/Problems-by-saving-Rprofile.site-under-vista-tp26339605p26339605.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. - Anna Lippel new in R so be careful I should be asking a lt of questions!:teeth: -- View this message in context: http://old.nabble.com/Problems-by-saving-Rprofile.site-under-vista-tp26339605p26408392.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] vignettes: .png graphics or pre-compiled .pdf
Achim Zeileis wrote: On Fri, 13 Nov 2009, Michael Friendly wrote: Alternatively, is there a way to generate .png graphs from the .Rnw file so that those are used in building the .pdf for the package? AFAICS, \SweaveOpts{} offers only the choices of eps/pdf = {TRUE/FALSE}. Yes, but you can call the png() device yourself within the code chunk = png(file = fig1.png, ...) ... dev.off() @ and then put \includegraphics{fig1} manually into the LaTeX. It's certainly not as nice as Sweave's automatic handling of figures but will work and still keep the file self-contained. Z Thanks, Achim This works, but has the infelicitous effect that both the png() call and dev.off(), with its output appear in the vignette (with echo=TRUE) % do .png manually ... fig1cpng, fig=TRUE, pdf=FALSE, eval=TRUE, echo=TRUE, debug=TRUE, results=verbatim, include=FALSE= png(file=figs/fig-fig1c.png, width=4, height=4, units=in, res=72) # plot stuff ... dev.off() @ I suppose I could break this up into 3 chunks as follows, but is there some other way, either with R or LaTeX constructs? echo=FALSE= png(file=figs/fig-fig1c.png, width=4, height=4, units=in, res=72) @ fig1cpng, fig=TRUE, pdf=FALSE, eval=TRUE, echo=TRUE, debug=TRUE, results=verbatim, include=FALSE= # plot stuff ... @ echo=FALSE= dev.off() @ -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A combinatorial optimization problem: finding the best permutation of a complex vector
Ravi: Cplex use to be an independent firm. Was acquired by Ilog which was acquired by IBM. It has a nice callable API which is written in C++. It is a very good product. The other optimizer you might want to look at that performs fast is FortMP which might provide source code also. I last re-call it was written in Fortran And they had some kind of academic pricing. http://www.optirisk-systems.com/default.asp Cplex and FortMp performance was very close both are good. I have used both as standalone program and via the API calls. Another less expensive Optimizer is Loqo from Princeton. http://www.princeton.edu/~rvdb/loqo/LOQO.html The optimizer to select depends on the model trying to solve. I suggest you look at Optimization Software Guide by Jorge J. Moré and Stephen J. Wright Available from SIAM: http://www.ec-securehost.com/SIAM/FR14.html Hope this detail helps! Neil Gottlieb -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ravi Varadhan Sent: Wednesday, November 18, 2009 9:39 AM To: 'Erwin Kalvelagen'; r-h...@stat.math.ethz.ch Subject: Re: [R] A combinatorial optimization problem: finding the best permutation of a complex vector Hi Erwin, Thank you for the information about Cplex. It seems quite impressive. Is it a proprietary software? I saw that there is a Matlab interface to it. Is there an R interface? Thanks, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erwin Kalvelagen Sent: Wednesday, November 18, 2009 12:20 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] A combinatorial optimization problem: finding the best permutation of a complex vector Ravi Varadhan rvaradhan at jhmi.edu writes: When I increased N = 1000, the time was about 1400 seconds! Not sure of this is important for you: This can be solved much faster. A good solver can solve the n=1000 problem in less than 2 seconds. The Cplex network code shows: Network - Optimal: Objective = 1.6173194067e+003 Network time =1.58 sec. Iterations = 209126 (102313) Even solved as an LP this takes about 150 seconds. (The solutions are the same as reported by solve_LSAP). Erwin Kalvelagen Amsterdam Optimization Modeling Group er...@amsterdamoptimization.com http://amsterdamoptimization.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Presentation of data in Graphical format
Hi r-help-boun...@r-project.org napsal dne 18.11.2009 16:01:27: Yes I tried all the basic ones like box plot, pie chart, etc but the data representation isnt that clear. I agree with Tal. But it partly depends on your data. If you have many levels and only few time values in each boxplot would not look well. Maybe you could check also ?xtabs or ?table and/or R graph gallery http://addictedtor.free.fr/graphiques/ if you find suitable graph. Regards Petr Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 7:20 PM, Tal Galili tal.gal...@gmail.com wrote: I would start with ?boxplot -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Nov 18, 2009 at 2:47 PM, Sunita Patil sunita...@gmail.com wrote: Thanx but I am not able to find a graph that wud suit my data Regards Our Thoughts have the Power to Change our Destiny. Sunita On Sun, Nov 15, 2009 at 8:54 PM, milton ruser milton.ru...@gmail.com wrote: Google R graph grallery Google R ggplot2 Google R lattice and good luck milton On Sun, Nov 15, 2009 at 7:48 AM, Sunita22 sunita...@gmail.com wrote: Hello My data contains following columns: 1st column: Posts (GM, Secretary, AM, Office Boy) 2nd Column: Dept (Finance, HR, ...) 3rd column: Tasks (Open the door, Fix an appointment, Fill the register, etc.) depending on the post 4th column: Average Time required to do the task So the sample data would look like PostsDeptTask Average time Office Boy HR Open the door 00:00:09 Secretary FinanceFix an appointment00.00.30 . . . I am trying to represent this data in Graphical format, I tried graphs like Mosaic plot, etc. But it does not represent the data correctly. My aim is to check the amount of time and its variability for groups of tasks Thank you in advance Regards Sunita -- View this message in context: http://old.nabble.com/Presentation-of-data-in-Graphical-format- tp26358857p26358857.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 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. [[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] vignettes: .png graphics or pre-compiled .pdf
On Wed, 18 Nov 2009, Michael Friendly wrote: Achim Zeileis wrote: On Fri, 13 Nov 2009, Michael Friendly wrote: Alternatively, is there a way to generate .png graphs from the .Rnw file so that those are used in building the .pdf for the package? AFAICS, \SweaveOpts{} offers only the choices of eps/pdf = {TRUE/FALSE}. Yes, but you can call the png() device yourself within the code chunk = png(file = fig1.png, ...) ... dev.off() @ and then put \includegraphics{fig1} manually into the LaTeX. It's certainly not as nice as Sweave's automatic handling of figures but will work and still keep the file self-contained. Z Thanks, Achim This works, but has the infelicitous effect that both the png() call and dev.off(), with its output appear in the vignette (with echo=TRUE) % do .png manually ... fig1cpng, fig=TRUE, pdf=FALSE, eval=TRUE, echo=TRUE, debug=TRUE, results=verbatim, include=FALSE= png(file=figs/fig-fig1c.png, width=4, height=4, units=in, res=72) # plot stuff ... dev.off() @ I suppose I could break this up into 3 chunks as follows, but is there some other way, either with R or LaTeX constructs? echo=FALSE= png(file=figs/fig-fig1c.png, width=4, height=4, units=in, res=72) @ fig1cpng, fig=TRUE, pdf=FALSE, eval=TRUE, echo=TRUE, debug=TRUE, results=verbatim, include=FALSE= # plot stuff ... @ echo=FALSE= dev.off() @ I typically re-use the code chunks, e.g.: myplot, echo=TRUE, eval=FALSE= plot(...) @ myplot-png, echo=FALSE, eval=TRUE= png(...) myplot dev.off() @ which is also convenient if you want to add par() settings (e.g., mfrow/mfcol) and have the code somewhere in the text but the resulting figure in a floating environment. Z -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] converting a vector of bytes to a PNG/JPEG image
Hi, I have some code that uses rJava. One of the Java side methods returns a byte[] representing the bytes from a PNG image. What I'd like to do is to be able to bring up the PNG on the R side (I can bring up a Swing window to show the PNG but I want to avoid that). I have looked at the pixmap and rimage packages but don't seem to be able to work out how I'd go about this (or if it's at all possible). Does anybody have any pointers? Thanks, -- Rajarshi Guha NIH Chemical Genomics Center [[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] Presentation of data in Graphical format
I have been using R just very recently, I have gone through this http://addictedtor.free.fr/graphiques/ a few weeks back but I am not able to understand as to how to choose the graph amongst them? Can anyone guide me regarding this? Thanks in advance Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 8:42 PM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi r-help-boun...@r-project.org napsal dne 18.11.2009 16:01:27: Yes I tried all the basic ones like box plot, pie chart, etc but the data representation isnt that clear. I agree with Tal. But it partly depends on your data. If you have many levels and only few time values in each boxplot would not look well. Maybe you could check also ?xtabs or ?table and/or R graph gallery http://addictedtor.free.fr/graphiques/ if you find suitable graph. Regards Petr Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 7:20 PM, Tal Galili tal.gal...@gmail.com wrote: I would start with ?boxplot -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Nov 18, 2009 at 2:47 PM, Sunita Patil sunita...@gmail.com wrote: Thanx but I am not able to find a graph that wud suit my data Regards Our Thoughts have the Power to Change our Destiny. Sunita On Sun, Nov 15, 2009 at 8:54 PM, milton ruser milton.ru...@gmail.com wrote: Google R graph grallery Google R ggplot2 Google R lattice and good luck milton On Sun, Nov 15, 2009 at 7:48 AM, Sunita22 sunita...@gmail.com wrote: Hello My data contains following columns: 1st column: Posts (GM, Secretary, AM, Office Boy) 2nd Column: Dept (Finance, HR, ...) 3rd column: Tasks (Open the door, Fix an appointment, Fill the register, etc.) depending on the post 4th column: Average Time required to do the task So the sample data would look like PostsDeptTask Average time Office Boy HR Open the door 00:00:09 Secretary FinanceFix an appointment00.00.30 . . . I am trying to represent this data in Graphical format, I tried graphs like Mosaic plot, etc. But it does not represent the data correctly. My aim is to check the amount of time and its variability for groups of tasks Thank you in advance Regards Sunita -- View this message in context: http://old.nabble.com/Presentation-of-data-in-Graphical-format- tp26358857p26358857.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 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A combinatorial optimization problem: finding the best permutation of a complex vector
See also: http://yetanothermathprogrammingconsultant.blogspot.com/2009/11/assignment-problem.html http://yetanothermathprogrammingconsultant.blogspot.com/2009/11/assignment-problem.html Erwin Kalvelagen Amsterdam Optimization Modeling Group er...@amsterdamoptimization.com http://amsterdamoptimization.com On Wed, Nov 18, 2009 at 9:49 AM, Ravi Varadhan rvarad...@jhmi.edu wrote: I just saw that Cplex is a commercial software from ILOG/IBM, and that there is an R interface, Rcplex, for it. While this is bad news, it is still encouraging to know that the LSAP problem can be solved faster. I will keep looking for better/faster open source algorithms. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ravi Varadhan Sent: Wednesday, November 18, 2009 9:39 AM To: 'Erwin Kalvelagen'; r-h...@stat.math.ethz.ch Subject: Re: [R] A combinatorial optimization problem: finding the best permutation of a complex vector Hi Erwin, Thank you for the information about Cplex. It seems quite impressive. Is it a proprietary software? I saw that there is a Matlab interface to it. Is there an R interface? Thanks, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erwin Kalvelagen Sent: Wednesday, November 18, 2009 12:20 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] A combinatorial optimization problem: finding the best permutation of a complex vector Ravi Varadhan rvaradhan at jhmi.edu writes: When I increased N = 1000, the time was about 1400 seconds! Not sure of this is important for you: This can be solved much faster. A good solver can solve the n=1000 problem in less than 2 seconds. The Cplex network code shows: Network - Optimal: Objective = 1.6173194067e+003 Network time =1.58 sec. Iterations = 209126 (102313) Even solved as an LP this takes about 150 seconds. (The solutions are the same as reported by solve_LSAP). Erwin Kalvelagen Amsterdam Optimization Modeling Group er...@amsterdamoptimization.com http://amsterdamoptimization.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Creating an excel file and manipulating it from R
Hello everybody, I´ve been looking for a function that would create an excel file in my working directory where I would write my dataframe but I only found the functions to write or read in an existing file that you gave me on my former post or on some websites. I can´t find either functions to manipulate those datas: for example, I would like some lines to be red or green according to their value. Thank you in advance! - Anna Lippel new in R so be careful I should be asking a lt of questions!:teeth: -- View this message in context: http://old.nabble.com/Creating-an-excel-file-and-manipulating-it-from-R-tp26408408p26408408.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] Presentation of data in Graphical format
yes in my data the 1st column is the main category say suppose Secretary the second column is the sub category HR Dept the 3rd column is the list of duties performed by the Secretary from HR dept and 4th column is time required to perform the duty so there are many such posts and dept with varied duties and times resp. Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 8:42 PM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi r-help-boun...@r-project.org napsal dne 18.11.2009 16:01:27: Yes I tried all the basic ones like box plot, pie chart, etc but the data representation isnt that clear. I agree with Tal. But it partly depends on your data. If you have many levels and only few time values in each boxplot would not look well. Maybe you could check also ?xtabs or ?table and/or R graph gallery http://addictedtor.free.fr/graphiques/ if you find suitable graph. Regards Petr Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 7:20 PM, Tal Galili tal.gal...@gmail.com wrote: I would start with ?boxplot -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Nov 18, 2009 at 2:47 PM, Sunita Patil sunita...@gmail.com wrote: Thanx but I am not able to find a graph that wud suit my data Regards Our Thoughts have the Power to Change our Destiny. Sunita On Sun, Nov 15, 2009 at 8:54 PM, milton ruser milton.ru...@gmail.com wrote: Google R graph grallery Google R ggplot2 Google R lattice and good luck milton On Sun, Nov 15, 2009 at 7:48 AM, Sunita22 sunita...@gmail.com wrote: Hello My data contains following columns: 1st column: Posts (GM, Secretary, AM, Office Boy) 2nd Column: Dept (Finance, HR, ...) 3rd column: Tasks (Open the door, Fix an appointment, Fill the register, etc.) depending on the post 4th column: Average Time required to do the task So the sample data would look like PostsDeptTask Average time Office Boy HR Open the door 00:00:09 Secretary FinanceFix an appointment00.00.30 . . . I am trying to represent this data in Graphical format, I tried graphs like Mosaic plot, etc. But it does not represent the data correctly. My aim is to check the amount of time and its variability for groups of tasks Thank you in advance Regards Sunita -- View this message in context: http://old.nabble.com/Presentation-of-data-in-Graphical-format- tp26358857p26358857.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 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Writing a data frame in an excel file
Hi Charlie, I´ve been trying to use the sqlSave the way you showed me but it would give me this error message which I couldn´t solve: Erro em sqlSave(xlsFile, strategy, tablename = Result, rownames = FALSE) : table ‘Result’ already exists I would like to save the data frame in a specified worksheet but I couldn´t find in the help on sqlSave how to do it. cls59 wrote: anna_l wrote: Hello, I am having trouble by using the write.table function to write a data frame of 4 columns and 7530 rows. I don´t know if I should just use a sep=\n and change the .xls file into a .csv file. Thanks in advance Base R cannot write .xls files by it's self. You should output CSV using write.csv(): write.csv( dataFrame, file = 'results.csv' ) If you are using R on windows, then the RODBC package provides a mechanism for dumping data frames directly to Excel files, possibly with multiple sheets: require( RODBC ) xlsFile - odbcConnectExcel( 'results.xls', readOnly = F ) sqlSave( xlsFile, dataFrame, tablename = 'R Results', rownames = F ) odbcCloseAll() The tablename argument to sqlSave allows you to assign a name to the excel sheet that will contain the data.frame. -Charlie - Anna Lippel new in R so be careful I should be asking a lt of questions!:teeth: -- View this message in context: http://old.nabble.com/Writing-a-data-frame-in-an-excel-file-tp26378240p26408412.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] mann-whitney test with more groups
Dear r-helpers, I want to test groups of samples for significant differences. Question: Does Group1 differ significantly from group2. This is a question to be answered by mann-whitney-u-test. I know that I can use wilcox.test with 2 samples. My problem: How can r perform the test automatically if there are more than 2 groups in my data frame. Test group1 vs. 2, 1 vs. 3, 1 vs. 4, etc. This is my skript: Deckung - read.table(Gesamtdeckung.csv, sep=;, header=TRUE, dec=,, row.names=1) x - Deckung$Gesamtdeckung y - Deckung$Klasse #U-Test wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(1, 2)) wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(1, 3)) wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(2, 3)) Any help would be greatly appreciated! Thanks Kim -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Presentation of data in Graphical format
Yes I tried all the basic ones like box plot, pie chart, etc but the data representation isnt that clear. Given that you have neither provided your data, nor explained what you are trying to uncover from it, what sort of advice do you expect to get? Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] parsing numeric values
Thanks. This is now fixed in the development version so that it gives an error rather than crashing: library(gsubfn) Loading required package: proto Loading required package: tcltk Loading Tcl/Tk interface ... done source(http://gsubfn.googlecode.com/svn/trunk/R/gsubfn.R;) strapply(test, as.numeric) Error in as.character(pattern) : cannot coerce type 'builtin' to vector of type 'character' On Wed, Nov 18, 2009 at 8:49 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Thanks a lot, both of you. Incidentally, I made R crash when I forgot the X argument to strapply, library(gsubfn) Loading required package: tcltk Loading Tcl/Tk interface ... done strapply(test, as.numeric) *** caught bus error *** address 0x13c, cause 'non-existent physical address' Traceback: 1: .External(dotTclcallback, ..., PACKAGE = tcltk) 2: .Tcl.callback(x, e) 3: makeAtomicCallback(x, e) 4: makeCallback(get(value, envir = ref), get(envir, envir = ref)) 5: FUN(X[[3L]], ...) 6: lapply(val, val2obj) 7: .Tcl.args.objv(...) 8: structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class = tclObj) 9: .Tcl.objv(.Tcl.args.objv(...)) 10: tcl(set, e, e) 11: strapply1(x, pattern, backref, ignore.case) 12: FUN(test[[1L]], ...) 13: lapply(X, FUN, ...) 14: sapply(X, ff, simplify = is.logical(simplify) simplify, USE.NAMES = USE.NAMES) 15: strapply(test, as.numeric) Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace sessionInfo() R version 2.10.0 (2009-10-26) i386-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets grid methods [8] base other attached packages: [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9 proto_0.3-8 fortunes_1.3-6 2009/11/18 Gabor Grothendieck ggrothendi...@gmail.com: A minor variant might be the following: library(gsubfn) strapply(input, \\d+\\.\\d+E[-+]?\\d+, as.numeric, simplify = rbind) where: - as.numeric is used in place of c in which case we do not need combine - \\d+ matches one or more digits - \\. matches a decimal point - [-+]? matches -, + or nothing (i.e. an optional sign). - parentheses around the regular expression not needed On Wed, Nov 18, 2009 at 7:28 AM, Henrique Dallazuanna www...@gmail.com wrote: Try this: strapply(input, ([0-9]+\\.[0-9]+E-[0-9]+), c, simplify = rbind, combine = as.numeric) On Wed, Nov 18, 2009 at 9:57 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax = 1.3770E-03 bx = 3.4644E-07 ay = 1.9412E-04 by = 4.8840E-08 other text aax = 1.3770E-03 bbx = 3.4644E-07 aay = 1.9412E-04 bby = 4.8840E-08)) ## this is what I want results - c(as.numeric(strsplit(grep(ax, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(ay, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(aax, input,val=T), )[[1]][9]), as.numeric(strsplit(grep(aay, input,val=T), )[[1]][9]) ) ## [1] 0.00137700 0.00019412 0.00137700 0.00019412 The use of strsplit is not ideal here as there is a different number of space characters in the lines containing ax and aax for instance (hence the indices 8 and 9 respectively). I tried to use gsubfn for a cleaner construct, strapply(input, ax += +([0-9.]+), c, simplify=rbind,combine=as.numeric) but I can't seem to find the correct regular expression to deal with the exponent. Any tips are welcome! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Presentation of data in Graphical format
Hello Sir I had given a sample of my data, As I cannot disclose whole of my data this is just a sample given 1st column: Posts (GM, Secretary, AM, Office Boy) 2nd Column: Dept (Finance, HR, ...) 3rd column: Tasks (Open the door, Fix an appointment, Fill the register, etc.) depending on the post 4th column: Average Time required to do the task So the sample data would look like *PostsDeptTask Average time* Office Boy HR Open the door 00:00:09 Office Boy HR Switch on the lights 00:00:10 Secretary FinanceFix an appointment 00.00.30 . . . . . . in my data the 1st column is the main category say suppose Secretary the second column is the sub category HR Dept the 3rd column is the list of duties performed by the Secretary from HR dept and 4th column is time required to perform the duty so there are many such posts and dept with varied duties and times resp Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 9:15 PM, hadley wickham h.wick...@gmail.com wrote: Yes I tried all the basic ones like box plot, pie chart, etc but the data representation isnt that clear. Given that you have neither provided your data, nor explained what you are trying to uncover from it, what sort of advice do you expect to get? Hadley -- http://had.co.nz/ [[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] Creating an excel file and manipulating it from R
Try the RDCOMClient [1] package. [1]http://www.omegahat.org/RDCOMClient/ On Wed, Nov 18, 2009 at 1:31 PM, anna_l lippelann...@hotmail.com wrote: Hello everybody, I´ve been looking for a function that would create an excel file in my working directory where I would write my dataframe but I only found the functions to write or read in an existing file that you gave me on my former post or on some websites. I can´t find either functions to manipulate those datas: for example, I would like some lines to be red or green according to their value. Thank you in advance! - Anna Lippel new in R so be careful I should be asking a lt of questions!:teeth: -- View this message in context: http://old.nabble.com/Creating-an-excel-file-and-manipulating-it-from-R-tp26408408p26408408.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] foor loop - undefined columns selected error
Michela Leonardi wrote: Dear R-Help Members, I am trying to read and analyse a set of 100 csv files. I need work only on some columns in each of those, so I decided to use a for loop, isolate the column in each file to work on, but then an error mesage appear: undefined columns selected Here is my code: setwd(F:/Data/) a-list.files() for (x in a) { u-read.csv(x, header=T, sep=,, check.names=FALSE) #it give me the same problem using read.table h-u[,2] } Error in `[.data.frame`(u, , 2) : undefined columns selected It does not give me any problem selecting ane entire row (e.g. u[2,]) or a single value (e.g. [5,2]) If I try to select a column after the for loop I does not show any problem, e.g.: a-list.files() for (x in a) { u-read.csv(x, header=T, sep=,, check.names=FALSE) } h-u[,2] I would appreciate any suggestion or pointer to solve the problem or to do the same thing in a different way. Thanks for your consideration Michela, What are your loops supposed to accomplish? They just give you the last file in 'a'. When you get the error, that indicates that at least one of your files has only one column. You don't get the error when you take h-u[,2] out of the loop because the last file in 'a' does happen to have 2 or more columns. You need to rethink the loop with regard to what you will do with 'h'. And you need to check what's in those files. -Peter Ehlers -- Michela Leonardi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Presentation of data in Graphical format
That is not enough information for anyone to suggest a useful plot. For a start: * How many observations do you have? * How many difference posts/departments/tasks? * Are the variables nested or crossed? * Have you successfully parsed the time representation into something R can work with? Is the representation inconsistent as in your example? * What is the purpose of the study? What do you want to find out? Maybe you should meet with a local statistical consultant to discuss these issues in person. WARNING: you might have to pay - good advice is not always/seldom/ever free. Hadley On Wed, Nov 18, 2009 at 9:53 AM, Sunita Patil sunita...@gmail.com wrote: Hello Sir I had given a sample of my data, As I cannot disclose whole of my data this is just a sample given 1st column: Posts (GM, Secretary, AM, Office Boy) 2nd Column: Dept (Finance, HR, ...) 3rd column: Tasks (Open the door, Fix an appointment, Fill the register, etc.) depending on the post 4th column: Average Time required to do the task So the sample data would look like Posts Dept Task Average time Office Boy HR Open the door 00:00:09 Office Boy HR Switch on the lights 00:00:10 Secretary Finance Fix an appointment 00.00.30 . . . . . . in my data the 1st column is the main category say suppose Secretary the second column is the sub category HR Dept the 3rd column is the list of duties performed by the Secretary from HR dept and 4th column is time required to perform the duty so there are many such posts and dept with varied duties and times resp Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 9:15 PM, hadley wickham h.wick...@gmail.com wrote: Yes I tried all the basic ones like box plot, pie chart, etc but the data representation isnt that clear. Given that you have neither provided your data, nor explained what you are trying to uncover from it, what sort of advice do you expect to get? Hadley -- http://had.co.nz/ -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Presentation of data in Graphical format
Hi, (Sorry, I didn't cc the r-help list) On Nov 18, 2009, at 10:22 AM, Sunita Patil wrote: I have been using R just very recently, I have gone through this http://addictedtor.free.fr/graphiques/ a few weeks back but I am not able to understand as to how to choose the graph amongst them? Can anyone guide me regarding this? I'm not sure what you mean, exactly. Many of those graphs there aren't just normal R functions. They are put together using several commands in order to build the final picture you see there. For instance, say you like this graph: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=145 At the bottom left of the page, you'll find a Source Code section under Requirements. Click the view link there: http://addictedtor.free.fr/graphiques/graphcode.php?graph=145 And that's the code you need to make the graph (it's quite complex, but there are simpler ones. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Writing a data frame in an excel file
Sorry Charlie, I didn´t understand that tablename=R Results was creating a worksheet. But the thing now is that it works very well when I write for the first time on the excel file but when I want to rewrite on it it gives the error i wrote before saying that Results already exists, is there a way to avoid that? - Anna Lippel new in R so be careful I should be asking a lt of questions!:teeth: -- View this message in context: http://old.nabble.com/Writing-a-data-frame-in-an-excel-file-tp26378240p26408421.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] Presentation of data in Graphical format
Hi (again), On Nov 18, 2009, at 10:53 AM, Sunita Patil wrote: Hello Sir I had given a sample of my data, As I cannot disclose whole of my data this is just a sample given 1st column: Posts (GM, Secretary, AM, Office Boy) 2nd Column: Dept (Finance, HR, ...) 3rd column: Tasks (Open the door, Fix an appointment, Fill the register, etc.) depending on the post 4th column: Average Time required to do the task So the sample data would look like *PostsDeptTask Average time* Office Boy HR Open the door 00:00:09 Office Boy HR Switch on the lights 00:00:10 Secretary FinanceFix an appointment 00.00.30 . . . . . . in my data the 1st column is the main category say suppose Secretary the second column is the sub category HR Dept the 3rd column is the list of duties performed by the Secretary from HR dept and 4th column is time required to perform the duty so there are many such posts and dept with varied duties and times resp Fine, we see what your data looks like, but what are you trying to plot?! What do you want to show people about this data? -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Presentation of data in Graphical format
Hello Sir I have got 150 observations, got 10 posts/ 6 departments/ tasks vary from 5 to 10, A few of the variables are crossed specially in case of Office boy, where the tasks are like open the door, put on the lights, Yes time variable I have used Chron package, so that it works well My aim for this study is to check the amount of time and its variability for groups of tasks Its my project work so need to work this out myself if it doesnt work then I will have to consult a statistician Thanks for guiding me to put up the question in more clearer way, I will sure take care next time Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 9:29 PM, hadley wickham h.wick...@gmail.com wrote: That is not enough information for anyone to suggest a useful plot. For a start: * How many observations do you have? * How many difference posts/departments/tasks? * Are the variables nested or crossed? * Have you successfully parsed the time representation into something R can work with? Is the representation inconsistent as in your example? * What is the purpose of the study? What do you want to find out? Maybe you should meet with a local statistical consultant to discuss these issues in person. WARNING: you might have to pay - good advice is not always/seldom/ever free. Hadley On Wed, Nov 18, 2009 at 9:53 AM, Sunita Patil sunita...@gmail.com wrote: Hello Sir I had given a sample of my data, As I cannot disclose whole of my data this is just a sample given 1st column: Posts (GM, Secretary, AM, Office Boy) 2nd Column: Dept (Finance, HR, ...) 3rd column: Tasks (Open the door, Fix an appointment, Fill the register, etc.) depending on the post 4th column: Average Time required to do the task So the sample data would look like PostsDeptTask Average time Office Boy HR Open the door 00:00:09 Office Boy HR Switch on the lights 00:00:10 Secretary FinanceFix an appointment 00.00.30 . . . . . . in my data the 1st column is the main category say suppose Secretary the second column is the sub category HR Dept the 3rd column is the list of duties performed by the Secretary from HR dept and 4th column is time required to perform the duty so there are many such posts and dept with varied duties and times resp Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Nov 18, 2009 at 9:15 PM, hadley wickham h.wick...@gmail.com wrote: Yes I tried all the basic ones like box plot, pie chart, etc but the data representation isnt that clear. Given that you have neither provided your data, nor explained what you are trying to uncover from it, what sort of advice do you expect to get? Hadley -- http://had.co.nz/ -- http://had.co.nz/ [[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] mann-whitney test with more groups
Kim Vanselow wrote: Dear r-helpers, I want to test groups of samples for significant differences. Question: Does Group1 differ significantly from group2. This is a question to be answered by mann-whitney-u-test. I know that I can use wilcox.test with 2 samples. My problem: How can r perform the test automatically if there are more than 2 groups in my data frame. Test group1 vs. 2, 1 vs. 3, 1 vs. 4, etc. This is my skript: Deckung - read.table(Gesamtdeckung.csv, sep=;, header=TRUE, dec=,, row.names=1) x - Deckung$Gesamtdeckung y - Deckung$Klasse #U-Test wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(1, 2)) wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(1, 3)) wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(2, 3)) Any help would be greatly appreciated! Thanks Kim This sounds like serious data dredging, but if you're sure that it's what you want, try the combn() function: y - gl(4, 5) x - rnorm(20) m - cbind(t(combn(4, 2)), NA) for(i in 1:nrow(idx)) m[i, 3] - wilcox.test(x ~ y, subset = y %in% idx[i,])$p.value m -Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] mann-whitney test with more groups
Sorry, correction below. Peter Ehlers wrote: Kim Vanselow wrote: Dear r-helpers, I want to test groups of samples for significant differences. Question: Does Group1 differ significantly from group2. This is a question to be answered by mann-whitney-u-test. I know that I can use wilcox.test with 2 samples. My problem: How can r perform the test automatically if there are more than 2 groups in my data frame. Test group1 vs. 2, 1 vs. 3, 1 vs. 4, etc. This is my skript: Deckung - read.table(Gesamtdeckung.csv, sep=;, header=TRUE, dec=,, row.names=1) x - Deckung$Gesamtdeckung y - Deckung$Klasse #U-Test wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(1, 2)) wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(1, 3)) wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(2, 3)) Any help would be greatly appreciated! Thanks Kim This sounds like serious data dredging, but if you're sure that it's what you want, try the combn() function: y - gl(4, 5) x - rnorm(20) m - cbind(t(combn(4, 2)), NA) for(i in 1:nrow(idx)) m[i, 3] - wilcox.test(x ~ y, subset = y %in% idx[i,])$p.value m -Peter Ehlers y - gl(4, 5) x - rnorm(20) m - cbind(t(combn(4, 2)), NA) for(i in 1:nrow(m)) # change 'idx' to 'm' m[i, 3] - wilcox.test(x ~ y, subset = y %in% m[i,])$p.value # ditto -Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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 install older version of R?
Dear list This is much like a linux problem, but I can't find any reference for it. My OS is ubuntu 9.04 and a version of 2.9.2 of R has been already installed in. Now, I need to install the version of 2.7.1. I google a lot of websites and it seems like without a painless way provided me to do it. If any one offers me some suggestions/reference, I will appreciate. Jia-Chiun Pan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Writing a data frame in an excel file
On Wed, 18 Nov 2009 08:02:47 -0800 (PST) anna_l lippelanna21 @hotmail.com wrote: Sorry Charlie, I didn?t understand that tablename=R Results was creating a worksheet. But the thing now is that it works very well when I write for the first time on the excel file but when I want to rewrite on it it gives the error i wrote before saying that Results already exists, is there a way to avoid that? See the help page for 'sqlSave': ?sqlSave More specifically, take a look at the 'append' and 'safer' arguments. -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SVM Param Tuning with using SNOW package
On Tue, Nov 17, 2009 at 6:01 PM, raluca uca...@hotmail.com wrote: Hello, Is the first time I am using SNOW package and I am trying to tune the cost parameter for a linear SVM, where the cost (variable cost1) takes 10 values between 0.5 and 30. I have a large dataset and a pc which is not very powerful, so I need to tune the parameters using both CPUs of the pc. Somehow I cannot manage to do it. It seems that both CPUs are fitting the model for the same values of cost1, I guess the first 5, but not for the last 5. Please, can anyone help me! :-(( This is pretty easy to do with the train() funciton in the caret package. From ?train, here is an example for a different data set library(caret) library(snow) library(mlbench) data(BostonHousing) mpiCalcs - function(X, FUN, ...) + { + theDots - list(...) + parLapply(theDots$cl, X, FUN) + } library(snow) cl - makeCluster(5, MPI) ## 50 bootstrap models distributed across 5 workers mpiControl - trainControl(workers = 5, +number = 50, +computeFunction = mpiCalcs, +computeArgs = list(cl = cl)) set.seed(1) usingMPI - train(medv ~ ., +data = BostonHousing, +svmLinear, +tuneGrid = data.frame(.C = seq(.5, 30, length = 10)), +trControl = mpiControl) stopCluster(cl) [1] 1 -- Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Method dispatch for function
How can I determine what S3 method will be called for a particular first-argument class? I was imagining something like functionDispatch('str','numeric') = utils:::str.default , but I can't find anything like this. For that matter, I was wondering if anyone had written a version of `methods` which gave their fully qualified names if they were not visible, e.g. methods('str') = utils:::str.data.frameutils:::str.default stats:::str.dendrogramstats:::str.logLikutils:::str.POSIXt or methods('str') = $utils str.data.frame str.defaultstr.POSIXt $stats str.dendrogram str.logLik Thank you, -s [[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] parsing numeric values
The previous elegant solutions required the use of the gsubfn package. Nothing wrong with that, of course, but I'm always curious whether still relatively simple base R solutions can be found, as they are often (but not always!) much faster. And anyway, it seems to be in the spirit of your query to try such a solution. So here is one base R approach that I believe works. I'll break it up into 2 lines so you can see what's going on. ## Using your example... ## First replace everything but the number with spaces z - gsub([^[:digit:]E.+-], ,input) z [1] [2] 1.3770E-03 3.4644E-07 [3] 1.9412E-04 4.8840E-08 [4] [5] [6] 1.3770E-033.4644E-07 [7] 1.9412E-044.8840E-08 ## Now it can be scanned to a numeric via z-scan(textConnection(z),what=0) Read 8 items z [1] 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 I believe this strategy is reasonably general, but I haven't checked it carefully and would appreciate folks pointing out where it trips up (e.g. perhaps with NA's). Best, Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of baptiste auguie Sent: Wednesday, November 18, 2009 3:57 AM To: r-help Subject: [R] parsing numeric values Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax =1.3770E-03 bx =3.4644E-07 ay =1.9412E-04 by =4.8840E-08 other text aax =1.3770E-03 bbx =3.4644E-07 aay =1.9412E-04 bby =4.8840E-08)) ## this is what I want results - c(as.numeric(strsplit(grep(ax, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(ay, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(aax, input,val=T), )[[1]][9]), as.numeric(strsplit(grep(aay, input,val=T), )[[1]][9]) ) ## [1] 0.00137700 0.00019412 0.00137700 0.00019412 The use of strsplit is not ideal here as there is a different number of space characters in the lines containing ax and aax for instance (hence the indices 8 and 9 respectively). I tried to use gsubfn for a cleaner construct, strapply(input, ax += +([0-9.]+), c, simplify=rbind,combine=as.numeric) but I can't seem to find the correct regular expression to deal with the exponent. Any tips are welcome! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Writing a data frame in an excel file
Thanks Karl, well I am getting an error now after the following sqlSave command: sqlSave( xlsFile, datas, tablename = 'Datas_and_coefficients', rownames = FALSE ) -- [RODBC] Failed exec in Update 22018 39 [Microsoft][Driver ODBC for Excel]invalid character value for the diffusion specification (null) (null) More specifically, take a look at the 'append' and 'safer' arguments. -- Karl Ove Hufthammer __ R-help@r-project.org mailing list PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - Anna Lippel new in R so be careful I should be asking a lt of questions!:teeth: -- View this message in context: http://old.nabble.com/Writing-a-data-frame-in-an-excel-file-tp26378240p26412410.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] mann-whitney test with more groups
Peter Ehlers wrote: Sorry, correction below. Peter Ehlers wrote: Kim Vanselow wrote: Dear r-helpers, I want to test groups of samples for significant differences. Question: Does Group1 differ significantly from group2. This is a question to be answered by mann-whitney-u-test. I know that I can use wilcox.test with 2 samples. My problem: How can r perform the test automatically if there are more than 2 groups in my data frame. Test group1 vs. 2, 1 vs. 3, 1 vs. 4, etc. This is my skript: Deckung - read.table(Gesamtdeckung.csv, sep=;, header=TRUE, dec=,, row.names=1) x - Deckung$Gesamtdeckung y - Deckung$Klasse #U-Test wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(1, 2)) wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(1, 3)) wilcox.test(x ~ y, paired = FALSE, subset = y %in% c(2, 3)) Any help would be greatly appreciated! Thanks Kim This sounds like serious data dredging, but if you're sure that it's what you want, try the combn() function: y - gl(4, 5) x - rnorm(20) m - cbind(t(combn(4, 2)), NA) for(i in 1:nrow(idx)) m[i, 3] - wilcox.test(x ~ y, subset = y %in% idx[i,])$p.value m -Peter Ehlers y - gl(4, 5) x - rnorm(20) m - cbind(t(combn(4, 2)), NA) for(i in 1:nrow(m)) # change 'idx' to 'm' m[i, 3] - wilcox.test(x ~ y, subset = y %in% m[i,])$p.value # ditto There's also pairwise.wilcox.test, with multiple testing correction and all. (But someone called Lumley may chime in and remind you of the lack of guaranteed transitivity of rank tests.) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Data linkage functions for probabilistic linkage using person identifiers
I am somewhat new to R although using and liking already. I am curious if there are any probabilistic packages similar in function to others such and Link King (http://www.the-link-king.com/). I am looking for functions in SSN, First/Last name, date of birth, and a couple other indicators for matching. Thanks Dagan Wright, Ph.D., M.S.P.H. Lead Addictions Research Analyst, Analysis Evaluation Unit Addictions Mental Health Division (AMH) 500 Summer St. NE E86 Salem, Oregon 97301-1118 Office number: 503-945-5726 Fax number: 503-378-8467 dagan.a.wri...@state.or.us __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] border/box/frame around plot
Hello I need to know how to put a closed frame around my plot. I am plotting using the igraph package, and I have been able to use box() with limited success. Box() puts a border around only the upper and right edges of the plot area, but misses the axes. By default, setting the axes=TRUE in igraph does not produce closed axes (ie axes that run through the origin and up to the limits of the plot window). Any ideas? -- View this message in context: http://old.nabble.com/border-box-frame-around-plot-tp26410451p26410451.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] Y axis of 1-D Linear Discriminant Histograms
Hi all. I would like to understand what are the units defined on the y-axis when you plot the one-dimensional predictions (histograms) from lda() (MASS) discriminant function objects? While the helpfile suggests that a histogram is returned by default, the presumably proportion-like values for each group seem to add up to more than 1, and I'm not sure how to interpret the code from ldahist(), which, I believe, defines the heights of each bin as est1/(diff(breaks) * length(data[g == grp])) where est1 is (as far as I can tell) the frequency within the bin, and the denominator is apparently the bin width multiplied by the total sample size for that panel. It seems to be that a far more logical result would be returned for each bin if the diff(breaks) component was removed entirely. While I don't think my concern affects the shape of each group's histogram, I'd much prefer to display a more intuitive y-axis. Example: library(MASS) ld1-lda(Species ~ Sepal.Length + Sepal.Width, iris) plot(ld1, type = histogram, dimen = 1) #(eyeballing it suggests that the sum of the frequencies reported on the y-axis for each group exceeds 1) Thanks very much. --Bob Farmer Dalhousie University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] parsing numeric values
Hi, Thanks for the alternative approach. However, I should have made my example more complete in that other lines may also have numeric values, which I'm not interested in. Below is an updated problem, with my current solution, tc - textConnection( some text ax =1.3770E-03 bx =3.4644E-07 ay =1.9412E-04 by =4.8840E-08 other text aax =1.3770E-03 bbx =3.4644E-07 aay =1.9412E-04 bby =4.8840E-08 lots of other material, including numeric values 1.23E-4 123E5 12.3E-4 123E5 123E-4 123E5 12.3E-4 123E5 12.3E-4 123E5 123E-4 123E5 etc...) input - readLines(tc) close(tc) ## I want to retrieve the values for ## ax, ay, aax and aay only results - c( strapply(input, ax += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind), strapply(input, ay += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind), strapply(input, aax += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind), strapply(input, aay += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind)) results Using the suggested base R solution, I've come up with this variation, z - gsub([^[:digit:]E.+-], , grep(ax|ay|aax|aay, input, value=TRUE)) test - scan(textConnection(z),what=0) test[seq(1, length(test), by=2)] Thanks again, baptiste 2009/11/18 Bert Gunter gunter.ber...@gene.com: The previous elegant solutions required the use of the gsubfn package. Nothing wrong with that, of course, but I'm always curious whether still relatively simple base R solutions can be found, as they are often (but not always!) much faster. And anyway, it seems to be in the spirit of your query to try such a solution. So here is one base R approach that I believe works. I'll break it up into 2 lines so you can see what's going on. ## Using your example... ## First replace everything but the number with spaces z - gsub([^[:digit:]E.+-], ,input) z [1] [2] 1.3770E-03 3.4644E-07 [3] 1.9412E-04 4.8840E-08 [4] [5] [6] 1.3770E-03 3.4644E-07 [7] 1.9412E-04 4.8840E-08 ## Now it can be scanned to a numeric via z-scan(textConnection(z),what=0) Read 8 items z [1] 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 I believe this strategy is reasonably general, but I haven't checked it carefully and would appreciate folks pointing out where it trips up (e.g. perhaps with NA's). Best, Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of baptiste auguie Sent: Wednesday, November 18, 2009 3:57 AM To: r-help Subject: [R] parsing numeric values Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax = 1.3770E-03 bx = 3.4644E-07 ay = 1.9412E-04 by = 4.8840E-08 other text aax = 1.3770E-03 bbx = 3.4644E-07 aay = 1.9412E-04 bby = 4.8840E-08)) ## this is what I want results - c(as.numeric(strsplit(grep(ax, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(ay, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(aax, input,val=T), )[[1]][9]), as.numeric(strsplit(grep(aay, input,val=T), )[[1]][9]) ) ## [1] 0.00137700 0.00019412 0.00137700 0.00019412 The use of strsplit is not ideal here as there is a different number of space characters in the lines containing ax and aax for instance (hence the indices 8 and 9 respectively). I tried to use gsubfn for a cleaner construct, strapply(input, ax += +([0-9.]+), c, simplify=rbind,combine=as.numeric) but I can't seem to find the correct regular expression to deal with the exponent. Any tips are welcome! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Writing a data frame in an excel file
Why don't try the fabulous WRITEXLS package? Caveman On Wed, Nov 18, 2009 at 7:45 PM, anna_l lippelann...@hotmail.com wrote: Thanks Karl, well I am getting an error now after the following sqlSave command: sqlSave( xlsFile, datas, tablename = 'Datas_and_coefficients', rownames = FALSE ) -- [RODBC] Failed exec in Update 22018 39 [Microsoft][Driver ODBC for Excel]invalid character value for the diffusion specification (null) (null) More specifically, take a look at the 'append' and 'safer' arguments. -- Karl Ove Hufthammer __ R-help@r-project.org mailing list PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - Anna Lippel new in R so be careful I should be asking a lt of questions!:teeth: -- View this message in context: http://old.nabble.com/Writing-a-data-frame-in-an-excel-file-tp26378240p26412410.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] parsing numeric values
It only works if some text at the beginning has no digits, dots, E characters or sign characters. On Wed, Nov 18, 2009 at 12:44 PM, Bert Gunter gunter.ber...@gene.com wrote: The previous elegant solutions required the use of the gsubfn package. Nothing wrong with that, of course, but I'm always curious whether still relatively simple base R solutions can be found, as they are often (but not always!) much faster. And anyway, it seems to be in the spirit of your query to try such a solution. So here is one base R approach that I believe works. I'll break it up into 2 lines so you can see what's going on. ## Using your example... ## First replace everything but the number with spaces z - gsub([^[:digit:]E.+-], ,input) z [1] [2] 1.3770E-03 3.4644E-07 [3] 1.9412E-04 4.8840E-08 [4] [5] [6] 1.3770E-03 3.4644E-07 [7] 1.9412E-04 4.8840E-08 ## Now it can be scanned to a numeric via z-scan(textConnection(z),what=0) Read 8 items z [1] 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 I believe this strategy is reasonably general, but I haven't checked it carefully and would appreciate folks pointing out where it trips up (e.g. perhaps with NA's). Best, Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of baptiste auguie Sent: Wednesday, November 18, 2009 3:57 AM To: r-help Subject: [R] parsing numeric values Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax = 1.3770E-03 bx = 3.4644E-07 ay = 1.9412E-04 by = 4.8840E-08 other text aax = 1.3770E-03 bbx = 3.4644E-07 aay = 1.9412E-04 bby = 4.8840E-08)) ## this is what I want results - c(as.numeric(strsplit(grep(ax, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(ay, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(aax, input,val=T), )[[1]][9]), as.numeric(strsplit(grep(aay, input,val=T), )[[1]][9]) ) ## [1] 0.00137700 0.00019412 0.00137700 0.00019412 The use of strsplit is not ideal here as there is a different number of space characters in the lines containing ax and aax for instance (hence the indices 8 and 9 respectively). I tried to use gsubfn for a cleaner construct, strapply(input, ax += +([0-9.]+), c, simplify=rbind,combine=as.numeric) but I can't seem to find the correct regular expression to deal with the exponent. Any tips are welcome! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] parsing numeric values
Here is a slight variation: read.table(textConnection(grep(aa?[xy], input, value = TRUE)), +colClasses = c(NULL, NULL, numeric)) V3 V6 1 0.00137700 3.4644e-07 2 0.00019412 4.8840e-08 3 0.00137700 3.4644e-07 4 0.00019412 4.8840e-08 On Wed, Nov 18, 2009 at 1:54 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Thanks for the alternative approach. However, I should have made my example more complete in that other lines may also have numeric values, which I'm not interested in. Below is an updated problem, with my current solution, tc - textConnection( some text ax = 1.3770E-03 bx = 3.4644E-07 ay = 1.9412E-04 by = 4.8840E-08 other text aax = 1.3770E-03 bbx = 3.4644E-07 aay = 1.9412E-04 bby = 4.8840E-08 lots of other material, including numeric values 1.23E-4 123E5 12.3E-4 123E5 123E-4 123E5 12.3E-4 123E5 12.3E-4 123E5 123E-4 123E5 etc...) input - readLines(tc) close(tc) ## I want to retrieve the values for ## ax, ay, aax and aay only results - c( strapply(input, ax += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind), strapply(input, ay += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind), strapply(input, aax += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind), strapply(input, aay += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind)) results Using the suggested base R solution, I've come up with this variation, z - `, grep(ax|ay|aax|aay, input, value=TRUE)) test - scan(textConnection(z),what=0) test[seq(1, length(test), by=2)] Thanks again, baptiste 2009/11/18 Bert Gunter gunter.ber...@gene.com: The previous elegant solutions required the use of the gsubfn package. Nothing wrong with that, of course, but I'm always curious whether still relatively simple base R solutions can be found, as they are often (but not always!) much faster. And anyway, it seems to be in the spirit of your query to try such a solution. So here is one base R approach that I believe works. I'll break it up into 2 lines so you can see what's going on. ## Using your example... ## First replace everything but the number with spaces z - gsub([^[:digit:]E.+-], ,input) z [1] [2] 1.3770E-03 3.4644E-07 [3] 1.9412E-04 4.8840E-08 [4] [5] [6] 1.3770E-03 3.4644E-07 [7] 1.9412E-04 4.8840E-08 ## Now it can be scanned to a numeric via z-scan(textConnection(z),what=0) Read 8 items z [1] 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 I believe this strategy is reasonably general, but I haven't checked it carefully and would appreciate folks pointing out where it trips up (e.g. perhaps with NA's). Best, Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of baptiste auguie Sent: Wednesday, November 18, 2009 3:57 AM To: r-help Subject: [R] parsing numeric values Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax = 1.3770E-03 bx = 3.4644E-07 ay = 1.9412E-04 by = 4.8840E-08 other text aax = 1.3770E-03 bbx = 3.4644E-07 aay = 1.9412E-04 bby = 4.8840E-08)) ## this is what I want results - c(as.numeric(strsplit(grep(ax, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(ay, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(aax, input,val=T), )[[1]][9]), as.numeric(strsplit(grep(aay, input,val=T), )[[1]][9]) ) ## [1] 0.00137700 0.00019412 0.00137700 0.00019412 The use of strsplit is not ideal here as there is a different number of space characters in the lines containing ax and aax for instance (hence the indices 8 and 9 respectively). I tried to use gsubfn for a cleaner construct, strapply(input, ax += +([0-9.]+), c, simplify=rbind,combine=as.numeric) but I can't seem to find the correct regular expression to deal with the exponent. Any tips are welcome! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing
[R] (no subject)
How do you perform a multicollinearity test using R. Also how do you perform a selection stepwise to carry out a multiple regression analysis? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to choose appropriate linear model? (ANOVA)
I'm wondering how to choose an appropriate linear model for a given problem. I have been reading Applied Linear Regression Models by John Neter, Michael H Kutner, William Wasserman and Christopher J. Nachtsheim. I'm still not clear how to choose an appropriate linear model. For multi-factor ANOVA, shall I start with all the interaction terms and do an F-test to see with interaction terms are not significant, then do a linear regression on a model without the non-significant iteration term? Could somebody point me some good book or chapters on this topic? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
http://www.lmgtfy.com/?q=multicollinearity+test+using+R http://www.lmgtfy.com/?q=selection+stepwise+multiple+regression+analysis+using+R Moritz Karen Federico schrieb: How do you perform a multicollinearity test using R. Also how do you perform a selection stepwise to carry out a multiple regression analysis? [[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] standard error for the estimated value (lmer fitted model)
Dear R users, I want to draw standard error lines for the predicted regression line estimated by logistic regression using lmer. I have two predictors: cafr and its quadratic form I(cafr^2), where cafr is a variable centered around the mean of original variable. Now, the estimated value from the fitted model will be, (mo...@x)%*%fixef(model) In the logit scale, the mean sum of square from fitted model will be, sesample=sqrt(sum(resid(model)^2)/(n-p-1)), where p is the degrees of freedom used for fitting. Could someone make a judgement if it is reasonable to calculate standard error of the estimated value by sesample*sqrt(vector%*%ginv(t(mo...@x)%*%mo...@x)%*%t(vector)) , where vector is the (1,cafr,I(cafr^2)) which representing empirical data vector at considered point. If this is correct, I think I can use this method to draw standard error line. Otherwise, would you please suggest a reasonable one? Thank you very much for your attention! Yours sincerely, Jianghua -- View this message in context: http://old.nabble.com/standard-error-for-the-estimated-value-%28lmer-fitted-model%29-tp26414507p26414507.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] Re ading multiple Excel 2007 files with a loop
I have several hundred Excel 2007 data files in a folder. I would like to read every file in a single given folder using a loop. I have searched the FAQ, the forum archives here, other or older R boards and the R Import / Export documentation, and have asked some very knowledgeable R users without learning of a solution. I hope someone here can help. I understand that the most common suggestion is to convert the files to csv format. However, there are so many files in my case (ultimately 1000) I would rather avoid doing that. I have also found many solutions to this problem for txt files and files in additional formats other than Excel 2007. I can read three Excel 2007 files one at a time with the following example code using R 2.10.0 on a computer running Windows (XP, I think): library(RODBC) channel - odbcDriverConnect(DRIVER=Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb); DBQ=U:\\test folder\\testA.xlsx; ReadOnly=False) sqlTables(channel) my.data.A - sqlFetch(channel, Sheet1) odbcClose(channel) channel - odbcDriverConnect(DRIVER=Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb); DBQ=U:\\test folder\\testB.xlsx; ReadOnly=False) sqlTables(channel) my.data.B - sqlFetch(channel, Sheet1) odbcClose(channel) channel - odbcDriverConnect(DRIVER=Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb); DBQ=U:\\test folder\\testC.xlsx; ReadOnly=False) sqlTables(channel) my.data.C - sqlFetch(channel, Sheet1) odbcClose(channel) # However, when I attempt to read the same three files with the loop below I receive an error: library(RODBC) setwd(U:/test folder) fname - list.files(pattern=.\\.xlsx, full.names = FALSE, recursive = TRUE, ignore.case = TRUE) z - length(fname) print(z) for (sp in 1:z) { channel - odbcDriverConnect(DRIVER=Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb); DBQ=U:\\test folder\\fname[sp]; ReadOnly=False) sqlTables(channel) my.data - sqlFetch(channel, Sheet1) print(my.data) odbcClose(channel) } # The error I receive states: Error in odbcTableExists(channel, sqtable) : ‘Sheet1’: table not found on channel # Thank you sincerely in advance for any help with this problem. Mark Miller Gainesville, Florida -- View this message in context: http://old.nabble.com/Reading-multiple-Excel-2007-files-with-a-loop-tp26414828p26414828.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to choose appropriate linear model? (ANOVA)
Hello Peng, What you are talking about is model selection process. Although it also sound like you are referring to the more general subject of regression model strategies, consider finding this book: http://www.amazon.com/Regression-Modeling-Strategies-Frank-Harrell/dp/0387952322 Frank Harrell is a very insightful lecturer, I heard his writing is also good. I would love to read recommendation from other R members regarding your question. Best, Tal -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Nov 18, 2009 at 9:48 PM, Peng Yu pengyu...@gmail.com wrote: I'm wondering how to choose an appropriate linear model for a given problem. I have been reading Applied Linear Regression Models by John Neter, Michael H Kutner, William Wasserman and Christopher J. Nachtsheim. I'm still not clear how to choose an appropriate linear model. For multi-factor ANOVA, shall I start with all the interaction terms and do an F-test to see with interaction terms are not significant, then do a linear regression on a model without the non-significant iteration term? Could somebody point me some good book or chapters on this topic? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] parsing numeric values
another useful trick that could come in handy, thanks! baptiste 2009/11/18 Gabor Grothendieck ggrothendi...@gmail.com: Here is a slight variation: read.table(textConnection(grep(aa?[xy], input, value = TRUE)), + colClasses = c(NULL, NULL, numeric)) V3 V6 1 0.00137700 3.4644e-07 2 0.00019412 4.8840e-08 3 0.00137700 3.4644e-07 4 0.00019412 4.8840e-08 On Wed, Nov 18, 2009 at 1:54 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Thanks for the alternative approach. However, I should have made my example more complete in that other lines may also have numeric values, which I'm not interested in. Below is an updated problem, with my current solution, tc - textConnection( some text ax = 1.3770E-03 bx = 3.4644E-07 ay = 1.9412E-04 by = 4.8840E-08 other text aax = 1.3770E-03 bbx = 3.4644E-07 aay = 1.9412E-04 bby = 4.8840E-08 lots of other material, including numeric values 1.23E-4 123E5 12.3E-4 123E5 123E-4 123E5 12.3E-4 123E5 12.3E-4 123E5 123E-4 123E5 etc...) input - readLines(tc) close(tc) ## I want to retrieve the values for ## ax, ay, aax and aay only results - c( strapply(input, ax += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind), strapply(input, ay += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind), strapply(input, aax += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind), strapply(input, aay += +(\\d+\\.\\d+E[-+]?\\d+), as.numeric, simplify = rbind)) results Using the suggested base R solution, I've come up with this variation, z - `, grep(ax|ay|aax|aay, input, value=TRUE)) test - scan(textConnection(z),what=0) test[seq(1, length(test), by=2)] Thanks again, baptiste 2009/11/18 Bert Gunter gunter.ber...@gene.com: The previous elegant solutions required the use of the gsubfn package. Nothing wrong with that, of course, but I'm always curious whether still relatively simple base R solutions can be found, as they are often (but not always!) much faster. And anyway, it seems to be in the spirit of your query to try such a solution. So here is one base R approach that I believe works. I'll break it up into 2 lines so you can see what's going on. ## Using your example... ## First replace everything but the number with spaces z - gsub([^[:digit:]E.+-], ,input) z [1] [2] 1.3770E-03 3.4644E-07 [3] 1.9412E-04 4.8840E-08 [4] [5] [6] 1.3770E-03 3.4644E-07 [7] 1.9412E-04 4.8840E-08 ## Now it can be scanned to a numeric via z-scan(textConnection(z),what=0) Read 8 items z [1] 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 1.3770e-03 3.4644e-07 1.9412e-04 4.8840e-08 I believe this strategy is reasonably general, but I haven't checked it carefully and would appreciate folks pointing out where it trips up (e.g. perhaps with NA's). Best, Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of baptiste auguie Sent: Wednesday, November 18, 2009 3:57 AM To: r-help Subject: [R] parsing numeric values Dear list, I'm seeking advice to extract some numeric values from a log file created by an external program. Consider the following example, input - readLines(textConnection( some text ax = 1.3770E-03 bx = 3.4644E-07 ay = 1.9412E-04 by = 4.8840E-08 other text aax = 1.3770E-03 bbx = 3.4644E-07 aay = 1.9412E-04 bby = 4.8840E-08)) ## this is what I want results - c(as.numeric(strsplit(grep(ax, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(ay, input,val=T), )[[1]][8]), as.numeric(strsplit(grep(aax, input,val=T), )[[1]][9]), as.numeric(strsplit(grep(aay, input,val=T), )[[1]][9]) ) ## [1] 0.00137700 0.00019412 0.00137700 0.00019412 The use of strsplit is not ideal here as there is a different number of space characters in the lines containing ax and aax for instance (hence the indices 8 and 9 respectively). I tried to use gsubfn for a cleaner construct, strapply(input, ax += +([0-9.]+), c, simplify=rbind,combine=as.numeric) but I can't seem to find the correct regular expression to deal with the exponent. Any tips are welcome! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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