Re: [R] How Can I Execute a String Expression?

2017-06-12 Thread Jeff Newmiller
R is not a very good macro language... I recommend against this strategy. We could be more concrete in offering alternatives if you were a little more complete in your reproducible example [1][2][3]. What variations exactly were you thinking of? What kind of data are you working with? The way

Re: [R] How Can I Execute a String Expression?

2017-06-12 Thread Bert Gunter
eval(parse(text = yourstring)) # your string must be quoted, because that's what a string is. But don't do this! (usually) install.packages("fortunes") ## if not already downloaded and installed library("fortunes") fortune(106) See ?substitute and ?bquote for perhaps better ways to

Re: [R] How Can I Execute a String Expression?

2017-06-12 Thread Rolf Turner
On 13/06/17 13:55, Donald Macnaughton wrote: I have the string ggstr that I've built with string manipulation: ggstr = "ggplot(df1, aes(x,y)) + geom_smooth(se=FALSE, span=0.01)" Assuming df1 is properly defined, this string will execute properly if I submit it manually without the quotes.

[R] How Can I Execute a String Expression?

2017-06-12 Thread Donald Macnaughton
I have the string ggstr that I've built with string manipulation: ggstr = "ggplot(df1, aes(x,y)) + geom_smooth(se=FALSE, span=0.01)" Assuming df1 is properly defined, this string will execute properly if I submit it manually without the quotes. How can execute the command as a string, so that I

Re: [R] replacement has *** rows, data has ***

2017-06-12 Thread William Dunlap via R-help
This can happen if there are rows containing missing values (NA's) in the data used to fit the model. Use na.action=na.exclude when fitting the model instead of the default na.action=na.omit to make the prediction vector line up with the input data instead of lining up with the input data after

Re: [R] replacement has *** rows, data has ***

2017-06-12 Thread David Winsemius
> On Jun 12, 2017, at 1:32 PM, Manqing Liu wrote: > > Hi all, > > I created a predicted variable based on a model, but somehow not all > observations have a predicted value. When I tired to add the predicated > value to the main data set (data$pr <- pr) , it said: >

[R] replacement has *** rows, data has ***

2017-06-12 Thread Manqing Liu
Hi all, I created a predicted variable based on a model, but somehow not all observations have a predicted value. When I tired to add the predicated value to the main data set (data$pr <- pr) , it said: replacement has 34333 rows, data has 34347. Do you know how to solve that? Thanks, Manqing

Re: [R-es] Agregar a un data.frame de manera automatica

2017-06-12 Thread Carlos Ortega
Hola, Sí, la asignación que haces lo pones en una función. Y luego usas "apply()" aplicándolo sobre "datos" y por cada fila... Seria algo así como: apply(datos, 1, my_funcion) Saludos, Carlos Ortega www.qualityexcellence.es El 12 de junio de 2017, 12:39, Jesús Para Fernández <

Re: [R-es] Paralelizar R en windows

2017-06-12 Thread Carlos Ortega
Hola, Aquí tienes una forma: https://stackoverflow.com/questions/27051856/reading-multiple-files-quickly-in-r Saludos, Carlos Ortega www.qualityexcellence.es El 12 de junio de 2017, 15:38, Jesús Para Fernández < j.para.fernan...@hotmail.com> escribió: > Buenas, > > Quiero paralelizar R en

Re: [R] Paths in knitr

2017-06-12 Thread Yihui Xie
Will there be anything wrong if you do not set these options? Regards, Yihui -- https://yihui.name On Mon, Jun 12, 2017 at 2:24 AM, wrote: > Hi Yihui, > Hi Duncan, > > I corrected my typo. Unfortunately knitr did not find my plots in the > directory where they reside

Re: [R] plotting gamm results in lattice

2017-06-12 Thread Duncan Mackay
Hi Maria If you have problems just start with a small model with predictions and then plot with xyplot the same applies to xyplot Try library(gamm4) spring <- dget(file = "G:/1/example.txt") str(spring) 'data.frame': 11744 obs. of 11 variables: $ WATERBODY_ID : Factor w/ 1994

Re: [R] count number of stop words in R

2017-06-12 Thread Bert Gunter
I am unfamiliar with the tm package, but using basic regex tools, is this what you want: test <- "Mhm . Alright . There's um a young boy that's getting a cookie jar . And it he's uh in bad shape because uh the thing is falling over . And in the picture the mother is washing dishes and doesn't see

Re: [R] count number of stop words in R

2017-06-12 Thread Florian Schwendinger
If you just want to count the stopwords you cloud do something like, library(slam) library(tm) your_string <- "Mhm . Alright . There's um a young boy that's getting a cookie jar . And it he's uh in bad shape because uh the thing is falling over . And in the picture the mother is washing dishes

Re: [R] count number of stop words in R

2017-06-12 Thread Patrick Casimir
Or use the qdap package to perform any quantitative analysis of your string. https://cran.r-project.org/web/packages/qdap/qdap.pdf Package �qdap� - The Comprehensive R Archive Network cran.r-project.org Package �qdap� August 29, 2016 Type

Re: [R] count number of stop words in R

2017-06-12 Thread Patrick Casimir
you can use summary (my string) Patrick Casimir, PhD Health Analytics, Data Science, Big Data Expert & Independent Consultant C: 954.614.1178 From: Elahe chalabi Sent: Monday, June 12, 2017 11:42:43 AM To: Patrick Casimir; Bert Gunter

Re: [R] count number of stop words in R

2017-06-12 Thread Elahe chalabi via R-help
Defining data as you mentioned in your respond causes the following error: Error in UseMethod("tm_map", x) : no applicable method for 'tm_map' applied to an object of class "character" I can solve this error by using Corpus(VectorSource(my string)) and the using your command but I cannot

Re: [R] count number of stop words in R

2017-06-12 Thread Patrick Casimir
define your string as whatever object you want: data <- "Mhm . Alright . There's um a young boy that's getting a cookie jar . And it he's uh in bad shape because uh the thing is falling over . And in the picture the mother is washing dishes and doesn't see it . And so is the the water is

Re: [R] count number of stop words in R

2017-06-12 Thread Elahe chalabi via R-help
Thanks for your reply. I know the command data <- tm_map(data, removeWords, stopwords("english")) removes English stop words, I don't know how should I count stop words of my string: str="Mhm . Alright . There's um a young boy that's getting a cookie jar . And it he's uh in bad shape because

Re: [R] count number of stop words in R

2017-06-12 Thread Patrick Casimir
You can define stop words as below. data <- tm_map(data, removeWords, stopwords("english")) Patrick Casimir, PhD Health Analytics, Data Science, Big Data Expert & Independent Consultant C: 954.614.1178 From: R-help on behalf of

Re: [R] count number of stop words in R

2017-06-12 Thread Bert Gunter
You can use regular expressions. ?regex and/or the stringr package are good places to start. Of course, you have to define "stop words." Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley

Re: [R] Keep only those values in a row in a data frame which occur only once.

2017-06-12 Thread S Ellison
> I have a file data.txt as follows: > > Name_1,A,B,C > Name_2,E,F > Name_3,I,J,I,K,L,M > > My query is how can I keep only the unique elements in each row? For > example: I want the row 3 to be Name_3,I,J,K,L,M > > Please note I don't want the 2nd I to appear. > > How can I do this? Use

Re: [R-es] QUitar bucles for

2017-06-12 Thread Javier Marcuzzi
Estimado Jesús Para Fernández Si y No. En R antiguo, for no estaba vectorizado, o dicho de otra forma, R no esta vectorizado, para tener un rendimiento mayor hay formas de escribir donde aumenta el rendimiento, por otro lado aparecen funciones que colaboran para ordenar o trabajar con datos,

Re: [R] Problem related to rowSums

2017-06-12 Thread PIKAL Petr
Hi Not sure of your intention, do you want count how many rows have zeroes in all columns? In that case something like sum(rowSums(dat == 0) == ncol(dat)) should do the trick. If it is not an answer for your problem, post some toy data and desired result. Regards Petr > -Original

Re: [R-es] Bucle for que se salte los errores

2017-06-12 Thread Javier Marcuzzi
Estimado Jesús Para Fernández Pero no es lo mismo, usted pidió para cuándo i vale 0, el tryCatch es para todos los casos en donde no se puede porque hay un error, justo coloco en el buscador la definición para compartirla y encuentro un ejemplo muy apropiado. # tryCatch.Rscript -- experiments

Re: [R-es] Bucle for que se salte los errores

2017-06-12 Thread Jesús Para Fernández
He encontrado la respuesta. EL ejemplo que puse era trivial, ya que es obvio que if(i ==0) entonces next, pero me referia a sin saber si va a ser error el modelo o no. Para esto he encontrado la solución for(i in -3:3){ tryCatch({ z<-1/i > z<-z*z > modelo<-lm(z~1) },

Re: [R-es] Bucle for que se salte los errores

2017-06-12 Thread Javier Marcuzzi
Case también podría ir, en realidad cualquier función de condicional, hay algo de gusto personal también (yo prefiero if). Javier Rubén Marcuzzi De: Xavi tibau alberdi Enviado: lunes, 12 de junio de 2017 9:46 Para: guillermo.vi...@uv.es CC: Lista R Asunto: Re: [R-es] Bucle for que se salte los

Re: [R-es] Bucle for que se salte los errores

2017-06-12 Thread Xavi tibau alberdi
Otra opcio es no incluir en 0 For (i in c(-2,-1,1,2) El 12 jun. 2017 14:43, escribió: Hola, Creo que sería añadir if(i == 0) next Saludos, Guillermo > Buenas, �como puedo hacer que el bucle for se salte el error que salta cuando i<-0 en el codigo que paso?? > > > >

Re: [R-es] Bucle for que se salte los errores

2017-06-12 Thread Javier Marcuzzi
Estimado Jesús Para Fernández Usando un if dentro de for Algo como If i<- 0 no hacer , else hacer Javier Rubén Marcuzzi De: Jesús Para Fernández Enviado: lunes, 12 de junio de 2017 9:29 Para: r-help-es@r-project.org Asunto: [R-es] Bucle for que se salte los errores Buenas, �como puedo hacer

[R] count number of stop words in R

2017-06-12 Thread Elahe chalabi via R-help
Hi all, Is there a way in R to count the number of stop words (English) of a string using tm package? str="Mhm . Alright . There's um a young boy that's getting a cookie jar . And it he's uh in bad shape because uh the thing is falling over . And in the picture the mother is washing dishes

Re: [R-es] OPINIONES comparacion personal de R en linux y windows

2017-06-12 Thread Javier Marcuzzi
Buenos días a todos Estimado Eric R tiene dos partes, por un lado el que realiza cálculos y por el otro la forma de poder enviar lo que se debe hacer, esto es a partir de un archivo, escribiendo en una terminal, usando rstudio, rkward, entre otros, yo no recuerdo cuál fue la versión de R que

Re: [R-es] Bucle for que se salte los errores

2017-06-12 Thread Guillermo.Vinue
Hola, Creo que sería añadir if(i == 0) next Saludos, Guillermo > Buenas, �como puedo hacer que el bucle for se salte el error que salta cuando > i<-0 en el codigo que paso?? > > > > count <- 0 > for(i in -2:2){ > z<-1/i > z<-z*z > modelo<-lm(z~1) > } > > > Gracias > > > >

Re: [R-es] OPINIONES comparacion personal de R en linux y windows

2017-06-12 Thread eric
Hola Javier, he usado R principalmente en Linux, y principalmente en debian, aunque he tenido que usarlo tambien sobre windows y sobre otras distribuciones de Linux. La usabilidad a traves de todos ellos es basicamente la misma para mi, pues uso rkward que se

Re: [R-es] Agregar a un data.frame de manera automatica

2017-06-12 Thread Jesús Para Fernández
Me autocontesto, hacinedolo de la siguiente manera: for(i in 1:240) { df[paste("inicio.refri", i, sep = ".")]<-datos[which.max(datos[,109+i]),"LogDateTime"] } No hace falta usar el assing ni similares. Para nota, ¿se podria hacer con un lapply o similares?? y evitar usar el for?

Re: [R] Memory leak in nleqslv()

2017-06-12 Thread Ismail SEZEN
> On 12 Jun 2017, at 00:16, Andrew Leach wrote: > > Hello all, > > I am relatively new to R, but enjoying it very much. I am hoping that > someone on this list can help me with an issue I am having. > > I am having issues with iterations over nleqslv, in that the solver >

Re: [R] plspm package error in data frame

2017-06-12 Thread Rui Barradas
Hello, Please allways cc the list, don't answer just to me. Now I'm getting a different error. I had noticed that you have no reference to 'TPBDATA' before the call to plspm but I forgot to mention it in my first e-mail. TPB_pls1 = plspm(TPBDATA, TPB_path, TPB_blocks, modes = TPB_modes)

Re: [R] issues in plm using random effect model

2017-06-12 Thread Nina Schönfelder
Dear Kailas Gokhale, The negative individual variance is not a problem with your code or plm. It a property of your data. Please check the posts of Giovanni Millo on this topic: [R] R: plm random effect: the estimated variance of the individual effect is negative Millo Giovanni

Re: [R] Beginner’s Question

2017-06-12 Thread Barry Rowlingson
On Mon, Jun 12, 2017 at 2:39 AM, Neil Salkind wrote: > Please excuse the naive question but my first hour with RStudio, resulted in > this… > >> data() >> data(“women”) > Error: unexpected input in "data(�” > > So,that did not work but > >>data(women) > > without the

Re: [R] Paths in knitr

2017-06-12 Thread G . Maubach
Hi Yihui, Hi Duncan, I corrected my typo. Unfortunately knitr did not find my plots in the directory where they reside which is different from the Rmd document. The documentation of knitr says: base.dir: (NULL) an absolute directory under which the plots are generate root.dir: (NULL) the root

Re: [R] Keep only those values in a row in a data frame which occur only once.

2017-06-12 Thread Jim Lemon
Hi Ashim, One way is this, assuming that your data frame is named akdf: akdf<-t(apply(akdf,1,function(x) return(unique(x)[1:length(x)]))) If you want factors instead of strings, more processing will be required. Jim On Mon, Jun 12, 2017 at 3:23 PM, Ashim Kapoor wrote: >

Re: [R] Beginner’s Question

2017-06-12 Thread Jim Lemon
Hi Meil, Looks like the old fancy quote problem. You aren't cutting and pasting text from Word are you? Jim On Mon, Jun 12, 2017 at 11:39 AM, Neil Salkind wrote: > Please excuse the naive question but my first hour with RStudio, resulted in > this… > >> data() >>

[R] Beginner’s Question

2017-06-12 Thread Neil Salkind
Please excuse the naive question but my first hour with RStudio, resulted in this… > data() > data(“women”) Error: unexpected input in "data(�” So,that did not work but >data(women) without the quotes did. Would someone be so kind as to explain the function of quotes in RStudio? Thanks,

Re: [R-es] package ‘rgdal’ is not available (for R version 3.2.3)

2017-06-12 Thread miguel.angel.rodriguez.muinos
Hola Javier Valdes Efectivamente, tiene razón Carlos; rgdal necesita como mínimo la versión 3.3.0 de R https://cran.r-project.org/web/packages/rgdal/index.html Un Saludo. El 12/06/2017 a las 8:30, Carlos J. Gil Bellosta escribió: > Prueba con una versión no antigua de R. > > El lun., 12 jun.

Re: [R-es] package ‘rgdal’ is not available (for R version 3.2.3)

2017-06-12 Thread Carlos J. Gil Bellosta
Prueba con una versión no antigua de R. El lun., 12 jun. 2017 4:36, javier valdes escribió: > Estimados: > Es posible solucionar este tema?? He probado con varias alternativas > disponibles en internet, pero ninguna me ha funcionado aun. > Saludos. >