0
Item  Price  Discounted_price
A     5.70        4.00
B     4.50        NA
C     5.67        3.50
D     3.23        2.75
E     1.24        NA
F     4.25        NA

I have this dataset where i would like to show the price of each item but the catch is that if discounted_price is not NA, the discounted_price will be taken instead. May i know how can i start in R?

Item Price 
A     4.00
B     4.50 
C     3.50 
D     2.75 
E     1.24 
F     4.25
Empowered
  • 7
  • 3

1 Answers1

0

data['Price'] = np.where(data["Discounted_price"] < data["Price"], data["Discounted_price"], data["Price"])

data is the dataframe in which your data is stored. This is for python.

crazyman
  • 1
  • 1