I want to print different messages if the values in a column are unique or not unique:
df <- data.frame (test = c(1,1,1,2,2),
number = c(3,7,5,1,6)
)
if(unique(df$test)){
print("unique")
} else {
print("not unique")
}
It should print not unique since test does not have unique numbers. I get this warning message:
[1] "unique"
Warning message:
In if (unique(df$test)) { :
the condition has length > 1 and only the first element will be used