Message-ID: <513733F8.2090101@sapo.pt>
Date: 2013-03-06T12:18:00Z
From: Rui Barradas
Subject: Plotting time data for various countries in same graph
In-Reply-To: <CAKC+_z-5H4DCy+EtTUEp6gG8QXtW-QwGULSr68yX2WO8d9FNiQ@mail.gmail.com>
Hello,
You've forgot to use a geom.
Also, to have Time be the x axis variable you need to do a conversion.
library(ggplot2)
dat <- read.table(text = "
Time Country Values
2010Q1 India 5
2010Q2 India 7
2010Q3 India 5
2010Q4 India 9
2010Q1 China 10
2010Q2 China 6
2010Q3 China 9
2010Q4 China 14
", header = TRUE)
dat$Time <- as.numeric(sub("Q", "\\.", dat$Time))
p <- ggplot(dat,aes(x=Time,y=Values,colour=Country))
p + geom_line()
Hope this helps,
Rui Barradas
Em 06-03-2013 08:06, Anindya Sankar Dey escreveu:
> Hi,
>
> I've the following kind of data
>
> Time Country Values
> 2010Q1 India 5
> 2010Q2 India 7
> 2010Q3 India 5
> 2010Q4 India 9
> 2010Q1 China 10
> 2010Q2 China 6
> 2010Q3 China 9
> 2010Q4 China 14
>
>
> I needed to plot a graph with the x-axis being time,y-axis being he Values
> and 2 line graph , one for India and one for counry.
>
> I don't have great knowledge on graphics in R.
>
> I was trying to use, ggplot(data,aes(x=Time,y=Values,colour=Country))
>
> But this does not help.
>
> Can anyone help me with this?
>