I have a data frame like below
df1 <- data.frame(Type=c("A","B","C"),Grade=c(23,22,44))
I need to create a new column "cat" with the condition as below
df1$cat <- ifelse(df1$Grade > 30, df1$Type, "0")
When i print column "cat" i wanted it to return 0,0,C. However it is returning me 0,0,3. Looks like it is returning the factor levels of Type instead of the actual values. Can someone suggest how can i get the desired output?