Re: [R] Need content_transformer() called by tm_map() to change non-letters to spaces
Regex [^a-zA-Z] reads as not a letter. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On April 23, 2015 1:10:41 PM PDT, Mike mikeh...@y7mail.com wrote: Hello, In the following code, any characters matching /|@| \\|) will be changed to a space. library(tm) toSpace - content_transformer(function(x, pattern) gsub(pattern, , x)) docs - tm_map(docs, toSpace, /|@| \\|) What code would transform all non-letters to a space? (What goes where the x's are.)It is very difficult to put all non-letters in a string... So I'm doing the opposite of the above. toSpace_2 - content_transformer(function xxx)) docs - tm_map(docs, toSpace_2, abcdefghijklmnopqrstuvwxyz) This needs to be done by a content_transformer() function to maintain the integrity of docs. Thanks [[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-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] cbind question, please
Hello, I am not sure what you mean by a matrix. If you want to have a matrix, use the function matrix, (matrix(c(dog,cat,tree),3)) but I have the feeling you really want a data frame as you are talking about variables. In that case simply use mydataframe - data.frame(dog,cat,tree) If you are not sure what you want, please read the intro to R pdf which is included in your installed R library. Best regards, daniel Feladó: R-help [r-help-boun...@r-project.org] ; meghatalmaz#243;: Erin Hodgess [erinm.hodg...@gmail.com] Küldve: 2015. április 24. 0:41 To: R help Tárgy: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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-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] R MSI Installer
On 24/04/2015 01:22, billy am wrote: Hi Everyone , Is there a place where I can download msi installer for latest version of R? I believe not: certainly not an official one. Consult the manual as to how to build one if you really need one. Thanks Billy [[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. PLEASE do: no HTML for a start. -- Brian D. Ripley, rip...@stats.ox.ac.uk Emeritus Professor of Applied Statistics, University of Oxford 1 South Parks Road, Oxford OX1 3TG, UK __ 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] Mean of dates
Dear fellow R-help members, If my data is MM DD HH 2015 04 24 01 2015 04 24 02 2015 04 24 06 Where : year MM:month DD:day HH: hour How could I calculate the mean of the ISOdatetime(,MM,DD,HH,0,0) of these? Note: I set minutes and seconds to 0, as I don't have data for them. Thank you in advance! -- Jue Lin-Ye --- Civil Engineering phD candidate Maritime Engineering Laboratory (LIM) Universitat Politècnica de Catalunya (UPC) C/Jordi Girona 1-3, Barcelona 08034 (Spain) - [[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] Mean of dates
On 24 April 2015 at 12:59, Achim Zeileis achim.zeil...@uibk.ac.at wrote: On Fri, 24 Apr 2015, Jue Lin-Ye wrote: Dear fellow R-help members, If my data is MM DD HH 2015 04 24 01 2015 04 24 02 2015 04 24 06 Where : year MM:month DD:day HH: hour How could I calculate the mean of the ISOdatetime(,MM,DD,HH,0,0) of these? With the mean() method? On my machine: R mean(ISOdatetime(,MM,DD,HH,0,0)) [1] 2015-04-24 03:00:00 CEST Hi! Maybe the problem is when I try to create the vector that I am looking for. Please check this code out. X_season1-matrix(c(2015, 04, 24, 01, 2015 ,04, 24, 02, 2015 ,04 ,24 ,03 ,2015 ,04 ,24 ,05, 2015, 04, 24 ,06 ,2015, 04 ,24 ,10),3,8,byrow=T);colnames(X_season1)-c(AAi,MMi,DDi,HHi,AAf,MMf,DDf,HHf) time2-NULL for(i5 in 1:nrow(X_season1)){ time2[i5]-mean( as.Date(c(ISOdatetime(X_season1[i5,AAi],X_season1[i5,MMi],X_season1[i5,DDi],X_season1[i5,HHi],0,0), ISOdatetime(X_season1[i5,AAf],X_season1[i5,MMf],X_season1[i5,DDf],X_season1[i5,HHf],0,0)), format=%-%mm-%dd %H:%m:%s),trim=0)} Thanks! hth, Z Note: I set minutes and seconds to 0, as I don't have data for them. ?Thank you in advance!? -- Jue Lin-Ye --- Civil Engineering phD candidate Maritime Engineering Laboratory (LIM) Universitat Politècnica de Catalunya (UPC) C/Jordi Girona 1-3, Barcelona 08034 (Spain) - [[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. -- Jue Lin-Ye --- Civil Engineering phD candidate Maritime Engineering Laboratory (LIM) Universitat Politècnica de Catalunya (UPC) C/Jordi Girona 1-3, Barcelona 08034 (Spain) - [[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-es] Diferencias entre la version de 32 y 64 bits
Hola Sergio, En principio las diferencias entre 32 y 64 bits están relacionadas con cuánta RAM puede gestionar R. Esto efectivamente puede afectar a tu problema por el nivel de profundidad que el algoritmo simplex utilice hasta encontrar la solución y eso está asociado con la RAM que puede gestionarse. De todas formas prueba, en tu máquina de 32 bits, a modificar los parámetros de control donde supongo que podrás indicar el número máximo de iteraciones o incluso la precisión con la que simplex ya considere que ha convergido a una solución. Estos parámetros suelen estar en una función auxiliar de control. Saludos, Carlos. El 24 de abril de 2015, 9:21, Sergio Castro castro.rodriguez.ser...@gmail.com escribió: Buenos días, He hecho un desarrollo en mi máquina (de 64 bits) y funciona correctamente. Se trata de un problema de programación lineal (usando lpSolve y lpSolveAPI). El problema viene al ejecutar un caso concreto que en la máquina del usuario (de 32 bits) nos da que no hay solución factible para ese problema, pero en mi máquina de 64 sí que nos devuelve una solución. ¿Hay alguna forma (limitar decimales, por ejemplo) de solucionar esto? He probado con las versiones de R 3.1.3 y 3.2 Muchas gracias. Un saludo. ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es -- Saludos, Carlos Ortega www.qualityexcellence.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] Mean of dates
On Fri, 24 Apr 2015, Jue Lin-Ye wrote: Dear fellow R-help members, If my data is MM DD HH 2015 04 24 01 2015 04 24 02 2015 04 24 06 Where : year MM:month DD:day HH: hour How could I calculate the mean of the ISOdatetime(,MM,DD,HH,0,0) of these? With the mean() method? On my machine: R mean(ISOdatetime(,MM,DD,HH,0,0)) [1] 2015-04-24 03:00:00 CEST hth, Z Note: I set minutes and seconds to 0, as I don't have data for them. ?Thank you in advance!? -- Jue Lin-Ye --- Civil Engineering phD candidate Maritime Engineering Laboratory (LIM) Universitat Politècnica de Catalunya (UPC) C/Jordi Girona 1-3, Barcelona 08034 (Spain) - [[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-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] Warning message when starting RStudio
On 23/04/15 13:41, Albin Blaschka wrote: Hello Am 23.04.2015 um 09:57 schrieb Berend Hasselman: On 23-04-2015, at 08:45, Sun Shine phaedr...@gmail.com wrote: Hi list Recently, when starting up RStudio, the following warning is being displayed: Error in tools:::httpdPort = 0L : comparison (4) is possible only for atomic and list types I think that this is specific to RStudio because starting R in a terminal window doesn't produce this message. Does anyone have an idea on how to clear the conditions that are giving rise to this warning? Upgrade R-Studio, it is a problem in the interaction between R and R-Studio, which was solved with the new version of R-Studio... I had the same problem... HTH, Albin Hi Albin That did help - thanks so much! Cheers Sun __ 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] R MSI Installer
Hi Everyone , Is there a place where I can download msi installer for latest version of R? Thanks Billy [[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] cbind question, please
On 24/04/15 10:41, Erin Hodgess wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 I don't understand how you managed to get *that*. When I did the obvious thing --- do.call(cbind,as.list(big.char)) --- I got (as expected :-) ) [,1] [,2] [,3] [1,] dog cat tree Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. do.call(cbind,lapply(big.char,get,envir=.GlobalEnv)) Note: I had to throw in the specification of envir otherwise get() got the cat() function from base rather than your vector cat. Probably not a problem for your real application; shouldn't hurt, but. Another salutary example of why it's not a good idea to give data sets names that are names of R built-ins. cheers, Rolf -- Rolf Turner Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 Home phone: +64-9-480-4619 __ 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] run Rscript and ignore errors?
This seems like a recipe for garbage results to me, but there may be I something you can set the error option to. See ?options. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On April 23, 2015 9:51:31 AM PDT, Nick Matzke nickmatzke.n...@gmail.com wrote: Hi R-help, I've looked at google, the Rscript documentation and the Rscript --help output and haven't found much on this. So, here's my question: I have a rather long script that runs on various input datasets. It is quite convenient to run the script from the Terminal command line with Rscript scriptname.R However, some datasets will cause errors. These are non-essential errors -- just some datasets don't have certain columns so certain parts of the overall analysis don't produce figures etc. Yes, I could go through the whole script and insert try() statements, etc. But I'm lazy. So, is there a way to run Rscript or something similar, and just have it ignore all errors (i.e., keep running through the script)? I.e., just like what happens if you just copy-paste the whole script into the R window -- errors happen and are noted but the rest of the script keeps running. Thanks very much for any help!! Cheers! Nick [[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-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] cbind question, please
What are you expecting? dog - 1:3 cat - 2:4 tree - 5:7 big.char - c(dog,cat,tree) xx - cbind(dog, cat, tree, big.char) gives me xx1 - structure(c(1, 2, 3, 2, 3, 4, 5, 6, 7, dog, cat, tree), .Dim = 3:4, .Dimnames = list(NULL, c(dog, cat, tree, big.char))) John Kane Kingston ON Canada -Original Message- From: erinm.hodg...@gmail.com Sent: Thu, 23 Apr 2015 18:41:05 -0400 To: r-h...@stat.math.ethz.ch Subject: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ 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] cbind question, please
Steve Taylor steve.tay...@aut.ac.nz on Thu, 23 Apr 2015 23:32:00 + writes: This works for me... get0 = function(x) get(x,pos=1) sapply(big.char, get0) Note that get0() is a _ somewhat important for efficient code _ new function since R 3.2.0 so you'd rather call your functions differently... The extra step seems necessary because without it, get() gets base::cat() instead of cat. cheers, Steve -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Erin Hodgess Sent: Friday, 24 April 2015 10:41a To: R help Subject: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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-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] - Obtaining superscripts to affix to means that are not significantly different from each other with R
Hi Joachim, This function allows the user to set some characters in a string to superscript or subscript. If sup or sub are set to one or more numbers corresponding to an index in the string, those letters will be placed appropriately. I can't properly test this as there is some problem with X11 fonts that has appeared with the upgrade to R 3.2.0 and the cex argument seems to have no effect. supsubtext-function(x,y,label,sup=NA,sub=NA,cex=1,sscex=0.8,xadj=0,...) { nlabchar-nchar(label) yadj-rep(0.5,nlabchar) if(!is.na(sup)) yadj[sup]-0 if(!is.na(sub)) yadj[sub]-1 labbits-strsplit(label,)[[1]] currentx-x for(labchar in 1:nlabchar) { text(x,y,labbits[labchar],adj=c(xadj,yadj[labchar]), cex=ifelse(yadj[labchar]!=0.5,sscex,cex),...) x-x+strwidth(labbits[labchar]) } } Jim On Thu, Apr 23, 2015 at 11:02 PM, Joachim Audenaert joachim.audena...@pcsierteelt.be wrote: Is there also a version for non parametric tests like: pairwise.wilcox.test {stats} Met vriendelijke groeten - With kind regards, Joachim Audenaert onderzoeker gewasbescherming - crop protection researcher PCS | proefcentrum voor sierteelt - ornamental plant research Schaessestraat 18, 9070 Destelbergen, België T: +32 (0)9 353 94 71 | F: +32 (0)9 353 94 95 E: joachim.audena...@pcsierteelt.be | W: www.pcsierteelt.be From: David L Carlson dcarl...@tamu.edu To: Joachim Audenaert joachim.audena...@pcsierteelt.be, r-help@r-project.org r-help@r-project.org Date: 23/04/2015 14:51 Subject:RE: [R] - Obtaining superscripts to affix to means that are not significantly different from each other with R The function cld() in package multcomp generates compact letter displays, but does not format them as exponents of the group names. - David L Carlson Department of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Joachim Audenaert Sent: Thursday, April 23, 2015 4:58 AM To: r-help@r-project.org Subject: [R] - Obtaining superscripts to affix to means that are not significantly different from each other with R Hello all, It is often time consuming to interpret p-values of multiple pairwise comparisons of groups and assign them a letter code for publication purposes. So I found this interesting link to a program that does this for you. http://www.jerrydallal.com/lhsp/similar.htm I was wondering if something similar exists in R? Met vriendelijke groeten - With kind regards, Joachim Audenaert onderzoeker gewasbescherming - crop protection researcher PCS | proefcentrum voor sierteelt - ornamental plant research Schaessestraat 18, 9070 Destelbergen, Belgi� T: +32 (0)9 353 94 71 | F: +32 (0)9 353 94 95 E: joachim.audena...@pcsierteelt.be | W: www.pcsierteelt.be Heb je je individuele begeleiding bemesting (CVBB) al aangevraagd? | Het PCS op LinkedIn Disclaimer | Please consider the environment before printing. Think green, keep it on the screen! [[alternative HTML version deleted]] Heb je je individuele begeleiding bemesting (CVBB) al aangevraagd? | Het PCS op LinkedIn Disclaimer | Please consider the environment before printing. Think green, keep it on the screen! [[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-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] cbind question, please
Here is the big picture. I have a character vector with all of the names of the variables in it. I want to cbind all of the variables to create a matrix. Doing 3 is straightforward, but many, not so much. Hence my question. Thanks so much for your answers! Sincerely, Erin On Thu, Apr 23, 2015 at 7:44 PM, John Kane jrkrid...@inbox.com wrote: What are you expecting? dog - 1:3 cat - 2:4 tree - 5:7 big.char - c(dog,cat,tree) xx - cbind(dog, cat, tree, big.char) gives me xx1 - structure(c(1, 2, 3, 2, 3, 4, 5, 6, 7, dog, cat, tree), .Dim = 3:4, .Dimnames = list(NULL, c(dog, cat, tree, big.char))) John Kane Kingston ON Canada -Original Message- From: erinm.hodg...@gmail.com Sent: Thu, 23 Apr 2015 18:41:05 -0400 To: r-h...@stat.math.ethz.ch Subject: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! Check it out at http://www.inbox.com/marineaquarium -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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] cbind question, please
Is this what you're looking for? dog - 1:3 bat - 2:4 tree - 5:7 big.char - c(dog,bat,tree) do.call(cbind,lapply(big.char, get)) [,1] [,2] [,3] [1,]125 [2,]236 [3,]347 On Thu, Apr 23, 2015 at 3:41 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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-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] cbind question, please
G'day Erin, On Thu, 23 Apr 2015 20:51:18 -0400 Erin Hodgess erinm.hodg...@gmail.com wrote: Here is the big picture. I have a character vector with all of the names of the variables in it. I want to cbind all of the variables to create a matrix. Doing 3 is straightforward, but many, not so much. So I guess you want something like: R do.call(cbind, sapply(big.char, as.name)) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 Which does not seem to have the problem of confusing the numeric vector `cat' with the function 'cat'. HTH. Cheers, Berwin __ 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] Diferencias entre la version de 32 y 64 bits
Buenos días, He hecho un desarrollo en mi máquina (de 64 bits) y funciona correctamente. Se trata de un problema de programación lineal (usando lpSolve y lpSolveAPI). El problema viene al ejecutar un caso concreto que en la máquina del usuario (de 32 bits) nos da que no hay solución factible para ese problema, pero en mi máquina de 64 sí que nos devuelve una solución. ¿Hay alguna forma (limitar decimales, por ejemplo) de solucionar esto? He probado con las versiones de R 3.1.3 y 3.2 Muchas gracias. Un saludo. ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] cbind question, please
I am amazed at the number of rather obtuse misunderstandings of the actual nature of Erin's question. The suggestion that Erin should read the intro to R made me smile. Erin is a long time and highly sophisticated user of R; she has no need to read the intro. The person who made that suggestion should have read her question more thoughtfully. Also I liked Steve Taylor's and Marc Swartz's nifty solutions that use sapply(); much sexier than my rather kludgy effort using do.call(). Berwin Turlach's combination of do.call() and sapply() is pretty sexy too. cheers, Rolf Turner -- Rolf Turner Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 Home phone: +64-9-480-4619 __ 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] Error increasing font size in R 3.2.0
I wanted to increase the size of the font in R, but when I do, I get the error message below. I've searched on Google, and the only thing I saw is about changing the version of X11. I'm running the current version of X11, and running OS X Yosemite 10.10.3. I'm using a Mac Desktop, 3.2 Ghz processor. Any thoughts on how I can fix this? Because I have 21.5 inch monitor, the default size of 8 is a little small for my liking. 2015-04-23 20:45:07.429 R[4458:2481342] Layout still needs update after calling -[NSScrollView layout]. NSScrollView or one of its superclasses may have overridden -layout without calling super. Or, something may have dirtied layout in the middle of updating it. Both are programming errors in Cocoa Autolayout. The former is pretty likely to arise if some pre-Cocoa Autolayout class had a method called layout, but it should be fixed. Thanks so much for your help, Chris [[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] lm() funtion
try lm.ridge from MASS package. __ 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] some general advice sought on the use of gctorture()
On 04/24/2015 06:49 AM, Franckx Laurent wrote: Dear all I have bumped into the dreaded 'segfault' error type when running some C++ code using .Call(). segfaults often involve invalid memory access at the C level that are best discovered via valgrind or similar rather than gctorture. A good way to spot these is to (a) come up with a _minimal_ reproducible script test.R that takes just a few seconds to run and that tickles, at least some times, the segfault (b) make sure that your package is compiled without optimizations and with debugging symbols, e.g., in ~/.R/Makevars add the lines CFLAGS=-ggdb -O0 CXXFLAGS=-ggdb -O0 (c) run the code under 'valgrind' R -d valgrind -f test.r Look especially for 'invalid read' or 'invalid write' messages, and isolate _your_ code in the callback that the message produces. There is a 'worked example' at http://bioconductor.org/developers/how-to/c-debugging/#case-study Of course this might lead to nothing, and then you'll be back to your original question about using gctorture or other strategies. Martin Morgan I have already undertaken several attempts to debug the C++ code with gdb(), but until now I have been unable to pinpoint the origin of the problem. There are two elements that I think are puzzling (a) this .Call() has worked fine for about three years, for a variety of data (b) the actual crash occurs at random points during the execution of the function (well, random from a human eye's point of view). From what I understand in the R extensions manual, the actual problem may have been around for a while before the actual call to the C++ code. As recommended in the manual, I am now using gctorture() to try to pinpoint the origins of the problem. I can, alas, only confirm that gctorture() has an enormous impact on execution time, even for operations that are normally executed within the blink of an eye. From what I have seen until now, executing all the R code before the crash with gctorture(TRUE) could take months. I suppose then that the best way to proceed would be to proceed backward from the point where the crash occurs when gctorture(FALSE). I have tried to find some concrete examples of good practices in the use of gctorture() to identify memory problems in R, but most of what I have found on the web is simply a copy of the help page. Does anybody know more concrete and elaborated examples that could give an indication on how to best proceed further? Laurent Franckx, PhD Senior researcher sustainable mobility VITO NV | Boeretang 200 | 2400 Mol Tel. ++ 32 14 33 58 22| mob. +32 479 25 59 07 | Skype: laurent.franckx | laurent.fran...@vito.be | Twitter @LaurentFranckx VITO Disclaimer: http://www.vito.be/e-maildisclaimer __ 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. -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 __ R-help@r-project.org mailing list -- 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] Plots without X11 in CentOS
Hi All, I am wondering how to save plots in R at CentOS when X11 is not available, any suggestion would be appreciated. Warm Regards Sudip [[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] Possible bug in rlm
Have just checked with R 3.2.0 and MASS 7.3-40 and there still appears to be a problem/strangeness at around k=2.5 On 23 April 2015 at 14:09, Francis Bursa francis.bu...@quantics.co.uk wrote: Dear all, I believe I have found a bug in rlm in the MASS package. Specifically, the scale estimate can be wrong when there are no outliers. The following code snippet is an example: dose - c(0,1,2,0,1,2) response - c(0.659,1.633,3.621,1.803,3.093,4.424) line - c(1,1,1,2,2,2) k2 - seq(1.5,5,by=0.01) repNA - rep(NA,length(k2)) scale - repNA niter - repNA for (i in 1:length(k2)){ rlm.fit - rlm(response~dose+factor(line), psi=psi.huber,k=1.345, scale.est=proposal 2,k2=k2[i]) scale[i] - rlm.fit$s niter[i] - length(rlm.fit$conv) } plot(k2,scale,type=b,col=niter) For this dataset there are no outliers, so I would expect the scale to be a smooth function of k2 once k2 is reasonably large, certainly for k2 2. However, there is a funny jump in the scale estimate around k2 = 2.4, just at the point where the number of iterations to convergence falls from 3 to 1. Looking at the source code, it appears that on each iteration, the scale is updated, then the parameters, and then a check for convergence is carried out just for the parameters, not the scale. So I would guess that in the range around k2=2.5 convergence is being reached when in fact the scale estimate hasn't converged. I am using MASS version 7.3-33 and R version 3.1.0 on Windows. I am not sure how common this issue is but there does not seem to be anything special about my dataset so it could be quite generic. Am I right that this is a bug? Many thanks, Francis Bursa -- Francis Bursa Statistician Quantics Consulting Ltd 28 Drumsheugh Gardens Edinburgh EH3 7RN Telephone: +44 (0) 131 440 2781 ext 207 Quantics - complex data into clear results Quantics is an ISO 9001 registered company www.quantics.co.uk Please note that the contents of this e-mail (including any attachments) are confidential and may be legally privileged. If you are not the intended recipient you may not read, copy, distribute or make any other use of this email or its contents. If received in error, please tell us immediately by telephone on +44 (0) 131 440 2781 quoting the name of the sender and the intended recipient, then delete it from your system. Thank you. __ 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. [[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] cbind question, please
Hello Erin, I think you have explain your goal more detailed. Maybe I am completely lost but as far as I understand now you only need the command cbind: m1 - cbind(dog, dat, tree) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 But I can't imagine that is the solution you are looking for. Cheers David On 24.04.2015 00:41, Erin Hodgess wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- David Kienle Department of Biogeography University of Bayreuth GEO II, Rm 003 __ 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
Bonjour, je suis un nouveau dans R. Je fais actuellement mon mémoire de mastère et je voudrais appliquer le Package BCDating. Mail il se trouve que je reçois toujours le message d'erreur suivant: Erreur dans if (mat_tp[r, 1] n) mat_tp - rbind(mat_tp, c(n, 1 - mat_tp[r, : l'argument est de longueur nulle J'ai suivi les étapes suivantes: LGDPTUND.ts= ts(data=LGDPTUND, start=c(2000,1), end=c(2014,3), frequency=4) class(LGDPTUND.ts) dat -BBQ(LGDPTUND,name=Datation du Cycle Eco Tunisien) Erreur dans if (mat_tp[r, 1] n) mat_tp - rbind(mat_tp, c(n, 1 - mat_tp[r, : l'argument est de longueur nulle Pour me présenter, je suis un jeune étudiant sénégalais qui fais actuellement ses études en Tunisie, en Economie Quantitative. Merci Cordialement!!! [[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] run Rscript and ignore errors?
Jeff Newmiller jdnewmil at dcn.davis.ca.us writes: This seems like a recipe for garbage results to me, but there may be I something you can set the error option to. See ?options. --- Jeff NewmillerThe . . Go Live... DCN:jdnewmil at dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On April 23, 2015 9:51:31 AM PDT, Nick Matzke nickmatzke.ncse at gmail.com wrote: Hi R-help, I've looked at google, the Rscript documentation and the Rscript --help output and haven't found much on this. So, here's my question: I have a rather long script that runs on various input datasets. It is quite convenient to run the script from the Terminal command line with Rscript scriptname.R However, some datasets will cause errors. These are non-essential errors -- just some datasets don't have certain columns so certain parts of the overall analysis don't produce figures etc. Yes, I could go through the whole script and insert try() statements, etc. But I'm lazy. So, is there a way to run Rscript or something similar, and just have it ignore all errors (i.e., keep running through the script)? I.e., just like what happens if you just copy-paste the whole script into the R window -- errors happen and are noted but the rest of the script keeps running. Thanks very much for any help!! Cheers! Nick This is a really, really simple life-hack of mine after failed past attemps to solve this issue : Option 1 : Write an if(foreseen error){empty} so if _that_ happens, the code just ignores it. Option 2: Try to run same code for the different initial values in different windows, so if one stops, another one keeps running. I am interested in finding a real solution (like the one proposed above by Mr. Newmiller) , so I am looking forward to some more expert's say. Best regards. Jue [[alternative HTML version deleted]] __ 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. [[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] lm() funtion
Hi, Currently i am working with the lm() function for some regressions required for my project. suppose the formula parameter in that is given by response ~ terms,after some testing i found out that when the number of observations under terms is less than the number of columns or features under terms, the coefficients of regression generated from the linear model object contains NA which makes it useless. right now i am in situation where the number of observation is less than the number of features , can someone help me how to apply regression in this case. -- *Praveen Kr Singh* *Dept-CSE* *HIT-K* [[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] some general advice sought on the use of gctorture()
This is very off-topic here. My suggestion would be to do as the Posting Guide says and ask this on R-devel, or perhaps even a gdb forum. From what little I know, valgrind might help also. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On April 24, 2015 6:49:31 AM PDT, Franckx Laurent laurent.fran...@vito.be wrote: Dear all I have bumped into the dreaded 'segfault' error type when running some C++ code using .Call(). I have already undertaken several attempts to debug the C++ code with gdb(), but until now I have been unable to pinpoint the origin of the problem. There are two elements that I think are puzzling (a) this .Call() has worked fine for about three years, for a variety of data (b) the actual crash occurs at random points during the execution of the function (well, random from a human eye's point of view). From what I understand in the R extensions manual, the actual problem may have been around for a while before the actual call to the C++ code. As recommended in the manual, I am now using gctorture() to try to pinpoint the origins of the problem. I can, alas, only confirm that gctorture() has an enormous impact on execution time, even for operations that are normally executed within the blink of an eye. From what I have seen until now, executing all the R code before the crash with gctorture(TRUE) could take months. I suppose then that the best way to proceed would be to proceed backward from the point where the crash occurs when gctorture(FALSE). I have tried to find some concrete examples of good practices in the use of gctorture() to identify memory problems in R, but most of what I have found on the web is simply a copy of the help page. Does anybody know more concrete and elaborated examples that could give an indication on how to best proceed further? Laurent Franckx, PhD Senior researcher sustainable mobility VITO NV | Boeretang 200 | 2400 Mol Tel. ++ 32 14 33 58 22| mob. +32 479 25 59 07 | Skype: laurent.franckx | laurent.fran...@vito.be | Twitter @LaurentFranckx VITO Disclaimer: http://www.vito.be/e-maildisclaimer __ 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] cbind question, please
You could do something tricky like do.call(cbind, lapply(big.char, as.name)) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 but you are usually better off creating these things as part of a list and passing that to do.call(cbind, list). There is a slight danger of using do.call with cbind. If your list has a component with the unlikely name 'deparse.level', then that will be taken as cbind's deparse.level argument, not as a column of the matrix to be made. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Apr 23, 2015 at 3:41 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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. [[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] some general advice sought on the use of gctorture()
Dear all I have bumped into the dreaded 'segfault' error type when running some C++ code using .Call(). I have already undertaken several attempts to debug the C++ code with gdb(), but until now I have been unable to pinpoint the origin of the problem. There are two elements that I think are puzzling (a) this .Call() has worked fine for about three years, for a variety of data (b) the actual crash occurs at random points during the execution of the function (well, random from a human eye's point of view). From what I understand in the R extensions manual, the actual problem may have been around for a while before the actual call to the C++ code. As recommended in the manual, I am now using gctorture() to try to pinpoint the origins of the problem. I can, alas, only confirm that gctorture() has an enormous impact on execution time, even for operations that are normally executed within the blink of an eye. From what I have seen until now, executing all the R code before the crash with gctorture(TRUE) could take months. I suppose then that the best way to proceed would be to proceed backward from the point where the crash occurs when gctorture(FALSE). I have tried to find some concrete examples of good practices in the use of gctorture() to identify memory problems in R, but most of what I have found on the web is simply a copy of the help page. Does anybody know more concrete and elaborated examples that could give an indication on how to best proceed further? Laurent Franckx, PhD Senior researcher sustainable mobility VITO NV | Boeretang 200 | 2400 Mol Tel. ++ 32 14 33 58 22| mob. +32 479 25 59 07 | Skype: laurent.franckx | laurent.fran...@vito.be | Twitter @LaurentFranckx VITO Disclaimer: http://www.vito.be/e-maildisclaimer __ 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] lm() funtion
You really really really need to work with a local statistical expert, as your post indicates fundamental confusion. Furthermore, statistical issues are off topic here. Cheers, Bert On Friday, April 24, 2015, Praveen kr singh pcubesi...@gmail.com wrote: Hi, Currently i am working with the lm() function for some regressions required for my project. suppose the formula parameter in that is given by response ~ terms,after some testing i found out that when the number of observations under terms is less than the number of columns or features under terms, the coefficients of regression generated from the linear model object contains NA which makes it useless. right now i am in situation where the number of observation is less than the number of features , can someone help me how to apply regression in this case. -- *Praveen Kr Singh* *Dept-CSE* *HIT-K* [[alternative HTML version deleted]] __ R-help@r-project.org javascript:; 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. -- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. Clifford Stoll [[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] help
Bonjour, We need more information. See Reproducibility http://adv-r.had.co.nz/Reproducibility.html for some suggestions on how to ask a question. John Kane Kingston ON Canada -Original Message- From: mamadouns...@gmail.com Sent: Fri, 24 Apr 2015 13:26:32 +0100 To: r-help@r-project.org Subject: [R] help Bonjour, je suis un nouveau dans R. Je fais actuellement mon mémoire de mastère et je voudrais appliquer le Package BCDating. Mail il se trouve que je reçois toujours le message d'erreur suivant: Erreur dans if (mat_tp[r, 1] n) mat_tp - rbind(mat_tp, c(n, 1 - mat_tp[r, : l'argument est de longueur nulle J'ai suivi les étapes suivantes: LGDPTUND.ts= ts(data=LGDPTUND, start=c(2000,1), end=c(2014,3), frequency=4) class(LGDPTUND.ts) dat -BBQ(LGDPTUND,name=Datation du Cycle Eco Tunisien) Erreur dans if (mat_tp[r, 1] n) mat_tp - rbind(mat_tp, c(n, 1 - mat_tp[r, : l'argument est de longueur nulle Pour me présenter, je suis un jeune étudiant sénégalais qui fais actuellement ses études en Tunisie, en Economie Quantitative. Merci Cordialement!!! [[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. FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! __ 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] obtaining the sum of lagged variables
Hi everybody, I am trying to replicate the formula shown in the attachment. I want to estimate tau using a macroeconomic variable X at month t using k lags of the variable X. My code so far looks as follows: psi - fn(...) k - 1:K ltau - m + theta*sum(psi*X[t-k]) Unfortunately, if I run the code as shown the result I get is NA but I want to obtain a list of ltaus at month t. ltau - m + theta*sum(psi*X[t-k]) ltau [1] NA Hence I defined t and ran X[t-k] and get following results. That is, X[t-k] provides every third element in my data table three times instead of calculating the sum of the lagged observations multiplied with psi t-1:15 t [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 X[t-k] [1] -0.25 -0.25 -0.25 0.50 0.50 0.50 -0.44 -0.44 -0.44 0.15 0.15 0.15 How do I get the list of taus at month t based on the sum of lagged observations as shown in the attachment? Thanks in advance __ 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] Extract latitude and longitude from several geottaged jpeg files
Geospatial image maps or just exif tags? Search for r exif for several leads. Cheers, Mike On Sat, Apr 25, 2015, 08:48 Alejo C.S. alej@gmail.com wrote: Hi all, I have several jpeg files with lat long information. I want to make a lat long table whit this info. Anyone knows how to do it? Can't find anything in google. Thanks a lot in advance A. [[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. [[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] Interactive maps
Hello, all: I am new here, and have a challenge to present some graphical data to the user in a convenient way. The challenge is to present a map to the user which is coloured with the value of a variable. Say for example, temperature. This is a preexisting graph that I can generate in any format, including svg. I don't have to produce it using R. When the user clicks anywhere in the map, the coordinates (longitude and latitude) have to be passed to R so that this, R, can look for the values of other variables in that location and make another graph with them. Does anyubody know how could I accomplish this?. Thanks in advance. Antonio Serrano aasde...@aim.com ن [[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] Extract latitude and longitude from several geottaged jpeg files
Hi all, I have several jpeg files with lat long information. I want to make a lat long table whit this info. Anyone knows how to do it? Can't find anything in google. Thanks a lot in advance A. [[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] Extract latitude and longitude from several geottaged jpeg files
That's a pretty vague question, but you might be able to do it with functions from the raster package. Followup on this topic should be to R-sig-geo. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 4/24/15, 3:46 PM, Alejo C.S. alej@gmail.com wrote: Hi all, I have several jpeg files with lat long information. I want to make a lat long table whit this info. Anyone knows how to do it? Can't find anything in google. Thanks a lot in advance A. [[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-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] Plots without X11 in CentOS
Plot directly to the appropriate device, e.g. pdf(file=my.pdf) plot(rnorm(500)) dev.off() This is often recommendable even if you do have an on-screen graphics device because some subtleties can get lost in translation for one device to another. (The prototypical example is that a legend box is sized to hold the text in the font used on the screen device. Then, saving to PDF causes the box to be scaled and the font to change, but it can happen that the text now overruns the box extents.) Peter D. On 24 Apr 2015, at 16:12 , Sudip Chatterjee sudipanal...@gmail.com wrote: Hi All, I am wondering how to save plots in R at CentOS when X11 is not available, any suggestion would be appreciated. Warm Regards Sudip [[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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ 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] help
Hello, Please, read and follow the posting guide and provide a minimal reproducible example as you are encouraged to do. Moreover, write to the list in english. Just a quick test : have you looked at your object 'mat_tp' : str(mat_tp) Bon courage, François Le 24/04/2015 14:26, Mamadou Ndiaye SENE a écrit : Bonjour, je suis un nouveau dans R. Je fais actuellement mon mémoire de mastère et je voudrais appliquer le Package BCDating. Mail il se trouve que je reçois toujours le message d'erreur suivant: Erreur dans if (mat_tp[r, 1] n) mat_tp - rbind(mat_tp, c(n, 1 - mat_tp[r, : l'argument est de longueur nulle J'ai suivi les étapes suivantes: LGDPTUND.ts= ts(data=LGDPTUND, start=c(2000,1), end=c(2014,3), frequency=4) class(LGDPTUND.ts) dat -BBQ(LGDPTUND,name=Datation du Cycle Eco Tunisien) Erreur dans if (mat_tp[r, 1] n) mat_tp - rbind(mat_tp, c(n, 1 - mat_tp[r, : l'argument est de longueur nulle Pour me présenter, je suis un jeune étudiant sénégalais qui fais actuellement ses études en Tunisie, en Economie Quantitative. Merci Cordialement!!! [[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-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] Codificación UTF-8 en un Mc
Hola Jesús, Si la otra persona usa RStudio, basta con reabrir el script con el encoding que tú uses. Menú File/Open with re-enconding. Si vais a compartir más ficheros, lo mejor es que cree un proyecto y establezca para ese proyecto el encoding por defecto que tú uses. Espero te sirva, un saludo, Emilio El vie., 24 abr. 2015 a las 16:27, Jesus Herranz (jesus.herr...@imdea.org) escribió: Hola a todos Estoy desarrollando unos scripts en Windows y cuando se los paso a una persona que tiene un Mac estoy teniendo algunos problemas con caracteres especiales (acentos, º, … ) y algunos de ellos vienen en los ficheros de datos, y no los puedo cambiar. Creo que tiene que ver con la codificación UTF-8, que el Mac no la está sabiendo interpretar ¿alguna idea para cambiar esto en el Mac? Muchas gracias Jesús [[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] Plots without X11 in CentOS
Hi Peter, I did the same but I received an error stating X11 is not available. On Fri, Apr 24, 2015 at 8:11 PM, peter dalgaard pda...@gmail.com wrote: Plot directly to the appropriate device, e.g. pdf(file=my.pdf) plot(rnorm(500)) dev.off() This is often recommendable even if you do have an on-screen graphics device because some subtleties can get lost in translation for one device to another. (The prototypical example is that a legend box is sized to hold the text in the font used on the screen device. Then, saving to PDF causes the box to be scaled and the font to change, but it can happen that the text now overruns the box extents.) Peter D. On 24 Apr 2015, at 16:12 , Sudip Chatterjee sudipanal...@gmail.com wrote: Hi All, I am wondering how to save plots in R at CentOS when X11 is not available, any suggestion would be appreciated. Warm Regards Sudip [[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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com [[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] Why is removeSparseTerms() not doing anything?
Reproducibility http://adv-r.had.co.nz/Reproducibility.html http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example John Kane Kingston ON Canada -Original Message- From: mikeh...@y7mail.com Sent: Wed, 22 Apr 2015 18:52:45 + (UTC) To: r-help@r-project.org Subject: [R] Why is removeSparseTerms() not doing anything? Here's the code and results. The corpus is the text version of a single book. (r vs. 3.2) docs - tm_map(docs, stemDocument) dtm - DocumentTermMatrix(docs) freq - colSums(as.matrix(dtm)) ord - order(freq) freq[tail(ord)] one experi will can lucid dream 287 312 363 452 1018 2413 freq[head(ord)] abbey abdomin abdu abraham absent abus 1 1 1 1 1 1 dim(dtm) [1] 1 5265 dtms - removeSparseTerms(dtm, 0.1) dim(dtms) [1] 1 5265 dtms - removeSparseTerms(dtm, 0.001) dim(dtms) [1] 1 5265 dtms - removeSparseTerms(dtm, 0.9) dim(dtms) [1] 1 5265 [[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. Can't remember your password? Do you need a strong and secure password? Use Password manager! It stores your passwords protects your account. __ 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] Interactive maps
Hi Antonio, If you do create the map in R, you can use locator(). Jim On Sat, Apr 25, 2015 at 8:37 AM, Antonio Serrano via R-help r-help@r-project.org wrote: Hello, all: I am new here, and have a challenge to present some graphical data to the user in a convenient way. The challenge is to present a map to the user which is coloured with the value of a variable. Say for example, temperature. This is a preexisting graph that I can generate in any format, including svg. I don't have to produce it using R. When the user clicks anywhere in the map, the coordinates (longitude and latitude) have to be passed to R so that this, R, can look for the values of other variables in that location and make another graph with them. Does anyubody know how could I accomplish this?. Thanks in advance. Antonio Serrano aasde...@aim.com ن [[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-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] Codificación UTF-8 en un Mc
Pues entonces no sé qué decir, porque no uso Mac y desconozco si el editor de texto que trae permite hacer algo parecido a lo que hace RStudio. Por si acaso es factible para ti, la operación inversa también la puedes hacer desde RStudio (que supongo tú sí lo tienes instalado): File/Save with Encoding. Si lo tienes que hacer rutinariamente seguramente puedas automatizarlo con un script sencillo combinando las funciones readLines, iconv, writeLines. Saludos, E. *Emilio L. Cano* Mobile: +34 665 676 225 skype: emilopezcano twitter: @emilopezcano http://emilio.lcano.com El 24 de abril de 2015, 18:39, jesus.herranz jesus.herr...@imdea.org escribió: Hola, Emilio Muchas gracias por la respuesta. El problema es que la otra persona no sabe nada de R, e instalarle RStudio va a ser casi peor. Además, parece que el origen es que tiene su Mac con configuración USA por un tema de correos y fechas; así que creo que lo que necesitaría es algo que cambie solo la configuración de la sesión de R a UTF-8 o algo parecido. Quizás no es posible Saludos Jesús El 24.04.2015 18:01, Emilio L. Cano escribió: Hola Jesús, Si la otra persona usa RStudio, basta con reabrir el script con el encoding que tú uses. Menú File/Open with re-enconding. Si vais a compartir más ficheros, lo mejor es que cree un proyecto y establezca para ese proyecto el encoding por defecto que tú uses. Espero te sirva, un saludo, Emilio El vie., 24 abr. 2015 a las 16:27, Jesus Herranz (jesus.herr...@imdea.org [3]) escribió: Hola a todos Estoy desarrollando unos scripts en Windows y cuando se los paso a una persona que tiene un Mac estoy teniendo algunos problemas con caracteres especiales (acentos, º, … ) y algunos de ellos vienen en los ficheros de datos, y no los puedo cambiar. Creo que tiene que ver con la codificación UTF-8, que el Mac no la está sabiendo interpretar ¿alguna idea para cambiar esto en el Mac? Muchas gracias Jesús [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org [1] https://stat.ethz.ch/mailman/listinfo/r-help-es [2] Links: -- [1] mailto:R-help-es@r-project.org [2] https://stat.ethz.ch/mailman/listinfo/r-help-es [3] mailto:jesus.herr...@imdea.org [[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] run Rscript and ignore errors?
Hi, Thanks so much for the hints, I think I've cracked it! The key is to create a dummy function, continue_on_error which gets run instead of stop when an error occurs, then reference it with options(error=continue_on_error). Here's an example: == continue_on_error - function() { print(NOTE: THERE WAS AN ERROR HERE. We are continuing because we have set 'options(error=continue_on_error())') } testfunc - function(a,b) { print(a+b) } # This is the key option options(error=continue_on_error) print(1) print(2) # This should work testfunc(a=10, b=10) print(3) # This should produce an error and stop the Rscript run normally testfunc(a=1) print(4) print(5) == Running this via Rscript completes: Rscript continue_on_error.R [1] 1 [1] 2 [1] 20 [1] 3 Error in print(a + b) : argument b is missing, with no default Calls: testfunc - print [1] NOTE: THERE WAS AN ERROR HERE. We are continuing because we have set 'options(error=continue_on_error())' [1] 4 [1] 5 If you comment out the options() line you get: Rscript continue_on_error.R [1] 1 [1] 2 [1] 20 [1] 3 Error in print(a + b) : argument b is missing, with no default Calls: testfunc - print Execution halted ...which was what was annoying me before. So, life hack FTW. (Of course, yes, it would be better to write code good n stuff, but for quick and dirty things this is handy.) Cheers! Nick On Fri, Apr 24, 2015 at 10:06 AM, Jue Lin-Ye jl.i...@gmail.com wrote: Jeff Newmiller jdnewmil at dcn.davis.ca.us writes: This seems like a recipe for garbage results to me, but there may be I something you can set the error option to. See ?options. --- Jeff NewmillerThe . . Go Live... DCN:jdnewmil at dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On April 23, 2015 9:51:31 AM PDT, Nick Matzke nickmatzke.ncse at gmail.com wrote: Hi R-help, I've looked at google, the Rscript documentation and the Rscript --help output and haven't found much on this. So, here's my question: I have a rather long script that runs on various input datasets. It is quite convenient to run the script from the Terminal command line with Rscript scriptname.R However, some datasets will cause errors. These are non-essential errors -- just some datasets don't have certain columns so certain parts of the overall analysis don't produce figures etc. Yes, I could go through the whole script and insert try() statements, etc. But I'm lazy. So, is there a way to run Rscript or something similar, and just have it ignore all errors (i.e., keep running through the script)? I.e., just like what happens if you just copy-paste the whole script into the R window -- errors happen and are noted but the rest of the script keeps running. Thanks very much for any help!! Cheers! Nick This is a really, really simple life-hack of mine after failed past attemps to solve this issue : Option 1 : Write an if(foreseen error){empty} so if _that_ happens, the code just ignores it. Option 2: Try to run same code for the different initial values in different windows, so if one stops, another one keeps running. I am interested in finding a real solution (like the one proposed above by Mr. Newmiller) , so I am looking forward to some more expert's say. Best regards. Jue [[alternative HTML version deleted]] __ 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. [[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] JPEG command not responding to size options
R 3.2.0 OS X Colleagues I have a script that has been unchanged for years but I just noticed a difference in the output. A minimal example is: jpeg(file=xxx.jpeg, width=4, height=2, unit=in, pointsize=12, bg=white, res=150, quality=100) plot(1) graphics.off() system(open xxx.jpeg) ## works in OS X -- use 'start' instead of 'open' in Windows In the past (probably more than several months ago, although I can’t identify when the change occurred), this yielded a graphic that appears to be the intended size (4 x 2). I assess this based on the size on the screen and the size when I drag the file to a Word document. With R 3.2.0 (and 3.1.3), the image is appreciably larger, i.e., the width and height options appear to be ignored. OS X’s Preview application includes an inspector that provided information about the images. In the earlier incarnations, Inspector reported that the image has 150 pixels / inch. With 3.2.0, it shows 72 pixels / inch. I think that the problem is as follows — the image is created with the correct number of pixels — but the info as to pixels / inch is not being handled correctly. I can confirm this by replacing res=150 with res=72 The resulting image is the intended size. Is this a bug? The workaround appears to be restoring res=72 but that does not seem to be an ideal solution. Dennis Dennis Fisher MD P (The P Less Than Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com __ 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] cbind question, please
Perhaps: dog - 1:3 cat - 2:4 tree - 5:7 big.char - cbind(dog,cat,tree) big.char dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 colnames(big.char)-c(dog,cat,tree) big.char dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600 USPS: PO Box 47600, Olympia, WA 98504-7600 Parcels:300 Desmond Drive, Lacey, WA 98503-1274 On Thu, 23 Apr 2015, Erin Hodgess wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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-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] cbind question, please
Hi Erin, Well, if I do this: dog - 1:3 cat - 2:4 tree - 5:7 dct-cbind(dog,cat,tree) I get this: dct dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 If I assume that you want to include the character vector as well: rownames(dct)-big.char dct Jim On Fri, Apr 24, 2015 at 8:41 AM, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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-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] cbind question, please
On Apr 23, 2015, at 5:41 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin Hi Erin, One approach could be: sapply(big.char, get, mode = integer) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 or sapply(big.char, get, mode = numeric) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 Note that I used the ‘mode' argument to get(). You used ‘cat’ as the name of one of the objects and of course, there is an R function cat(). By default for get(), mode = “any”, which would otherwise result in: sapply(big.char, get) $dog [1] 1 2 3 $cat function (..., file = , sep = , fill = FALSE, labels = NULL, append = FALSE) { if (is.character(file)) if (file == ) file - stdout() else if (substring(file, 1L, 1L) == |) { file - pipe(substring(file, 2L), w) on.exit(close(file)) } else { file - file(file, ifelse(append, a, w)) on.exit(close(file)) } .Internal(cat(list(...), file, sep, fill, labels, append)) } bytecode: 0x7fe942d78f78 environment: namespace:base $tree [1] 5 6 7 In the above, the cat() function body is returned, instead of the vector cat. So just need to be cautious. An alternative approach, depending upon where your vectors are stored, might be: sapply(big.char, get, pos = 1) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 which specifies which environment to search for the named objects and the cat() function is not returned since it is in namespace:base. See ?get Regards, Marc Schwartz __ 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] cbind question, please
This works for me... get0 = function(x) get(x,pos=1) sapply(big.char, get0) The extra step seems necessary because without it, get() gets base::cat() instead of cat. cheers, Steve -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Erin Hodgess Sent: Friday, 24 April 2015 10:41a To: R help Subject: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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-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] cbind question, please
These are great! Thank you! On Thu, Apr 23, 2015 at 7:14 PM, William Dunlap wdun...@tibco.com wrote: You could do something tricky like do.call(cbind, lapply(big.char, as.name)) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 but you are usually better off creating these things as part of a list and passing that to do.call(cbind, list). There is a slight danger of using do.call with cbind. If your list has a component with the unlikely name 'deparse.level', then that will be taken as cbind's deparse.level argument, not as a column of the matrix to be made. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Apr 23, 2015 at 3:41 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I experimented with do.call, but all I got was 1 2 3 Any suggestions would be much appreciated. I still think that do.call might be the key, but I'm not sure. R Version 3-1.3, Windows 7. Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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. -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[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.