add column to data frame based on conditions

A post was split to a new topic: Reactive values not working