Cattle have a complex social organization, with negative (agonistic) and positive (affiliative) interactions that affect access to environmental resources. Thus, the social behaviour has a major impact on animal production, and it is an important factor to improve the farm animal welfare. The use of data from electronic bins to determine social competition has already been validated; however, the studies used non-free software or did not make the code available. With data from electronic bins is possible to identify when one animal takes the place of another animal, i.e. a replacement occurs, at the feeders or drinkers. However, there is no package for the R environment to detect competitive replacements from electronic bins data. Our general approach consisted in creating a user-friendly R package for social behaviour analysis. The workflow of the socialh package comprises several steps that can be used sequentially or separately, allowing data input from electronic systems, or obtained from the animals’ observation. We provide an overview of all functions of the socialh package and demonstrate how this package can be applied using data from electronic feed bins of beef cattle. The socialh package provides support for researchers to determine the social hierarchy of gregarious animals through the synthesis of agonistic interactions (or replacement) in a friendly, versatile, and open-access system, thus contributing to scientific research.