Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

in R how to count the number of times a value appears and meet multiple criteria

$
0
0

example:

Colour   vehicle      city         type
red       car         London       Petrol
blue      truck       Paris        Diesel
red       car         NewYork      Electric
green     van         Barcelona    Petrol
black     motorbike   LosAngeles   Petrol

i.e. How to count number of times that "car" appears and it's "red" and "Petrol"

this is what I tried

sum(full_data$vehicle == "car"& full_data$Colour == "red"& 
  full_data$type == "Petrol")

Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>