Re: [R] Split

2020-09-23 Thread Val
Thank you again for your help and giving me the opportunity to choose the efficient method. For a small data set there is no discernable difference between the different approaches. I will carry out a comparison using the large data set. On Wed, Sep 23, 2020 at 11:52 AM LMH wrote: > > Below

Re: [R] help with nesting if else statements

2020-09-23 Thread Ana Marija
Hi Jeremie, when I try to reproduce your code this is what I get: > a=setDT(a) > head(a) FID IID CURRELIG PLASER RTNPTHY 1: fam0110 G1102 2 2 2: fam0113 G1132 2 2 3: fam0114 G1142 2 2 4: fam0117 G1172 2 2 5:

Re: [R] jitter-bug? problematic behaviour of the jitter function

2020-09-23 Thread Rui Barradas
Hello, Thanks for the further explanation. I believe that yes, it would be a good idea to document a bit better that "apart from fuzz" is a rounding operation, it is said en passant, and its meaning is not clear. Rui Barradas Às 21:25 de 23/09/20, Duncan Murdoch escreveu: On 23/09/2020

Re: [R] jitter-bug? problematic behaviour of the jitter function

2020-09-23 Thread Duncan Murdoch
On 23/09/2020 4:03 p.m., Rui Barradas wrote: Hello, I believe that though Duncan's explanation is right it is also not explaining the value of the digits argument. round makes the first 2 numbers 0 but why? If there had been rounding in their computation, you might see a difference like

Re: [R] jitter-bug? problematic behaviour of the jitter function

2020-09-23 Thread Rui Barradas
Hello, I believe that though Duncan's explanation is right it is also not explaining the value of the digits argument. round makes the first 2 numbers 0 but why? The function below prints the digits argument and then outputs d. The code is taken from jitter. f <- function(x){ z <- diff(r

Re: [R] help with nesting if else statements

2020-09-23 Thread Jeremie Juste
Hello Ana Marija, I cannot reproduce your error, with a$PHENO=ifelse(a$PLASER==2 |a$RTNPTHY==2, 2, ifelse(a$CURRELIG==1 | a$RTNPTHY==1,1,NA)) For instance I have the expected PHENO=2 > FID IID CURRELIG PLASER RTNPTHY PHENO > 39: fam5706 G57061 1 2 2 In

Re: [R] jitter-bug? problematic behaviour of the jitter function

2020-09-23 Thread Rui Barradas
Hello, R 4.0.2 on Ubuntu 20.04, sessionInfo at end. This came up in r-help, I'm answering to the OP and also posting to r-devel since I believe it is more appropriate there. I can confirm this. The original instructions are the first and the last, but even with smaller numbers the error

Re: [R] help with nesting if else statements

2020-09-23 Thread Bert Gunter
Nested ifelse()'s are confusing and invite error. Just use ?within and subscript with your conditions: dat$PHENO <- NA ## initialize PHENO > dat <- ## to return the modified result within(dat, { + PHENO[CURRELIG ==1] <- 1 + PHENO[CURRELIG == 1 & PLASER == 2] <- 2 + PHENO[CURRELIG

Re: [R] help with nesting if else statements

2020-09-23 Thread Ana Marija
I tried doing this: a$PHENO=ifelse(a$PLASER==2 | a$RTNPTHY==2,2,ifelse(a$CURRELIG==1 | a$RTNPTHY==1,1,NA)) which brought be closer to the solution, but now I have lines like this: FID IID CURRELIG PLASER RTNPTHY PHENO fam3151 G31511 1 NANA fam3149 G31492

Re: [R] Split

2020-09-23 Thread LMH
Below is a script in bash the uses the awk tokenizer to do the work. This assumes that your input and output delimiter is space. The number of consecutive delimiters in the input is not important. This also assumes that the input file does not have a header row. That is easy to modify if you

[R] help with nesting if else statements

2020-09-23 Thread Ana Marija
Hello, I have a data frame as shown bellow. I want to create a new column PHENO which will be defined as follows: if CURRELIG==1 -> PHENO==1 in the above subset those that have: PLASER==2 -> PHENO==2 and those where RTNPTHY==1 -> PHENO==1 I tried doing this: a$PHENO=ifelse(a$CURRELIG==1 |

Re: [R] Split

2020-09-23 Thread LMH
What is the delimiter is in the input data? Is it tab, space, etc? Is this going to be the same for the output data that you will use for R input? LMH Val wrote: > Thank you all for the help! > > LMH, Yes I would like to see the alternative. I am using this for a > large data set and if the

Re: [R] jitter-bug? problematic behaviour of the jitter function

2020-09-23 Thread Duncan Murdoch
On 23/09/2020 6:32 a.m., Martin Keller-Ressel wrote: Dear all, i have noticed some strange behaviour in the „jitter“ function in R. On the help page for jitter it is stated that "The result, say r, is r <- x + runif(n, -a, a) where n <- length(x) and a is the amount argument (if specified).“

[R] Issues with lapply and for loop Compared to Running Function

2020-09-23 Thread Kevin Egan
Hello, I’d like to apologise as I understand that this is a significant amount of code, but I am struggling to understand why my code develops an error when running. I have been able to obtain results for the list of matrices named xdot and ydot but am struggling with zdot as I keep getting

[R] jitter-bug? problematic behaviour of the jitter function

2020-09-23 Thread Martin Keller-Ressel
Dear all, i have noticed some strange behaviour in the „jitter“ function in R. On the help page for jitter it is stated that "The result, say r, is r <- x + runif(n, -a, a) where n <- length(x) and a is the amount argument (if specified).“ and "If amount is NULL (default), we set a <- factor

[R] package plotrix: how to account for two two z categories

2020-09-23 Thread Luigi Marongiu
Hello, I have an experiment measuring optical density (OD) when comparing three parameters: a) concentration of the target b) concentration of the probe c) concentration of the reporter antibody. Using plotrix I can nicely draw the first two into clusters, but I can't get separation for the third

Re: [R-es] Encontrar un dato y añadirlo a otra columna

2020-09-23 Thread Samura .
perfecto, pero en realidad habia simplificado el ejemplo ya que no siempre se encuentra en la misma posicion (y a veces es AV en mayuscula, otra en minuscula, otra entre parentesis etc..) pero con sacarlo siguiendo este formato me vale, luego lo adapto a cada circunstancia nombre1 AV 23 PEPE

Re: [R] open file on R GUI results in spinning wheel and frozen R - Mac OS

2020-09-23 Thread Peter Dalgaard
...or try R-patched, which I'm told has the newer GUI. -pd > On 21 Sep 2020, at 21:43 , Berend Hasselman wrote: > > > >> On 21 Sep 2020, at 20:24, Gonçalo Ferraz wrote: >> >> Hello, >> >> I’ve been using R-studio for a while and today I needed to try something >> directly on the R-GUI.

Re: [R] Split

2020-09-23 Thread Rui Barradas
Hello, If speed is important, and following the previous discussion and Bert's tests, here are two other alternatives, both faster. 1. Bert2 is Bert's original but with scan(., sep = "_") substituted for unlist/strsplit. 2. A package data.table solution. These are always fast, many times the

Re: [R-es] Insertar punto en numero

2020-09-23 Thread Emilio L. Cano
¿Posición 4? Sería la 6, ¿no? x <- "43.0522"; paste0(substring(x, 1, 5), ".", substring(x, 6)) > El 23 sept 2020, a las 10:27, jose luis via R-help-es > escribió: > > Buenos días. ¿como puedo insertar un punto en la posicion 4, de forma que me > quede en vez de43.0522 > 43.05.22SaludosJose

[R-es] Insertar punto en numero

2020-09-23 Thread jose luis via R-help-es
Buenos días. ¿como puedo insertar un punto en la posicion 4, de forma que me quede en vez de43.0522  43.05.22SaludosJose Luis [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org

Re: [R-es] ORDEN GRÁFICO POR MESES

2020-09-23 Thread Victoria Lopez
Lo que dice Marcelino es buena solución, es lo que yo hago. El mié., 23 sept. 2020 8:59, Marcelino de la Cruz Rot < marcelino.delac...@urjc.es> escribió: > Hola: > Si el orden de los niveles de tu factor no es el que quieres, puedes > especificar tu orden preferido al crear el factor (o

Re: [R-es] EXTRAER MES EN LETRAS Y CASTELLANO

2020-09-23 Thread Marcelino de la Cruz Rot
Hola: Otra forma, más sencilla todavía. Saludos, Marcelino mes_numero = sample(1:12, 50, replace = TRUE) mes_chr = c('ENE', 'FEB', 'MAR', 'ABR', 'MAY', 'JUN', 'JUL', 'AGO', 'SEP','OCT','NOV', 'DIC') nueva_variable <- mes_chr[mes_numero] El 23/09/2020 a las 1:11, Carlos Ortega escribió:

Re: [R-es] Encontrar un dato y añadirlo a otra columna

2020-09-23 Thread Marcelino de la Cruz Rot
Hola: Para este ejemplo concreto, es bastante sencillo. Por ejemplo: sp <-strsplit(df$nombre1, " ") df$Nombre1_numero<-sapply(sp, function(x) ifelse(x[1]=="AV", as.numeric(x[2]), NA)) Saludos, Marcelino El 23/09/2020 a las 2:14, Samura . escribió: Con parse_number sacaria todos los numeros

Re: [R-es] ORDEN GRÁFICO POR MESES

2020-09-23 Thread jose luis via R-help-es
Holaimagino que tienes la variable mes como número o como factor. Para que lo ordene cronologicamente debe estar en formato fecha, por ejemplo así: Diario_S2$mes<-as.Date( Diario_S2, format = "%d/%m/%Y" ) En miércoles, 23 de septiembre de 2020 02:53:42 CEST, Jesus MARTIN F. escribió:

Re: [R] Quadratic programming

2020-09-23 Thread Abby Spurdle
> I'm trying to replicate a C++ code with R. Notes: (1) I'd recommend you make the code more modular. i.e. One function for initial data prep/modelling, one function for setting up and solving the QP, etc. This should be easier to debug. (However, you would probably have to do it to the C++ code