[R] Restricting Decimal Places in the Output

Shivi82 shivibhatia at ymail.com
Wed Jun 17 07:50:21 CEST 2015


Good Morning All,

I have working on a data set where I am finding mean and median for weight
variable on a daily basis. 
The code:

aggr<-aggregate(retail$weight,list(retail$ship.date),mean)
This is giving me an accurate result however with 4 decimal places for the
mean weight. In order to restrict it i used the following syntax:

format(aggr,digits=2,justify = c("right"))
After the execution of this code i have mean weight but now there are no
decimal places. Could you please advice what is incorrect in the syntax.

Thank you, Shivi



--
View this message in context: http://r.789695.n4.nabble.com/Restricting-Decimal-Places-in-the-Output-tp4708739.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list