Re: [R] replace character by numeric value

2023-09-29 Thread Ebert,Timothy Aaron
'SELL', -1, NA))) is an option that would take care of other options. -Original Message- From: R-help On Behalf Of Ben Bolker Sent: Friday, September 29, 2023 10:00 AM To: r-help@r-project.org Subject: Re: [R] replace character by numeric value [External Email] The reason you're

Re: [R] replace character by numeric value

2023-09-29 Thread Ben Bolker
p On Behalf Of Enrico Schumann Sent: Thursday, September 28, 2023 3:13 AM To: arnaud gaboury Cc: r-help Subject: Re: [R] replace character by numeric value [External Email] On Wed, 27 Sep 2023, arnaud gaboury writes: I have two data.frames: mydf1 <- structure(list(symbol = "ETHUSDT&q

Re: [R] replace character by numeric value

2023-09-29 Thread Ebert,Timothy Aaron
Does this work? mynewdf$side <- as.numeric(mynewdf$side) This code would be the next line after your mutate. TIm -Original Message- From: R-help On Behalf Of Enrico Schumann Sent: Thursday, September 28, 2023 3:13 AM To: arnaud gaboury Cc: r-help Subject: Re: [R] replace charac

Re: [R] replace character by numeric value

2023-09-28 Thread arnaud gaboury
On Thu, Sep 28, 2023 at 8:18 AM Ivan Calandra wrote: > > Dear Arnaud, > > I don't quite unterstand why you have imbricated ifelse() statements. Do > you have more that BUY (1) and SELL (-1)? If not, why not simply: > mynewdf2 <- mydf2 |> dplyr::mutate(side = ifelse(side == 'BUY', 1, -1)) Yes it

Re: [R] replace character by numeric value

2023-09-28 Thread Enrico Schumann
On Wed, 27 Sep 2023, arnaud gaboury writes: > I have two data.frames: > > mydf1 <- structure(list(symbol = "ETHUSDT", cummulative_quote_qty = > 1999.9122, side = "BUY", time = structure(1695656875.805, tzone = "", class > = c("POSIXct", "POSIXt"))), row.names = c(NA, -1L), class = c("data.table",

Re: [R] replace character by numeric value

2023-09-28 Thread Ivan Calandra
Dear Arnaud, I don't quite unterstand why you have imbricated ifelse() statements. Do you have more that BUY (1) and SELL (-1)? If not, why not simply: mynewdf2 <- mydf2 |> dplyr::mutate(side = ifelse(side == 'BUY', 1, -1)) That would solve the problem. I'm not quite sure exactly what

[R] replace character by numeric value

2023-09-28 Thread arnaud gaboury
I have two data.frames: mydf1 <- structure(list(symbol = "ETHUSDT", cummulative_quote_qty = 1999.9122, side = "BUY", time = structure(1695656875.805, tzone = "", class = c("POSIXct", "POSIXt"))), row.names = c(NA, -1L), class = c("data.table", "data.frame")) mydf2 <- structure(list(symbol =