How to Apply countifs function in R ?

Hi,
i was trying to do countifs function in R,but so far unsuccessful. Sample data set is as follows:

|Table 1|

|Column 1| |Column 2| |Column 3| |Column 4|
|VillageName| |Household(HH)| |Toilet constructed Under Govt Scheme| |Toilet Status|
Village 1 HH1 Yes Functioning
Village 1 HH2 Yes Not Functioning
Village 1 HH3 No Functioning
Village 2 HH1 Yes Functioning
Village 2 HH2 No Not Functioning
Village 3 HH1 Yes Functioning
Village 3 HH2 No Not Functioning
Village 3 HH3 No Functioning
Village 3 HH4 Yes Functioning
|Column5|
|Water Connection|
Yes
No
Yes
Yes
No
Yes
Yes
No
Maybe.

|End|

I want to apply countifs. This is quite easy in excel which gives the following results:

|Output|

|Column 1| |Column 2| |Cloumn 3|
|Village Name| |Build under Govt Scheme| |Functioning Toilets(only under govt Scheme)|
Village 1 2 1
Village 2 1 1
Village 3 2 2

|Column 4|
|Water Connection(only for functioning and build under govt scheme)|
1
1
1

|End|

Basically in the output table ,for column 3, i want the count of functioning toilets which are built under govt. scheme for every village. For Column 4, i want the count of those Households who have water connection provided that they are functioning and were built under govt. scheme.

How do i do this in R? Please help

Thanks in advance.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.