Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Countis function using fixed column range in R

$
0
0

@sahil_dhingra wrote:

How do I write below excel function in R?

=IF(OR(COUNTIF($Q4:$CG4, BL$6)>0, COUNTIF($Q4:$CG4, BL$6 & “w/ HRA”)>0), 1, 0)

So, I have a data frame in R ‘qryMDV1’ with 193 rows and 92 columns. Few column names are same but have different values. Now, I would like to look for a fixed value ( BL$6 in our case ) for example, ‘Hyundai’ or ‘Hyundai star’ under column 19 to 88 ($Q4:$CG4 in excel). in our data frame qryMDV1. If ‘Hyundai’ or ‘Hyundai with Star’ exist in column 19 to 88 for each row than calculate the count and if that is greater than 0 assign value ‘1’ otherwise ‘0’!

please refer to sample input data and desired output data.

Rcode1|565x500

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles