Re: [R] the opposite of pluck() in purrr

2021-11-18 Thread Avi Gross via R-help
As noted, this is not the place to ask about dplyr but the answer you may want is perhaps straight R. If you have a list called weekdays and you know you o not want to take the fifth, then indexing with -5 removes it: > weekdays <- list("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat") >

Re: [R] the opposite of pluck() in purrr

2021-11-18 Thread Rolf Turner
On Thu, 18 Nov 2021 16:40:14 -0500 "Christopher W. Ryan via R-help" wrote: > I've just learned about pluck() and chuck() in the purrr package. Very > cool! As I understand it, they both will return one element of a > list, either by name or by [[]] index, or even "first" or "last" > > I was

Re: [R-es] reemplazar valores de una variable por otras

2021-11-18 Thread Javier Marcuzzi
Estimado Juan Manuel Dias Yo lo realizo con vectores, en realidad hay muchas formas, si usted piensa en if, está en lo correcto. Hay un problema, mire el siguiente ejemplo, puede ser que comparte el error que usted tiene y aprende sobre su propio código antes de cambiarlo por otra solución.

Re: [R] the opposite of pluck() in purrr

2021-11-18 Thread Bert Gunter
tidyverse is an RStudio ecosystem of packages -- it is not part of R's "standard" package distro, so as the posting guide linked below says: "For questions about functions in standard packages distributed with R (see the FAQ Add-on packages in R

[R] the opposite of pluck() in purrr

2021-11-18 Thread Christopher W. Ryan via R-help
I've just learned about pluck() and chuck() in the purrr package. Very cool! As I understand it, they both will return one element of a list, either by name or by [[]] index, or even "first" or "last" I was hoping to find a way to return all *but* one specified element of a list. Speaking

Re: [R] Merge column with characters

2021-11-18 Thread Jim Lemon
Hi RosalinaZakaria, Talk about using a sledgehammer to crack a nut. In your example the two objects are character vectors. How about: dt_comb1gd <-paste0(dtpaigd,dtpmgd) Jim On Fri, Nov 19, 2021 at 2:15 AM ROSLINAZAIRIMAH BINTI ZAKARIA . wrote: > > Dear all, > > I try to merge two columns

Re: [R-es] reemplazar valores de una variable por otras

2021-11-18 Thread Diego Hernangómez Herrero
Buenas: Prueba la función dplyr::coalesce https://dplyr.tidyverse.org/reference/coalesce.html, está diseñada para trabajar con NAs. Creo que es lo que necesitas El El jue, 18 nov 2021 a las 19:36, juan manuel dias escribió: > Hola, como andan! > Necesito crear una variable nueva

Re: [R] Merge column with characters

2021-11-18 Thread Rui Barradas
Hello, Use an index giving the "" positions. i <- nchar(dtpmgd) == 0L dtpmgd[i] <- dtpaigd[i] Or, in one line, dtpmgd[nchar(dtpmgd) == 0L] <- dtpaigd[nchar(dtpmgd) == 0L] Hope this helps, Rui Barradas Às 07:02 de 18/11/21, ROSLINAZAIRIMAH BINTI ZAKARIA . escreveu: Dear all, I try

[R-es] reemplazar valores de una variable por otras

2021-11-18 Thread juan manuel dias
Hola, como andan! Necesito crear una variable nueva "*Dirección_Final*" que sea igual a la variable "*Dirección*", pero que si "*Dirección" *es NA traiga "*Dirección General*", si "*Dirección General*" es NA traiga "*Subsecretaria*", y si " *Subsecretaria*" es NA traiga "*Secretaria*". Estoy

Re: [R] Help with strange RGui behavior? Will not consistently run source.

2021-11-18 Thread Stephen Hartley
I haven't been able to get remote desktop working, I suspect it's disabled for security reasons. Any other thoughts/suggestions? On Thu, Nov 18, 2021 at 2:22 AM Mark Fowler wrote: > Hi, > > > > This issue bears some similarity to a problem I’ve been experiencing over > the last few days. R

Re: [R] Help with strange RGui behavior? Will not consistently run source.

2021-11-18 Thread Eric Berger
HI Stephen, The reason I suggested the test was that I had a real flakey and annoying GUI problem a couple of years ago. It had to do with selection by mouse etc. The IT group could not reproduce the problem (when they connected remotely) and I realized that when I worked from home I also avoided

Re: [R] Help with strange RGui behavior? Will not consistently run source.

2021-11-18 Thread Stephen Hartley
I have not tried that. I'm not certain if I have the permissions for remote desktop, but I will find out and give it a shot if possible. On Wed, Nov 17, 2021, 12:04 PM Eric Berger wrote: > Hi Stephen, > Does the problem still occur if you connect remotely to your computer from > a different

Re: [R] Merge column with characters

2021-11-18 Thread Micha Silver
On 18/11/2021 09:02, ROSLINAZAIRIMAH BINTI ZAKARIA . wrote: Dear all, I try to merge two columns consisting of characters using the 'coalesce' function from dplyr package. However, two data still have not merged, data no. 124 1nd 143. Any help is very much appreciated. I provide the data as

Re: [R] How to create a proper S4 class?

2021-11-18 Thread Martin Morgan
From my example, as(employees, "People") more general coercion is possible; see the documentation ?setAs. From your problem description I would have opted for the solution that you now have, with two slots rather than inheritance. Inheritance has a kind of weird contract when using another

[R] Merge column with characters

2021-11-18 Thread ROSLINAZAIRIMAH BINTI ZAKARIA .
Dear all, I try to merge two columns consisting of characters using the 'coalesce' function from dplyr package. However, two data still have not merged, data no. 124 1nd 143. Any help is very much appreciated. I provide the data as follows. > dput(dtpaigd) c("C+", "B+", "C+", "B+", "C+", "A-",

Re: [R-es] Pasar nombre variable regresión

2021-11-18 Thread Griera-yandex
Hola: Gracias por la respuesta. Nunca he utilizado variables globales por miedo de meter la pata. Sí, tienes razón. Lo mejor es pasar al nuevo espacio el dataframe. Se simplifica mucho. Gracias y saludos. On Thu, 18 Nov 2021 13:58:53 +0100 Proyecto R-UCA wrote: > Buenas, > > No he

Re: [R-es] Pasar nombre variable regresión

2021-11-18 Thread Proyecto R-UCA
Buenas, No he profundizado en el motivo pero como dices falla si las variables no están en el data.frame. Tienes que agregarlas primero al data.frame. Si el espacio del que hablas es el padre, o algún ascendiente, no habría problemas, pues R cuando no existe una variable en un entorno mira en

Re: [R-es] Pasar nombre variable regresión

2021-11-18 Thread Griera-yandex
Gracias por la respuesta! El código tuyo funciona sin problema, pero cuando lo "adapto" me da error: > ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) + trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) + group <- gl(2, 10, 20, labels = c("Ctl","Trt")) + weight <- c(ctl,

Re: [R-es] Pasar nombre variable regresión

2021-11-18 Thread Proyecto R-UCA
Buenas, a ver si esto te sirve: ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) dd <- data.frame(weight = weight, group = group, ctl = ctl, trt=trt) model

Re: [R-es] Pasar nombre variable regresión

2021-11-18 Thread Griera-yandex
Sí! Gracias por responder! Funciona sin problema: > X = "group" + X [1] "group" + lm.D9 <- lm(weight ~ get (X), data = df) + summary (lm.D9) Call: lm(formula = weight ~ get(X), data = df) Residuals: Min 1Q Median 3Q Max -1,0710 -0,4937 0,0685 0,2462 1,3690

Re: [R-es] Pasar nombre variable regresión

2021-11-18 Thread Marcelino de la Cruz Rot
Hola: Creo que lo que quieres es esto: lm.D9 <- lm(weight ~ get(X)) Saludos, Marcelino El 18/11/2021 a las 12:03, Griera escribió: Hola, buenos días: No es un problema concreto que tenga ahora, pero es un problema general que no se si tiene solución fácil. Hago una regresión (de lm.html):

Re: [R-es] Pasar nombre variable regresión

2021-11-18 Thread Griera-yandex
Hola: Gracias por la respuesta. Disculpa, el ejemplo está mal planteado. En realidad seria: ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) df <-

Re: [R] vectorization of loops in R

2021-11-18 Thread PIKAL Petr
Hi above tapply and aggregate, split *apply could be used) sapply(with(df, split(z, y)), mean) Cheers Petr > -Original Message- > From: R-help On Behalf Of Luigi Marongiu > Sent: Wednesday, November 17, 2021 2:21 PM > To: r-help > Subject: [R] vectorization of loops in R > > Hello,

[R-es] Pasar nombre variable regresión

2021-11-18 Thread Griera
Hola, buenos días: No es un problema concreto que tenga ahora, pero es un problema general que no se si tiene solución fácil. Hago una regresión (de lm.html): ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2,