# Change the order of individual plots in the boxplot graph in R

#1

Hi,

I was trying to solve the ‘bike sharing demand’ problem on Kaggle and I extracted the dates from the datetime column and converted them into names of days->

days_int=as.integer(substr(train_bike\$datetime,9,10))

days<-c()
for(i in 1:10886)
{
if(i%%7==1)
days[i]=“Sat”
else if(i%%7==2)
days[i]=“Sun”
else if(i%%7==3)
days[i]=“Mon”
else if(i%%7==4)
days[i]=“Tue”
else if(i%%7==5)
days[i]=“Wed”
else if(i%%7==6)
days[i]=“Thu”
else if(i%%7==0)
days[i]=“Fri”
}

I wanted a boxplot for the count according tho the days and I used

boxplot(train_bike\$count~days)

and I get the output as ->

How to arrange these individual plots in the right order of the names of days of the week?

Thanks

#2

have you tried lubridate package for date time manipulation

http://cran.r-project.org/web/packages/lubridate/vignettes/lubridate.html

also see this

create the ordering you need by rebuilding the factors, with explicit manual ordering of the levels: