[R] Make Month variable be called “May”,“June” etc., instead of a numeric quantity 5,6, etc.

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Thu Sep 20 19:36:59 CEST 2018


airquality$Month <- factor(airquality$Month, levels=1:12, labels=month.name )

On September 20, 2018 10:14:41 AM PDT, AbouEl-Makarim Aboueissa <abouelmakarim1962 using gmail.com> wrote:
>Dear All:
>
>*Re:* How to make the Month variable be called “May”,“June”, "July",
>"August", "September" instead of a numeric quantity (5,6,7,8,9)
>
>
>In the airquality data set, please see the code below; How to make the
>Month variable be called “May”,“June”, "July", "August", "September"
>instead of a numeric quantity (5,6,7,8,9)
>
>
>
>data(airquality)
>
>head(airquality)
>
>
>#### Making Day and Month categorical variables
>
>
>airquality$Day <- factor(airquality$Day)
>
>airquality$Month <- factor(airquality$Month)
>
>
>head(airquality)
>
>
>> head(airquality)
>  Ozone Solar.R Wind Temp Month Day
>1    41     190  7.4   67     5   1
>2    36     118  8.0   72     5   2
>3    12     149 12.6   74     5   3
>4    18     313 11.5   62     5   4
>5    NA      NA 14.3   56     5   5
>6    28      NA 14.9   66     5   6
>>
>
>
>
>Thank you very much for your help in advance
>
>
>with thanks
>abou
>______________________
>
>
>*AbouEl-Makarim Aboueissa, PhD*
>
>*Professor of Statistics*
>*Graduate Coordinator*
>
>*Department of Mathematics and Statistics*
>*University of Southern Maine*
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.




More information about the R-help mailing list