I am using levels(dataset$variable) and it is still showing a NULL output

Solution 1:

I’m guessing the course you’re following was created before R 4.0. In R4 the default value for the “stringsAsFactors” argument to data.frame was changed from true to false.