as factors - the object not found error.

if soc is in a data.frame then you wouldnt normally access it without a prexif / as if it was in global environment (because it isnt) perhaps data$soc would be appropriate. Its hard to advise you as you have not provided sufficient context...

If you would like help of greater quality then please consider providing a reprex.