ifelse(side ==
'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]
--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 character by numeric value
[External Email]
On Wed, 27 Sep 2023, arnaud gaboury writes:
I have two data.frames:
mydf1 <- stru
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 character
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 w
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",
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 happens,
6 matches
Mail list logo