I have a df with 160 columns, This is a sample of the type of df
df = data.frame (id= c('u1', 'u1', 'u1', 'u2', 'u2'),
var1= c('e1','e2','e3','e3','e4'),
var2= c('a1','a1','a1','a1','a1'),
var3=c('M','M','M','M','M'),var4=(2,0.1,3,4,5),var5=(0.1,0.1,0.1,0.1,0.1),var6=(2,2,2,2,2))
I want to remove those columns that contain a single value (numeric or other type), so finally i would have a df like this
df_final = data.frame (id= c('u1', 'u1', 'u1', 'u2', 'u2'),
var1= c('e1','e2','e3','e3','e4'),
var4=(2,0.1,3,4,5))
what kind of functions could i use? or using loops and conditions?. Thnx