'CONDITION WHICH VERIFY THE 2 FIRST CARACTER

I am working in R, this is a look of my table :

IAE_2017    IAE_2018

L1PYSH      L2PYSH

M1CHIMIE    M2CHIMIE
.....      ........

Now I want to make a condition which take the 2 first caracters of IAE_2017 and verify if it is different for the 2 fisrt's of IAE_2018.

r


Solution 1:[1]

You could use substr(), assuming df a dataframe :

substr(df[,1], start = 1, stop = 2)==substr(df[,2], start = 1, stop = 2)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Basti