r verbose output on when converting factor to ordered

Viewed 29

I am getting a lot of unnecessary verbose output when I run the ordered function over my data frame for a column that I have defined as a factor.

My R code:

# Convert column to factor
data_3_base$soc <- as.factor(data_3_base$soc)

# Set the order of the Soc from 0 - 4
ordered(data_3_base$soc, levels = c("0", "1", "2", "3", "4"))

How do I stop the output?

1 Answers

It is not an in-place operator; you simply need to assign it:

data_3_base$soc <-ordered(data_3_base$soc, levels = c("0", "1", "2", "3", "4"))
Related