I have a dataframe called df with variables AllCustomerName, and sum.of.FY.Total . The first column "AllCustomerName" has a list of all clients. I have a separate list that contains the names of the customers who I need information on. The code below is meant to loop through the dataframe column AllCustomerName, search for all values that equal my list values, and respectively add all values per each list observation.
y <- list("client 1", "client 2", "client 3") for ( i in y){ if ( df$AllCustomerName == i ){ sum(df$Sum.of.FY.Total) } }
When I run the code I however get warnings saying "the condition has length > 1 and only the first element will be used"
Thanks