I would like to create a function that helps me to identify possible mistakes in the levels of a factor by accessing the first letter, so first I am focused on the identification part.
Data Frame '''
alleles<-(c('A*24:02', 'A*11:01', 'blank', 'A*31:01'))
as.factor(alleles)
freq<-c(0.3782, 0.4209, 0.0362, 0.0761)
df<-data.frame(alleles, freq)
'''
My attempt_ '''
for(i in df$alleles){
if (i != 'A'){
can<-c()
append(can, i)
df$alleles<-df$alleles[-c(can)]
}
}
''' Error message Error in -c(can) : invalid argument to unary operator
Observations If I do '''print(can)''' the output is "NULL" meaning that it is not working the use of "append".