Emerging 5G wireless technology will support services and use cases with vastly heterogeneous requirements. Network slicing, which allows composing multiple dedicated logical networks with specific functionality running on top of a common infrastructure, is introduced as a solution to cope with this heterogeneity. At the radio access network (RAN), the use of network slicing involves the assignment of radio resources to each slice in accordance with its expected requirements and functionalities. Therefore, RAN slicing will provide the required design flexibility and will be necessary for any network slicing solution. This paper investigates the RAN slicing problem for providing two generic services of 5G, namely enhanced mobile broadband (eMBB) and vehicle-to-everything (V2X). In this respect, we propose an efficient RAN slicing scheme based on an off-line reinforcement learning followed by a low-complexity heuristic algorithm, which allocates radio resources to different slices with the target of maximizing the resource utilization while ensuring the availability of resources to fulfill the requirements of the traffic of each RAN slice. A simulation-based analysis is presented to assess the performance of the proposed solution. The simulation results have shown that the proposed algorithm improves the network performance in terms of resource utilization, the latency of V2X services, achievable data rate, and outage probability. INDEX TERMS Vehicle-to-everything (V2X), reinforcement learning, network slicing, RAN slicing.