[R] Requesting information
Dear Sir/Madam I'm Working on a research project called Dynamic price optimization using genetic algorithm to optimize product price's in an e-commerce store. I'm doing this project using R language (package GA). I need help in defining a Fitness function to optimize the products price. Can any one help me on this.!! Regards Rashmi Naik [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package implementing continuous binomial?
David Winsemius dwinsem...@comcast.net on Thu, 7 May 2015 12:10:25 -0700 writes: On May 6, 2015, at 7:00 PM, Benjamin Tyner wrote: Hi I'm wondering if anyone is aware of an R package implementing (i.e., providing a pdf, cdf, and/or quantile function) for the continuous binomial distribution? Specifically the one characterized here: http://www2.math.uni-paderborn.de/fileadmin/Mathematik/AG-Indlekofer/Workshop/Satellite_meeting/ilenko.pdf Figured I would check here first, before attempting to code it up myself. I found that reading the ArXiv version of that material was easier to understand: http://arxiv.org/abs/1303.5990 zipfR package has an implementation of the incomplete beta function that might make some of the coding of the pdf and cdf more simple. Well. To: David Winsemius dwinsem...@comcast.net Subject: Re: [R] package implementing continuous binomial? In-Reply-To: 5425134b-6aa1-4246-bcd4-d4be4be23...@comcast.net References: 554ac75a.8070...@gmail.com 5425134b-6aa1-4246-bcd4-d4be4be23...@comcast.net X-Mailer: VM 8.2.0b under 24.3.1 (x86_64-redhat-linux-gnu) Reply-To: Martin Maechler maech...@stat.math.ethz.ch CC: maechler --text follows this line-- Dear David, David Winsemius dwinsem...@comcast.net on Thu, 7 May 2015 12:10:25 -0700 writes: On May 6, 2015, at 7:00 PM, Benjamin Tyner wrote: Hi I'm wondering if anyone is aware of an R package implementing (i.e., providing a pdf, cdf, and/or quantile function) for the continuous binomial distribution? Specifically the one characterized here: http://www2.math.uni-paderborn.de/fileadmin/Mathematik/AG-Indlekofer/Workshop/Satellite_meeting/ilenko.pdf Figured I would check here first, before attempting to code it up myself. I found that reading the ArXiv version of that material was easier to understand: http://arxiv.org/abs/1303.5990 zipfR package has an implementation of the incomplete beta function that might make some of the coding of the pdf and cdf more simple. Searching done with Graves' very useful utility package: library('sos') findFn(incomplete beta function) Hmm... R's pbeta() function is a pretty good implementation of the incomplete beta function ... as is tries to say on its help page. If you look closely, these functions (for incomplete gamma, incomplete beta, and their inverses) are simple wrappers to pgamma() and qgamma() --- sometimes regularizing and sometimes not -- where regularization is simply a multiplication/division with gamma() or beta(). I wonder why you did not find R's help page about the beta distribution { - functions dgamma, pgamma, qgamma, rgamma } which does mention the incomplete beta function prominently. I don't think Benjamin should use the zipfR package just for these functions [and even the zipfR package help page on these can be read as saying so .. ] In the end I wonder if the continuous Binomial is not just a version of the good old Beta distribution... as indeed the Binomial and the Beta are related in the same way that the Gamma and the Poisson are. Martin Maechler ETH Zurich (I did't think that doing a search on continuous Binomial was likely to be helpful, but I tried it anyway and did not find any functions named continuous binomial in their help page titles.) -- David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] does segfault mean (always) a bug?
William Dunlap wdun...@tibco.com on Wed, 6 May 2015 09:53:50 -0700 writes: It looks like a problem in the Matrix package. Indeed. Thanks to Bill Dunlap for the diagnostics below (and other offline information and) I have been able to fix the bug yesterday in the R-forge version of Matrix. The problem was due to using a version of memory allocation which is known to be quite fast... but is not to be used for large objects .. which we have here. I plan to release the amended version of Matrix to CRAN as Matrix_1.2-1 rather sooner than later. With thanks to Bill and Pavel, Martin Maechler ETH Zurich I made the file KE.rda containing the Matrix objects K and E constructed in calc.diffusion.kernel by adding a save() call just before where R dies in the original example: K = lam$values[1] * I - M E = I - matrix(1, ncol = ncol(I), nrow = nrow(I))/ncol(I) cat(saving K, E, etc. in /tmp/KE.rda\n) save(K, E, deg, invD, I, W, M, lam, file=/tmp/KE.rda) cat(done making the file\n) K = E %*% K %*% E With that file in place I get library(Matrix) load(KE.rda) sessionInfo() R version 3.2.0 (2015-04-16) Platform: x86_64-unknown-linux-gnu (64-bit) Running under: Ubuntu precise (12.04.5 LTS) [ .. ] other attached packages: [1] Matrix_1.2-0 loaded via a namespace (and not attached): [1] grid_3.2.0 lattice_0.20-31 str(E) Formal class 'dsyMatrix' [package Matrix] with 5 slots ..@ x : num [1:143376676] 1.00 -8.35e-05 -8.35e-05 -8.35e-05 -8.35e-05 ... ..@ Dim : int [1:2] 11974 11974 ..@ Dimnames:List of 2 .. ..$ : NULL .. ..$ : NULL ..@ uplo: chr U ..@ factors : list() str(K) Formal class 'dgCMatrix' [package Matrix] with 6 slots ..@ i : int [1:487692] 0 69 948 951 1027 1192 1414 1420 1421 1714 ... ..@ p : int [1:11975] 0 27 125 147 199 212 221 230 254 274 ... ..@ Dim : int [1:2] 11974 11974 ..@ Dimnames:List of 2 .. ..$ : chr [1:11974] GO:002 GO:003 GO:012 GO:018 ... .. ..$ : chr [1:11974] GO:002 GO:003 GO:012 GO:018 ... ..@ x : num [1:487692] 32.2163 -0.004674 -0.000722 -0.005316 -0.014022 ... ..@ factors : list() EK - E %*% K EKE - EK %*% E *** caught segfault *** address 0x7fffa7e1ccf8, cause 'memory not mapped' [...] On Wed, May 6, 2015 at 1:57 AM, Martin Maechler maech...@lynne.stat.math.ethz.ch wrote: lejeczek pelj...@yahoo.co.uk on Wed, 6 May 2015 08:20:46 +0100 writes: On 05/05/15 20:36, Duncan Murdoch wrote: On 05/05/2015 2:54 PM, lejeczek wrote: hi eveybody I'm trying something simple (Biocunductor packages), so simple I believe it's example from docs but I get segfault. I don't suppose incorrect scripting can cause segfault, right? In R, a segfault always indicates a bug. What's not so clear is whether it is a bug in R, a bug in a contributed package, or a bug in some underlying system library. If you can only trigger the bug when using a Bioconductor package, then the first guess is that it is that package, and the maintainer of that package is in the best position to track it down further. If you can simplify the code to trigger it without using any contributed packages, then it could well be a bug in R, and we'd like to see code to reproduce it. Duncan Murdoch hi Duncan I remember that this was a principle of most of programming languages, only a bug in the code and/or compiler could cause segfault. In my case it is a contributed package, specifically GOSim package, I'm not R programmer and I realise my scripting is far from good and possibly with errors. I could send that snippet of the code here if people think it can be looked into and segfault could be replicated? I also emailed the author. many thanks P. Dear P., in the case of segfault from using a contributed package, you should typically really only email the package maintainer (which may different than the package authors), and not R-help. Only if the maintainer does not respond at all (and only if the package is open source, typically CRAN) should you ask for help here or another public forum. (I would also think it to be polite to the maintainer who has volunteered her/his code to be used by you if you give him an opportunity to see, comment and fix the problem) Martin Maechler ETH Zurich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help
Re: [R] package implementing continuous binomial?
I don't think Benjamin should use the zipfR package just for these functions [and even the zipfR package help page on these can be read as saying so .. ] Exactly. They are simply there because it's much easier to write and read code with wrappers that parametrize the incomplete Beta and Gamma functions in the usual way, so the code looks more like the original equations it's based on. In the end I wonder if the continuous Binomial is not just a version of the good old Beta distribution... as indeed the Binomial and the Beta are related in the same way that the Gamma and the Poisson are. I thought so, too, at first and was about to suggest that. But a closer look at the slides showed that the distribution function of the continuous binomial and Poisson showed that they keep the boundary of the integral fixed (it's one of the parameters of the distribution) and vary one or two of the other parameters of the function with x. It took me a while to figure this out because the slides use an uncommon notation for incomplete Gamma and Beta functions. In particular, qgamma() and qbeta() won't give quantiles for the new distributions and one may have to implement some kind of binary search based on the distribution functions of the continuous binomial and Poisson. In the interest of self-promotion ;-), Evert (2004, Appendix A.4) spells out the connections between the incomplete Beta and Gamma function, the Beta and Gamma distributions, and the binomial and Poisson distributions in what I consider to be an accessible manner. (PDF, now at last with bookmarks: http://purl.org/stefan.evert/PUB/Evert2004phd.pdf) Best, Stefan __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot by FIPS Code using Shapefiles
Excellent suggestions Professors! I really appreciated it. This is what I am using: library(data.table) library(rgdal) library(colourschemes) library(RColorBrewer) library(maptools) library(maps) library(ggmap) library(classInt) max_change is my csv file while shapes is my spatial data: max_change -read.csv (F:/GCM/max_change.csv) max_change - as.data.table(max_change) max_change$FIPS - sprintf(%05d,as.numeric(max_change$FIPS)) max_change - max_change[with(max_change, order(FIPS)), ] shapes=readOGR(dsn=F:/GCM//tl_2014_us_county, tl_2014_us_county) shapes$FIPS = paste(shapes$STATEFP,shapes$COUNTYFP,sep=) m = match(shapes$GEOID,max_change$FIPS) shapes$change = max_change$change[m] I am plotting the results now. I am getting different plots regarding county boundaries (most likely because I am doing something wrong). When I use the *plot *command: colours = brewer.pal(6,PuRd) sd = data.frame(col=colours,values=c(-2.5,-2,-1.5,-1,-.5,0)) sc = nearestScheme(sd) plot(c(-129,-61),c(21,53),type=n,axes=FALSE,xlab=,ylab=) title(main = Mid-Century Projections (GISS-ER-2) using Max GAM) plot(shapes,col=sc(shapes$change),add=TRUE,border=white,lwd=0.2, colorkey=T) I get a beautiful plot with the county boundaries clearly separated but for *spplot*; pal = brewer.pal(6,Reds) brks.eq = classIntervals(shapes$change, style = jenks) spplot(shapes, change,xlim = c(-129,-61), ylim = c(21,53), at=brks.eq$brks,col.regions=pal, col=transparent, main = list(label=Mid-Century Projections (GISS-ER-2) using Max GAM)) The county boundaries/FIPS are not defined. What am I doing wrong? Thanks again! Sincerely, Shouro On Wed, May 6, 2015 at 12:23 PM, Roger Bivand roger.biv...@nhh.no wrote: Corey Sparks corey.sparks at utsa.edu writes: Joining data the way you're doing it is dangerous, Roger Bivand and others describes a standard way to do this process here: http://r-sig-geo.2731867.n2.nabble.com/Merging-shapefiles-and-csv-td7586839.html Quite right - the chunks Corey is referring to are: Please do refer to the vignette in the maptools package, and to previous threads which have advised that merge() should not be used, and that the row.names of the data frames be used as ID keys. Typically using match() on the row.names of the two objects will show which are not correctly aligned. and Beware that the data from the objects may be jumbled - never use merge, always use match() on the row.names vectors of the objects to ensure that the key-IDs agree. Jumbled data happens, it is important not to think shapefile but to think DBMS with the ID key your way of staying sane. The maptools vignette is at: http://cran.r-project.org/web/packages/maptools/vignettes/combine_maptools.pdf or: library(maptools) vignette(combine_maptools) Here I also suspect that you'll find that there are non-unique FIPS in the county polygons file, so may need to go through maptools::unionSpatialPolygons() first. Roger And I do an example using US Census data here, using merge(): http://spatialdemography.org/wp-content/uploads/2013/04/9.-Sparks.pdf http://spatialdemography.org/wp-content/uploads/2013/04/9.-Sparks.pdf look at page 134 of that pdf. Hope this helps - Corey Sparks, PhD Assistant Professor Department of Demography University of Texas at San Antonio 501 West César E. Chávez Blvd Monterey Building 2.270C San Antonio, TX 78207 210-458-3166 corey.sparks 'at' utsa.edu coreysparks.weebly.com -- View this message in context: http://r.789695.n4.nabble.com/Plot-by-FIPS-Code-using-Shapefiles-tp4706830p4706840.html Sent from the R help mailing list archive at Nabble.com. __ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Shouro Dasgupta PhD Candidate | Department of Economics Ca' Foscari University of Venezia -- Junior Researcher | Fondazione Eni Enrico Mattei (FEEM) Isola di San Giorgio Maggiore, 8 | 30124 Venice, Italy Tel: +39 041 2700 436 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R-es] pregunta
Estimados Al dirigir la lectura de un folder tYA1.csv me da este error y no me percato del motivo, adjunto archivo. Espero su ayuda Saludos Jos� setwd(D:/Public/Documents/R/bioimpedancia) a-read.csv(tYA1.csv,header=TRUE, sep=,, dec=.) Error in read.table(file = file, header = header, sep = sep, quote = quote, : more columns than column names [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R] Changing layout in grid.arrange
Hi All: I am doing something very similar to the the example in the grid.arrange package: require(ggplot2) plots = lapply(1:10, function(.x) qplot(1:10,rnorm(10), main=paste(plot,.x))) require(gridExtra) do.call(grid.arrange, plots) If you run this, the layout is 4 rows and 3 columns with graphs 1-3 going across. What I would like instead is for the layout to have 2 columns and 5 rows, with graphs 1-5 going down the first column, graphs 6-10 going down the second column but almost everything I have tried has failed. Any help appreciated. -Roy M. ** The contents of this message do not reflect any position of the U.S. Government or NOAA. ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new address and phone*** 110 Shaffer Road Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ Old age and treachery will overcome youth and skill. From those who have been given much, much will be expected the arc of the moral universe is long, but it bends toward justice -MLK Jr. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R-es] Redes neuronales
Buenas tardes, escribo porque estoy teniendo problemas para definir el perceptrón que considere los puntos (−0.5, − 0.5), (−0.5,0.5), (0.3,−0.5), (0,1) donde se desea que la clasificación agrupe los dos primeros puntos por un lado y los dos segundos por otro. Pero no he usado mucho R para esto y no sé cómo hacerlo. Gracias. Un saludo. [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R-es] pregunta
Al menos en lo que a m� me llega el separador de datos es ; y el separador decimal es . y en la orden pone: sep=,, dec=. Esas opciones son las opciones por defecto, pero si est�s usando castellano con decimales con coma y separados con punto y coma pues eso que tienes que poner sep=; y dec=, Saludos. El 08/05/15 a las 17:39, jbetancourt escribi�: Estimados Al dirigir la lectura de un folder tYA1.csvme da este error y no me percato del motivo, adjunto archivo. Espero su ayuda Saludos Jos� setwd(D:/Public/Documents/R/bioimpedancia) a-read.csv(tYA1.csv,header=TRUE, sep=,, dec=.) Error in read.table(file = file, header = header, sep = sep, quote = quote, : more columns than column names ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] Question about cochran test in R
Hi Luis, (Let's keep R-help in the loop for the benefit of others.) On 2015-05-08 10:25, Luis Fernando García wrote: Thanks a lot for your replies Henry! Your answer was specially a bless! Many thanks this was an issue which was breaking my head. I have another couple of questions, may be you could help me. For post hoc comparison I was planning to run a McNemar test with a bonferroni correction, but wanted to be sure my approach is correct. It's an OK approach, I guess, but you should use the Holm correction rather than Bonferroni. (Holm dominates Bonferroni and is valid under the same arbitrary assumptions.) The classical approach, and as suggested in Cochran (1950), would be to partition the chi-squared statistic into components of interest. In a more general approach, a test of all the post-hoc comparisons is performed simultaneously. This is very efficient, in terms of power, since it takes account of the correlation between the test statistics. Ignoring such dependencies may result in strange results, due to loss of power, where none of the partial null hypotheses are rejected even though the global null hypothesis is rejected. Unfortunately, I'm not aware of any publicly available software that let's you do this. In theory, 'coin' should be able to, and there has even been some work done in this direction, but it's currently unfinished. Henric Winell Sorry if I annoy you with this remaining question. Thanks in advance! 2015-05-07 8:03 GMT-03:00 Henric Winell nilsson.hen...@gmail.com mailto:nilsson.hen...@gmail.com: On 2015-05-07 09:15, Jim Lemon wrote: Hi Luis, Try this page: http://www.r-bloggers.com/cochran-q-test-for-k-related-samples-in-r/ Jim Cochran's Q test is a marginal homogeneity test, and such tests can be performed by the 'mh_test' function in the 'coin' package. The following replicates the result in the blog post library(coin) dta - data.frame( + method= factor(rep(LETTERS[1:4], 6)), + repellent = factor(c(1, 1, 0, 0, + 1, 1, 0, 1, + 1, 0, 0, 0, + 1, 1, 1, 0, + 1, 1, 0, 1, + 1, 1, 0, 1)), + fabric= gl(6, 4, labels = as.roman(1:6)) + ) mh_test(repellent ~ method | fabric, data = dta) Asymptotic Marginal-Homogeneity Test data: repellent by method (A, B, C, D) stratified by fabric chi-squared = 9.3158, df = 3, p-value = 0.02537 and uses the asymptotic approximation to compute the p-value. The 'coin' package also allows you to approximate the exact null distribution using Monte Carlo methods: set.seed(123) mh_test(repellent ~ method | fabric, data = dta, + distribution = approximate(B = 1L)) Approximative Marginal-Homogeneity Test data: repellent by method (A, B, C, D) stratified by fabric chi-squared = 9.3158, p-value = 0.0202 For future reference, 'mh_test' is fairly general and handles both matched pairs or matched sets. So, the well-known tests due McNemar, Cochran, Stuart(-Maxwell) and Madansky are just special cases. For more general symmetry test problems, the 'coin' package offers the 'symmetry_test' function and this can be used to perform, e.g., multivariate marginal homogeneity tests like the multivariate McNemar test (Klingenberg and Agresti, 2006) or the multivariate Friedman test (Gerig, 1969). Henric On Thu, May 7, 2015 at 4:59 PM, Luis Fernando García luysgar...@gmail.com mailto:luysgar...@gmail.com wrote: Dear R Experts, May be this is a basic question for you, but it is something I need really urgently. I need to perform a Chi Square analysis for more than two groups of paired observations. It seems to be ok For Cochran test. Unfortunately I have not found info about this test in R, except for dealing with outliers which is not my aim. I am looking for something like this https://www.medcalc.org/manual/cochranq.php I found a video to perform this analysis in R, but was not specially useful. Does some of you know have some info about how to make this analysis in R? Thanks in advance! [[alternative HTML version deleted]] __ R-help@r-project.org mailto:R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
[R] Confusing 2 classes in a multiclass problem
Dear All, I hope this is not too off topic. Apologies for not sending now any code, but the point is really for me to understand how to proceed. Let's say that you have a multiclass classification problem and the outcome you want to predict is given by 9 different classes {A, B...}. By training several models and checking the confusion matrix, I noticed that it is particularly hard to tell apart class C and D. What is the best way forward? I am thinking about creating two artificial classes: C-and-D and then aggregate all the other levels into a fictitious class Other. Then I can train a model to identify C-and-D vs the Other class. The next step would be to train a model on telling apart only C and D which I had merged in the C-and-D class. Does such an approach sound sensible? Many thanks Lorenzo __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R-es] Redes neuronales
Estimada Jénifer Sánchez Creo que es bueno que copie y pegue el código problema junto con la librería que está utilizando dentro de R. Porque casi seguro que debe haber más de una forma y posiblemente el error está al escribir el código. Su pregunta sin algo de código para leer es casi imposible de responder (yo tampoco tengo mucha experiencia en redes neuronales). Javier Rubén Marcuzzi De: Jénifer Sánchez Enviado el: viernes, 08 de mayo de 2015 12:30 p.m. Para: R-help-es@r-project.org Buenas tardes, escribo porque estoy teniendo problemas para definir el perceptrón que considere los puntos (−0.5, − 0.5), (−0.5,0.5), (0.3,−0.5), (0,1) donde se desea que la clasificación agrupe los dos primeros puntos por un lado y los dos segundos por otro. Pero no he usado mucho R para esto y no sé cómo hacerlo. Gracias. Un saludo. [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R-es] pregunta
Estimados Mi primera opción es usar el asistente de Rstudio (tolos, import …) , el cuál me crea el siguiente código tYA1 - read.csv(C:/Users/Javier Marcuzzi/Downloads/tYA1.csv, sep=;, dec=,) Javier Rubén Marcuzzi De: José Trujillo Carmona Enviado el: viernes, 08 de mayo de 2015 12:48 p.m. Para: R-help-es@r-project.org Al menos en lo que a m� me llega el separador de datos es ; y el separador decimal es . y en la orden pone: sep=,, dec=. Esas opciones son las opciones por defecto, pero si est�s usando castellano con decimales con coma y separados con punto y coma pues eso que tienes que poner sep=; y dec=, Saludos. El 08/05/15 a las 17:39, jbetancourt escribi�: Estimados Al dirigir la lectura de un folder tYA1.csvme da este error y no me percato del motivo, adjunto archivo. Espero su ayuda Saludos Jos� setwd(D:/Public/Documents/R/bioimpedancia) a-read.csv(tYA1.csv,header=TRUE, sep=,, dec=.) Error in read.table(file = file, header = header, sep = sep, quote = quote, : more columns than column names ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es [[alternative HTML version deleted]] [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R-es] pregunta
Estimados Al dirigir la lectura de un folder tYA1.csv me da este error y no me percato del motivo, adjunto archivo. Espero su ayuda Saludos José setwd(D:/Public/Documents/R/bioimpedancia) a-read.csv(tYA1.csv,header=TRUE, sep=,, dec=.) Error in read.table(file = file, header = header, sep = sep, quote = quote, : more columns than column names tYA1.csv Description: Binary data ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R] Grep out columns using a list of strings
Hi, I have a list of 150 strings, say, ap,: aajkss dfghjk sdfghk ... xxcvvn And I would l like to grep out these strings from column names in another file, af,. I've tried the following but none seem to work: aps - af[,grep(ap, colnames(af), value=TRUE)] aps - af[,grep(ap, colnames(af), value=FIXED)] aps - af[,grep(as.character(list(ap),colnames(af))] and also aps - unique (grep(ap, colnames(af)) Is there another way I can do this - maybe without using grep? Thanks! Kate. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] CoDA ANOVA Error
I'm running linear regressions and ANOVAs on 5 sets of compositional data following van den Boogaart and Tolosana-Delgado's book, pp. 129 ff. Four of the five data sets compute without error; one does not. To test results, load package 'compositions'. The input data: for Y structure(c(0.18968103189681, 0.0619, 0.0875, 0.102910291029103, 0.1023, 0.482751724827517, 0.5773, 0.7125, 0.5000500050005, 0.5795, 0.068993100689931, 0.0309, 0.0125, 0.0882088208820882, 0.0341, 0.206879312068793, 0.2371, 0.1125, 0.235323532353235, 0.2614, 0.0516948305169483, 0.0928, 0.075, 0.0735073507350735, 0.0227 ), .Dim = c(5L, 5L), .Dimnames = list(NULL, c(Fi, Ga, Gr, Pr, Sh)), class = acomp) for X c(0.31, 0.31, 0.21, 2, 0.31) Regression model: ( model - lm(ilr(Y) ~ log(X)) ) Convert back from ILR to original units: ( orig - ilrInv(coef(model),orig=Y) ) Then run the ANOVA: ( analvar - anova(model) ) The result displayed is: Error in anova.mlm(model) : residuals have rank 3 4 A Web search found a nabble thread from 2012 but that was related to using the spephical model, not the Pillai model. I do not see differences between the number of columns in the Y and X variables in the different data sets that might throw that error. What might be the cause and is there anything I can do to test the variable for significance? Rich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Revolutions blog roundup: April 2015
Since 2008, Revolution Analytics staff and guests have written about R every weekday at the Revolutions blog: http://blog.revolutionanalytics.com and every month I post a summary of articles from the previous month of particular interest to readers of r-help. In case you missed them, here are some articles related to R from the month of April: Joseph Rickert reviews the inaugural New York City R User Conference, featuring Andrew Gelman: http://blog.revolutionanalytics.com/2015/04/the-ny-r-conference.html Engineer Vineet Abraham compares performance benchmarks for R and Revolution R Open on OS X and Ubuntu: http://blog.revolutionanalytics.com/2015/04/benchmarks-of-rro-on-osx-and-ubuntu.html R was featured in the keynotes for the BUILD developer's conference: http://blog.revolutionanalytics.com/2015/04/see-r-in-action-at-the-build-conference.html Mark Malter created a Shiny application to explore baseball statistics: http://blog.revolutionanalytics.com/2015/04/situational-baseball-analyzing-runs-potential-statistics.html A curated list of the best packages, add-ons and resources for R according to Qin Wenfeng: http://blog.revolutionanalytics.com/2015/04/awesome-r-a-curated-list-of-the-best-add-ons-for-r.html An analysis of paintings from British museums reveals an increasing use of the colour blue over the last two centuries: http://blog.revolutionanalytics.com/2015/04/paintings-getting-blue.html Journalists are increasingly referencing source research via DOIs, and packages from rOpenSci allow R users to access that research programmatically: http://blog.revolutionanalytics.com/2015/04/the-new-science-journalism-and-open-science.html Microsoft is hiring programmers to work on R-related projects: http://blog.revolutionanalytics.com/2015/04/microsoft-hiring-engineers-for-r-projects.html Some examples of visualizing the results of hierarchical clustering with a heat map: http://blog.revolutionanalytics.com/2015/04/r-for-more-powerful-clustering.html The Financial Times published an interactive data visualization based on R to explore European unemployment statistics: http://blog.revolutionanalytics.com/2015/04/financial-times-tracks-unemployment-with-r.html Announcing R 3.2.0: http://blog.revolutionanalytics.com/2015/04/r-320-released.html Recent R user group meetings have covered Shiny, SparkR, htmlwidgets, and dynamic pricing models: http://blog.revolutionanalytics.com/2015/04/r-user-group-meetings-this-week-in-the-bay-area-and-around-the-world.html A story about teaching R to archaeologists in Myanmar, and coping with package installation in a low-bandwidth environment with the miniCRAN package: http://blog.revolutionanalytics.com/2015/04/r-in-myanmar.html RPowerLabs allows electrical engineers to experiment on virtual power distribution systems: http://blog.revolutionanalytics.com/2015/04/rpowerlabs-electric-power-system-virtual-laboratories-online.html Two high-performance packages from RStudio for reading data into R: readr (for text data) and readxl (for Excel data): http://blog.revolutionanalytics.com/2015/04/new-packages-for-reading-data-into-r-fast.html A list of the top 25 R user groups in the world by membership: http://blog.revolutionanalytics.com/2015/04/where-are-the-r-users.html A guide to association rules and market basket analysis in R: http://blog.revolutionanalytics.com/2015/04/association-rules-and-market-basket-analysis-with-r.html The choroplethrZip package allows R users to create data maps from US zip codes: http://blog.revolutionanalytics.com/2015/04/exploring-san-francisco-with-choropleth.html Revolution Analytics is now a subsidiary of Microsoft: http://blog.revolutionanalytics.com/2015/04/revolution-analytics-microsoft.html DeployR 7.4, a web-services framework for integrating R code to other applications, is now available for download: http://blog.revolutionanalytics.com/2015/04/deployr-74-released.html Coarse-grained parallel computing with R on servers and Hadoop with rxExec in Revolution R Enterprise: http://blog.revolutionanalytics.com/2015/04/coarse-grain-parallelism-with-foreach-and-rxexec.html Revolution R Open 8.0.2 was released (and 8.0.3 is now available, too): http://blog.revolutionanalytics.com/2015/04/a-minor-update-revolution-r-open-802.html General interest stories (not related to R) in the past month included: a video travelling at the speed of light (http://blog.revolutionanalytics.com/2015/04/because-its-friday-slow-light.html), a snowy music video (http://blog.revolutionanalytics.com/2015/04/because-its-friday-boy-and-bear-in-the-snow.html), and visualizing the baseline in a Marvin Gaye classic (http://blog.revolutionanalytics.com/2015/04/because-its-friday-all-about-that-bassline.html). Meeting times for local R user groups (http://blog.revolutionanalytics.com/local-r-groups.html) can be found on the updated R Community Calendar at: http://blog.revolutionanalytics.com/calendar.html If
[R] trouble installing RcppOctave
Dear R list, I am trying install the RcppOctave package to run Matlab packages in R. I did the following, install.packages(RcppOctave) After some time of installation, I get the following error. I have homebrew installed, I also have Octave and Matlab install. installing the source package ‘RcppOctave’ trying URL ' http://watson.nci.nih.gov/cran_mirror/src/contrib/RcppOctave_0.14.5.tar.gz' Content type 'application/octet-stream' length 767455 bytes (749 KB) == downloaded 749 KB * installing *source* package ‘RcppOctave’ ... ** package ‘RcppOctave’ successfully unpacked and MD5 sums checked checking R CC... clang checking R CFLAGS... -Wall -mtune=core2 -g -O2 checking R CPPFLAGS... -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include checking R CXXFLAGS... -Wall -mtune=core2 -O3 checking for clang... /usr/bin/clang checking for gcc... clang checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether clang accepts -g... yes checking for clang option to accept ISO C89... none needed checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking for g++... /usr/bin/g++ Original R_LDFLAGS: -F/Library/Frameworks/R.framework/.. -framework R -lpcre -llzma -lbz2 -lz -licucore -lm -liconv Original R_CPPFLAGS: -I/Library/Frameworks/R.framework/Resources/include checking whether R is a shared library... yes checking type of Operating System... Darwin checking whether OS is Mac OS (Darwin)... yes Using mkoctfile with R_LDFLAGS: -Wl,-F/Library/Frameworks/R.framework/.. -framework R -lpcre -llzma -lbz2 -lz -licucore -lm -liconv Using mkoctfile with R_CPPFLAGS: -I/Library/Frameworks/R.framework/Resources/include checking Octave binary path specification... none using Octave binary path from $PATH checking for octave-config... no checking for mkoctfile... no configure: error: mkoctfile not found, is Octave installed? - On Mac OS please check that the required packages are installed: * octave package from homebrew (works out of the box): $ brew install gfortran octave # install as usual in R install.packages('RcppOctave') ERROR: configuration failed for package ‘RcppOctave’ * removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/RcppOctave’ The downloaded source packages are in ‘/private/var/folders/qf/q83rlh3x2qjcp75c3phtj81cgn/T/Rtmpdh718K/downloaded_packages’ Warning message: In install.packages(RcppOctave) : installation of package ‘RcppOctave’ had non-zero exit status Thanks in advance, Mike [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] nlminb supplying NaN parameters to objective function
Your problem is saying (on my machine) that it cannot compute the gradient. Since it does this numerically, my guess is that the step to evaluate the gradient violates the bounds and we get log(-something). I also get Warning messages: 1: In dnbinom(x = dummyData[, Y], mu = mu, size = params[length(params)], : NaNs produced 2: In nlminb(start = sv, objective = nLL, lower = 0, upper = Inf, control = list(trace = TRUE)) : NA/NaN function evaluation 3: In dnbinom(x = dummyData[, Y], mu = mu, size = params[length(params)], : NaNs produced 4: In nlminb(start = sv, objective = nLL, lower = 0, upper = Inf, control = list(trace = TRUE)) : NA/NaN function evaluation I put lower=0.01 and got convergence OK, but that may not be suitable, since all but one of the parameters are at that bound. $par [1] 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 [7] 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 [13] 0.09168027 $objective [1] 11879.51 $convergence [1] 0 $iterations [1] 8 $evaluations function gradient 13 119 $message [1] relative convergence (4) As it turns out, Duncan Murdoch, Ben Bolker and I had a meeting yesterday to discuss improvements in optimization and nonlinear least squares and derivatives. One suggestion to be implemented is a wrapper for objective functions to reveal when bounds are violated. It will, however, take a little time for me to get that organized. FYI, without the reproducible example, you would not have received this attempt to explain things. Thanks. JN A follow-up to my yesterday's email. I was able to make a reproducible example. All you will have to do is load the .RData file that you can download here: https://drive.google.com/file/d/0B0DKwRjF11x4dG1uRWhwb1pfQ2s/view?usp=sharing and run this line of code: nlminb(start=sv, objective = nLL, lower = 0, upper = Inf, control=list(trace=TRUE)) which output the following: 0: 12523.401: 0.0328502 0.0744493 0.00205298 0.0248628 0.0881807 0.0148887 0.0244485 0.0385922 0.0714495 0.0161784 0.0617551 0.0244901 0.0784038 1: 12421.888: 0.0282245 0.0697934 0.0 0.0199076 0.0833634 0.0101135 0.0189494 0.0336236 0.0712130 0.0160687 0.0616015 0.0244689 0.0660129 2: 12050.535: 0.00371847 0.0451786 0.0 0.0 0.0575667 0.0 0.0 0.00697067 0.0697205 0.0156250 0.0608550 0.0243431 0.0994355 3: 12037.682: 0.00303460 0.0445012 0.0 0.0 0.0568530 0.0 0.0 0.00636016 0.0696959 0.0156250 0.0608550 0.0243419 0.0988824 4: 12012.684: 0.00164710 0.0431313 0.0 0.0 0.0554032 0.0 0.0 0.00515500 0.0696451 0.0156250 0.0608550 0.0243395 0.0978328 5: 12003.017: 0.00107848 0.0425739 0.0 0.0 0.0548073 0.0 0.0 0.00469592 0.0696233 0.0156250 0.0608550 0.0243386 0.0974616 6: 11984.372: 0.0 0.0414397 0.0 0.0 0.0535899 0.0 0.0 0.00378996 0.0695782 0.0156250 0.0608550 0.0243370 0.0967449 7: 11978.154: 0.0 0.0409106 0.0 0.0 0.0530158 0.0 0.0 0.00340746 0.0695560 0.0156250 0.0608550 0.0243363 0.0964537 8:-0.000: 0.0 nan 0.0 0.0 nan 0.0 0.0 nan nan nan nan nan nan Regards, Jean 2015-05-06 17:43 GMT-07:00 Jean Marchal jean.d.marc...@gmail.com: Dear list, I am doing some maximum likelihood estimation using nlminb() with box-constraints to ensure that all parameters are positive. However, nlminb() is behaving strangely and seems to supply NaN as parameters to my objective function (confirmed using browser()) and output the following: $par [1] NaN NaN NaN 0 NaN 0 NaN NaN NaN NaN NaN NaN NaN $objective [1] 0 $convergence [1] 1 $iterations [1] 19 $evaluations function gradient 87 542 $message [1] gr cannot be computed at initial par (65) __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help 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 INDIVIDUAL effects of multiple qualitative variables (ordered and unordered factors)
Dear Richard, I really appreciate your help. ## Your download host seems to want to give me software, so I am not taking it. *To download my file, please uncheck the Use our download manager and get recommended downloads option. *But If you prefer, I might send my file attached by email. #In fact, I wish calculate library (quantreg) qrModel2=rq(data=tabela1.1, pontoefetivo ~ p1 + p21 + p22 + p23 + p24 + p25 + p34 + p5 + p6 + p7 + p8 + p9, tau=0.5) summary(qrModel2) #But I have to suppress the intercept and consider that the reference group is also zero. #When I make qrModel3=rq(data=tabela1.1, pontoefetivo ~ 0+ p1 + p21 + p22 + p23 + p24 + p25 + p34 + p5 + p6 + p7 + p8 + p9, tau=0.5) summary(qrModel3) #The value of the reference group reappears in the first estimated coefficient. Is there any way to do this? Thanks in advance , Rafael Costa. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Specifying Directory to Search When Updating a Package
R packages here are installed in /usr, not /usr/local/. Most of the time when I run 'update.packages()' each finds headers in /usr/include. Today, the package 'rgl' failed to build because it was looking for freetype.h in /usr/local/include/freetype2/. By making a softlink from /usr/include/freetype2 to /usr/local/include/ the package update built without further error. For future reference, if an update attempt fails because the code is looking in a different directory than where the required file (usually a header) is found, is there a way to specify the correct directory when issuing the update.packages() command? Rich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] nlminb supplying NaN parameters to objective function
Prof. Nash, awesome! This sounds promising. Thank you for the explanation, Jean 2015-05-08 14:16 GMT-07:00 Prof J C Nash (U30A) nas...@uottawa.ca: Your problem is saying (on my machine) that it cannot compute the gradient. Since it does this numerically, my guess is that the step to evaluate the gradient violates the bounds and we get log(-something). I also get Warning messages: 1: In dnbinom(x = dummyData[, Y], mu = mu, size = params[length(params)], : NaNs produced 2: In nlminb(start = sv, objective = nLL, lower = 0, upper = Inf, control = list(trace = TRUE)) : NA/NaN function evaluation 3: In dnbinom(x = dummyData[, Y], mu = mu, size = params[length(params)], : NaNs produced 4: In nlminb(start = sv, objective = nLL, lower = 0, upper = Inf, control = list(trace = TRUE)) : NA/NaN function evaluation I put lower=0.01 and got convergence OK, but that may not be suitable, since all but one of the parameters are at that bound. $par [1] 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 [7] 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 [13] 0.09168027 $objective [1] 11879.51 $convergence [1] 0 $iterations [1] 8 $evaluations function gradient 13 119 $message [1] relative convergence (4) As it turns out, Duncan Murdoch, Ben Bolker and I had a meeting yesterday to discuss improvements in optimization and nonlinear least squares and derivatives. One suggestion to be implemented is a wrapper for objective functions to reveal when bounds are violated. It will, however, take a little time for me to get that organized. FYI, without the reproducible example, you would not have received this attempt to explain things. Thanks. JN A follow-up to my yesterday's email. I was able to make a reproducible example. All you will have to do is load the .RData file that you can download here: https://drive.google.com/file/d/0B0DKwRjF11x4dG1uRWhwb1pfQ2s/view?usp=sharing and run this line of code: nlminb(start=sv, objective = nLL, lower = 0, upper = Inf, control=list(trace=TRUE)) which output the following: 0: 12523.401: 0.0328502 0.0744493 0.00205298 0.0248628 0.0881807 0.0148887 0.0244485 0.0385922 0.0714495 0.0161784 0.0617551 0.0244901 0.0784038 1: 12421.888: 0.0282245 0.0697934 0.0 0.0199076 0.0833634 0.0101135 0.0189494 0.0336236 0.0712130 0.0160687 0.0616015 0.0244689 0.0660129 2: 12050.535: 0.00371847 0.0451786 0.0 0.0 0.0575667 0.0 0.0 0.00697067 0.0697205 0.0156250 0.0608550 0.0243431 0.0994355 3: 12037.682: 0.00303460 0.0445012 0.0 0.0 0.0568530 0.0 0.0 0.00636016 0.0696959 0.0156250 0.0608550 0.0243419 0.0988824 4: 12012.684: 0.00164710 0.0431313 0.0 0.0 0.0554032 0.0 0.0 0.00515500 0.0696451 0.0156250 0.0608550 0.0243395 0.0978328 5: 12003.017: 0.00107848 0.0425739 0.0 0.0 0.0548073 0.0 0.0 0.00469592 0.0696233 0.0156250 0.0608550 0.0243386 0.0974616 6: 11984.372: 0.0 0.0414397 0.0 0.0 0.0535899 0.0 0.0 0.00378996 0.0695782 0.0156250 0.0608550 0.0243370 0.0967449 7: 11978.154: 0.0 0.0409106 0.0 0.0 0.0530158 0.0 0.0 0.00340746 0.0695560 0.0156250 0.0608550 0.0243363 0.0964537 8:-0.000: 0.0 nan 0.0 0.0 nan 0.0 0.0 nan nan nan nan nan nan Regards, Jean 2015-05-06 17:43 GMT-07:00 Jean Marchal jean.d.marc...@gmail.com: Dear list, I am doing some maximum likelihood estimation using nlminb() with box-constraints to ensure that all parameters are positive. However, nlminb() is behaving strangely and seems to supply NaN as parameters to my objective function (confirmed using browser()) and output the following: $par [1] NaN NaN NaN 0 NaN 0 NaN NaN NaN NaN NaN NaN NaN $objective [1] 0 $convergence [1] 1 $iterations [1] 19 $evaluations function gradient 87 542 $message [1] gr cannot be computed at initial par (65) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Changing layout in grid.arrange
Hi Roy, If this helps, you can get the layout like this: split.screen(figs=matrix(c(rep(0,5),rep(0.5,10),rep(1,5), rep(seq(0.8,0,by=-0.2),2),rep(seq(1,0.2,by=-0.2),2)),ncol=4)) for(scr in 1:10) { screen(scr) par(mar=c(0,0,0,0)) plot(0.5,0.5,xlim=c(0,1),ylim=c(0,1), axes=FALSE,xlab=,ylab=,type=n) box() text(0.5,0.5,scr) } close.screen(all=TRUE) Jim On Sat, May 9, 2015 at 12:53 AM, Roy Mendelssohn - NOAA Federal roy.mendelss...@noaa.gov wrote: Hi All: I am doing something very similar to the the example in the grid.arrange package: require(ggplot2) plots = lapply(1:10, function(.x) qplot(1:10,rnorm(10), main=paste(plot,.x))) require(gridExtra) do.call(grid.arrange, plots) If you run this, the layout is 4 rows and 3 columns with graphs 1-3 going across. What I would like instead is for the layout to have 2 columns and 5 rows, with graphs 1-5 going down the first column, graphs 6-10 going down the second column but almost everything I have tried has failed. Any help appreciated. -Roy M. ** The contents of this message do not reflect any position of the U.S. Government or NOAA. ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new address and phone*** 110 Shaffer Road Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ Old age and treachery will overcome youth and skill. From those who have been given much, much will be expected the arc of the moral universe is long, but it bends toward justice -MLK Jr. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Changing layout in grid.arrange
Thanks, it took some digging in the internet, but I figured out how to do it. The first thing is how to pass options to grid.arrange when used in do.call. It takes a list, which I tried in several different ways, the list has to be of a certain form, so something like: args.list - c(plots,list(nrow=5,ncol=2)) do.call(grid.arrange,args.list) The second thing is to interleave sequences before doing the lapply, as in: x- 1:5 y-6:10 iOrder-c(rbind(x,y)) I should add that Dennis Murphy sent this solution off-line, I will add it for completeness: require(ggplot2) plots = lapply(1:10, function(.x) qplot(1:10,rnorm(10), main=paste(plot,.x))) require(gridExtra) do.call(grid.arrange, c(plots[as.vector(gdata::interleave(1:5, 6:10))], list(nrow = 5))) Either of these produces a grid of plots with 5 rows and two columns, which is what I was after. -Roy On May 8, 2015, at 5:38 PM, Jim Lemon drjimle...@gmail.com wrote: Hi Roy, If this helps, you can get the layout like this: split.screen(figs=matrix(c(rep(0,5),rep(0.5,10),rep(1,5), rep(seq(0.8,0,by=-0.2),2),rep(seq(1,0.2,by=-0.2),2)),ncol=4)) for(scr in 1:10) { screen(scr) par(mar=c(0,0,0,0)) plot(0.5,0.5,xlim=c(0,1),ylim=c(0,1), axes=FALSE,xlab=,ylab=,type=n) box() text(0.5,0.5,scr) } close.screen(all=TRUE) Jim On Sat, May 9, 2015 at 12:53 AM, Roy Mendelssohn - NOAA Federal roy.mendelss...@noaa.gov wrote: Hi All: I am doing something very similar to the the example in the grid.arrange package: require(ggplot2) plots = lapply(1:10, function(.x) qplot(1:10,rnorm(10), main=paste(plot,.x))) require(gridExtra) do.call(grid.arrange, plots) If you run this, the layout is 4 rows and 3 columns with graphs 1-3 going across. What I would like instead is for the layout to have 2 columns and 5 rows, with graphs 1-5 going down the first column, graphs 6-10 going down the second column but almost everything I have tried has failed. Any help appreciated. -Roy M. ** The contents of this message do not reflect any position of the U.S. Government or NOAA. ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new address and phone*** 110 Shaffer Road Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ Old age and treachery will overcome youth and skill. From those who have been given much, much will be expected the arc of the moral universe is long, but it bends toward justice -MLK Jr. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ** The contents of this message do not reflect any position of the U.S. Government or NOAA. ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new address and phone*** 110 Shaffer Road Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ Old age and treachery will overcome youth and skill. From those who have been given much, much will be expected the arc of the moral universe is long, but it bends toward justice -MLK Jr. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Grep out columns using a list of strings
How about %in% ? # preparing something that looks like I think your data looks like: ap - c(aajkss, dfghjk, sdfghk, xxcvvn) af - matrix(1:10, nrow=2) colnames(af) - c(aajkss, b, c, dfghjk, e) # doing what I think you need done: ap[ap %in% colnames(af)] Cheers, B. (PS. a reproducible example saves us all time and unnecessary effort. :-) On May 8, 2015, at 3:50 PM, Kate Ignatius kate.ignat...@gmail.com wrote: Hi, I have a list of 150 strings, say, ap,: aajkss dfghjk sdfghk ... xxcvvn And I would l like to grep out these strings from column names in another file, af,. I've tried the following but none seem to work: aps - af[,grep(ap, colnames(af), value=TRUE)] aps - af[,grep(ap, colnames(af), value=FIXED)] aps - af[,grep(as.character(list(ap),colnames(af))] and also aps - unique (grep(ap, colnames(af)) Is there another way I can do this - maybe without using grep? Thanks! Kate. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.