[R] Help on Histogram ~ Barplot

Jim Lemon drjimlemon at gmail.com
Wed May 27 12:49:39 CEST 2015


Hi Shivi82,
My suggestion is that the error concerned a mismatch between the
number of labels and the number of bars.

More seriously, you seem to want to sum the values of weight (MFST_WT)
within each month. So:

tot_mon_wt<-by(mwlc$MFST_WT,mwlc$Month,sum)
barplot(tot_mon_wt, names.arg = sort(unique(mwlc$Month)), las=2,
  ylim=c(0,25000),col="red",border="orange", main="Monthly Weight")

Jim


On Wed, May 27, 2015 at 7:28 PM, Shivi82 <shivibhatia at ymail.com> wrote:
> Hello All,
> I need help on creating a histogram for one of my data. The data is as below
> (sample):
> MFST_WT Hours   PROCESS Month   Weekday Day of the Month
> 6,828   13             INBOUND  Mar                  Fri        13
> 2,504   16             INBOUND  Mar                  Fri        27
> 20              16             INBOUND  Mar                  Fri        27
> 10,262  16             INBOUND  Mar                  Fri        27
> 2,500   17             INBOUND  Mar                  Fri        13
> 3,938   16             INBOUND  Feb                 Thu 26
> 798             10             INBOUND  Feb                 Sat 14
> 5,439   15             INBOUND  Feb                 Mon 16
>
> This data has these columns and total rows are 45000.
> Now I need to group the data and create a bar plot based on total weight on
> a monthly basis. The code I have used is:
> barplot(mwlc$MFST_WT, names.arg = mwlc$Month, las=2, ylim=c(0,10000), col
> ="red",
>         border="orange", main="Monthly Weight")
> but this is showing an error. Please suggest.
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Help-on-Histogram-Barplot-tp4707739.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list