My data is organized as follows:
year company color car_total
2000 toyota red 873
2013 honda red 737
2012 nissan green 809
2002 toyota blue 429
2000 nissan green 861
2012 honda red 742
2009 toyota red 320
2010 ford yellow 319
2000 ford green 587
2011 nissan blue 777
2014 ford blue 32
I am trying to replace the values in columns given multiple conditions. Two situations:
I would like to replace each
car_totalfor rows ofcompany == fordORcompany == nissanwith 0. What command would accomplish this?What if my constraints came from different columns? e.g. What if I wanted to replace any
car_totalwhich has itscompany == fordORcolor == redwith 0?
!ford | !redis the same as!(ford & red)dat$color <- as.character(dat$color)first - R won't allow you to assign a factor a value which isn't already present.