Need a help to plot bar for time series Rain data

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Need a help to plot bar for time series Rain data

Nyanzura
Hey Guys,
I am quite new to R, am trying to plot a bar plot for my monthly rainfall data from 1920 to 1990. For every year I have the data from January to December. I have created this code:

data<-read.table("C://R//Data//Rain.txt", header=TRUE)
data<-data[,2:13]
Rdata<-data[1,]
for(i in 2:79){Rdata<-c(Rdata,data[i,])}
times<-ts(Rdata,start=1920,frequency=12)
pdf("plot_Rain",width=20,height=5)
barplot(times)

I am getting this error:

Error in barplot.default(times) : 'height' must be a vector or a matrix

Could anyone please tell me how should I specify/write the code to plot the bars??

Thank you in advance for your time!

Nyanzura
Reply | Threaded
Open this post in threaded view
|

Re: Need a help to plot bar for time series Rain data

Jim Lemon
On 07/30/2010 06:51 PM, Nyanzura wrote:

>
> Hey Guys,
> I am quite new to R, am trying to plot a bar plot for my monthly rainfall
> data from 1920 to 1990. For every year I have the data from January to
> December. I have created this code:
>
> data<-read.table("C://R//Data//Rain.txt", header=TRUE)
> data<-data[,2:13]
> Rdata<-data[1,]
> for(i in 2:79){Rdata<-c(Rdata,data[i,])}
> times<-ts(Rdata,start=1920,frequency=12)
> pdf("plot_Rain",width=20,height=5)
> barplot(times)
>
> I am getting this error:
>
> Error in barplot.default(times) : 'height' must be a vector or a matrix
>
> Could anyone please tell me how should I specify/write the code to plot the
> bars??
>
Hi Nyanzura,
I guess the first thing would be to see what:

class(times)

has to say. However, a plot with 852 bars might be a little hard to
interpret.

Jim

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Need a help to plot bar for time series Rain data

Nyanzura
Hi Jim,

Thank you very much, let me check as you suggested. But in addition what do you think could be easy to interpret? Could you advice me please.

Nyanzura
Reply | Threaded
Open this post in threaded view
|

Re: Need a help to plot bar for time series Rain data

Jim Lemon
On 07/30/2010 09:24 PM, Nyanzura wrote:
>
> Hi Jim,
>
> Thank you very much, let me check as you suggested. But in addition what do
> you think could be easy to interpret? Could you advice me please.
>
I would probably start with:

plot(times,type="l",...)

if you can makes 'times' into a vector.

Jim

______________________________________________
[hidden email] mailing list
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.