Hello,

Could someone please advice how I can convert my variable to categorical using as.factor()?

I have googled the error, tried with as.factor(weeks) but it is not clear to me and I keep getting the same error.

My understanding is that I need to create more levels with the <- c("x"...) but that seems tedious with 52 weeks.

I have enclosed a screenshot of the result I am looking for but instead of weight I want weeks.

Please find below my first reprex.

Thanks in advance!!!!!!!!

```
reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-11-08
inference (y = weeks, data= nc, statistic = "mean", type= "ci", method= "theoretical", conf_level = 0,99)
#> Error in inference(y = weeks, data = nc, statistic = "mean", type = "ci", : could not find function "inference"
```

```
reprex::reprex_info()
reprex::reprex_info()\n#> Created by the reprex package v0.1.1.9000 on 2017-11-08\n\ninference (y = weeks, data= nc, statistic = "mean", type= "ci", method= "theoretical", conf_level = 0,99)\n#> Error in inference(y = weeks, data = nc, statistic = "mean", type = "ci", : could not find function "inference"
#> Error: <text>:3:22: unexpected input
#> 2:
#> 3: reprex::reprex_info()\
#>
```

Created by the reprex package v0.1.1.9000 on 2017-11-08

Explanatory variable was numerical, it has been converted

to categorical. In order to avoid this warning, first convert

your explanatory variable to a categorical variable using the

as.factor() function

Show Traceback

Error: Explanatory variable has only one level, it should have at least two levels