I think you need to include some more information in order to fully diagnose this problem.
Can you include the rest of your code, especially the part where natenvir
is created? (Keep in mind this site’s homework policy, and don’t include any of the verbatim text of your assignment, though)
In the meantime, as a guess: is natenvir
a variable (column) in a data frame? If so, you need to refer to it with dataframename$variablename
syntax. Also, if natenvir
is a factor already, you don’t need to use unique()
inside your call to levels()
(levels
on its own gives you a unique list of the factor levels). However, be aware that neither of those bits of advice may help — I need to see more of your code to know for sure!
Finally, a tip to help your helpers: it’s really hard to read code that isn’t formatted as code, especially since this site will misinterpret special characters as other kinds of formatting (that’s why all your comments came out as headings!). Here’s how you can make the code you post here look nice