[R] object of type 'closure' is not subsettable

Sarah Goslee sarah.goslee at gmail.com
Tue Aug 5 17:20:23 CEST 2014


On Tue, Aug 5, 2014 at 7:33 AM, Frederic Ntirenganya <ntfredo at gmail.com> wrote:
> Dear All,
>
> I am getting this error: Error in boxplot$Month : object of type 'closure'
> is not subsettable

probably because your dataframe is box_plot while boxplot is the name
of a function.

Try
box_plot$Month

Sarah

> The following is the codes i am using to produce the boxplot I need for
> this daily rainfall data.
>
> ## reading the data
> rm(list=ls(all=TRUE))
> Bungoma=read.csv("/home/fredo/Documents/Maseno/Data/Bungoma_2.csv")
> attach(Bungoma)
> head(Bungoma)
> tail(Bungoma)
> summary(Bungoma)
> # removing missing values
> Bungoma <- na.omit(Bungoma)
> summary(Bungoma)
> ###### split the data by month and boxplot for 0.85mm as the threshold
> box_plot=Bungoma[Bungoma$Rain>0.85,]
> head(box_plot)
> bungoma_boxplot=split(box_plot$Rain,box_plot$Month)
> head(bungoma_boxplot)
> boxplot(bungoma_boxplot,
> names=c("J","F","M","A","M","J","J","A","S","O","N","D"),width =
> table(boxplot$Month))
> title(main="Boxplot of Rain for each month")
>
> Any idea is welcome on how I can make it and overcome the error. Thanks.
>

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list