Re: [R] xyplot - show values of a series on graph

2009-04-08 Thread alienz747
This is great, thanks a lot!

On Wed, Apr 8, 2009 at 3:50 PM, baptiste auguie  wrote:

> not very clean, but perhaps,
>
> xyplot(cars+trucks~year, data=df2, type="o",
>  panel=function(x,y,subscripts,...){
>panel.xyplot(x,y,subscripts=subscripts,...)
>
>  grid.text(unit(df2$year,"native"),unit(df2$cars,"native"),label=df2$cars,
> just="top")}
>   )
>
> baptiste
>
> On 8 Apr 2009, at 20:25, taz9 wrote:
>
>
>> Thank you very much for your help. I tried to use lattice but I'm not sure
>> how to restrict it to display only the values of "cars".
>>
>> xyplot(cars+trucks~year, data=df2, type="o",
>> panel=function(x,y,...){
>>panel.xyplot(x,y,...)
>>grid.text(unit(x,"native"),unit(y,"native"),label=y, just="top")}
>>  )
>>
>>
>>
>> baptiste auguie-2 wrote:
>>
>>>
>>> with ggplot2,
>>>
>>> d <- melt(df2,id="year")
>>> qplot(year,value,data=d,colour=variable,geom=c("line","point")) +
>>> geom_text(data= subset(d, variable == "cars"), aes(label=value))
>>>
>>>
>>> with lattice, my best guess would be to use grid.text in a custom
>>> panel function.
>>>
>>>
>>> Hope this helps,
>>>
>>> baptiste
>>>
>>> On 8 Apr 2009, at 19:40, taz9 wrote:
>>>
>>>
 Hi All,

 I have a very simple graph:

 cars <- c(1, 3, 6, 4, 9)
 trucks <- c(2, 5, 4, 5, 12)
 year <- c(2004, 2005, 2006, 2007, 2008)
 df2<-data.frame(cars,trucks,year)
 xyplot(cars+trucks~year, data=df2, type="o")

 I need to show the values of "cars" on the graph. How can I do this?

 Thanks.

 --
 View this message in context:

 http://www.nabble.com/xyplot---show-values-of-a-series-on-graph-tp22956986p22956986.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org 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.

>>>
>>> _
>>>
>>> Baptiste Auguié
>>>
>>> School of Physics
>>> University of Exeter
>>> Stocker Road,
>>> Exeter, Devon,
>>> EX4 4QL, UK
>>>
>>> Phone: +44 1392 264187
>>>
>>> http://newton.ex.ac.uk/research/emag
>>>
>>> __
>>> R-help@r-project.org 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.
>>>
>>>
>>>
>> --
>> View this message in context:
>> http://www.nabble.com/xyplot---show-values-of-a-series-on-graph-tp22956986p22957501.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org 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.
>>
>
> _
>
> Baptiste Auguié
>
> School of Physics
> University of Exeter
> Stocker Road,
> Exeter, Devon,
> EX4 4QL, UK
>
> Phone: +44 1392 264187
>
> http://newton.ex.ac.uk/research/emag
> __
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] xyplot - show values of a series on graph

2009-04-08 Thread alienz747
Thank you so much Deepayan! My problem is solved.

On Wed, Apr 8, 2009 at 3:47 PM, Deepayan Sarkar
wrote:

> On Wed, Apr 8, 2009 at 12:25 PM, taz9  wrote:
> >
> > Thank you very much for your help. I tried to use lattice but I'm not
> sure
> > how to restrict it to display only the values of "cars".
> >
> > xyplot(cars+trucks~year, data=df2, type="o",
> > panel=function(x,y,...){
> >panel.xyplot(x,y,...)
> >grid.text(unit(x,"native"),unit(y,"native"),label=y, just="top")}
> >   )
>
> A custom 'panel.groups' will let you condition on group number (see
> ?panel.superpose):
>
> xyplot(cars+trucks~year, data=df2, type="o",
>   panel = panel.superpose,
>   panel.groups = function(x, y, ..., group.number) {
>   panel.xyplot(x,y,...)
>   if (group.number == 1) {
>   require(grid)
>   grid.text(unit(x,"native"),
> unit(y,"native"),
> label=y, just="top")
>   }
>   })
>
> -Deepayan
>
> >
> >
> >
> > baptiste auguie-2 wrote:
> >>
> >> with ggplot2,
> >>
> >> d <- melt(df2,id="year")
> >> qplot(year,value,data=d,colour=variable,geom=c("line","point")) +
> >> geom_text(data= subset(d, variable == "cars"), aes(label=value))
> >>
> >>
> >> with lattice, my best guess would be to use grid.text in a custom
> >> panel function.
> >>
> >>
> >> Hope this helps,
> >>
> >> baptiste
> >>
> >> On 8 Apr 2009, at 19:40, taz9 wrote:
> >>
> >>>
> >>> Hi All,
> >>>
> >>> I have a very simple graph:
> >>>
> >>> cars <- c(1, 3, 6, 4, 9)
> >>> trucks <- c(2, 5, 4, 5, 12)
> >>> year <- c(2004, 2005, 2006, 2007, 2008)
> >>> df2<-data.frame(cars,trucks,year)
> >>> xyplot(cars+trucks~year, data=df2, type="o")
> >>>
> >>> I need to show the values of "cars" on the graph. How can I do this?
> >>>
> >>> Thanks.
> >>>
> >>> --
> >>> View this message in context:
> >>>
> http://www.nabble.com/xyplot---show-values-of-a-series-on-graph-tp22956986p22956986.html
> >>> Sent from the R help mailing list archive at Nabble.com.
> >>>
> >>> __
> >>> R-help@r-project.org 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.
> >>
> >> _
> >>
> >> Baptiste Auguié
> >>
> >> School of Physics
> >> University of Exeter
> >> Stocker Road,
> >> Exeter, Devon,
> >> EX4 4QL, UK
> >>
> >> Phone: +44 1392 264187
> >>
> >> http://newton.ex.ac.uk/research/emag
>

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] xyplot - show values of a series on graph

2009-04-08 Thread baptiste auguie

not very clean, but perhaps,

xyplot(cars+trucks~year, data=df2, type="o",
 panel=function(x,y,subscripts,...){
panel.xyplot(x,y,subscripts=subscripts,...)
 	 
grid 
.text(unit(df2$year,"native"),unit(df2$cars,"native"),label=df2$cars,  
just="top")}

   )

baptiste

On 8 Apr 2009, at 20:25, taz9 wrote:



Thank you very much for your help. I tried to use lattice but I'm  
not sure

how to restrict it to display only the values of "cars".

xyplot(cars+trucks~year, data=df2, type="o",
panel=function(x,y,...){
panel.xyplot(x,y,...)
grid.text(unit(x,"native"),unit(y,"native"),label=y, just="top")}
  )



baptiste auguie-2 wrote:


with ggplot2,

d <- melt(df2,id="year")
qplot(year,value,data=d,colour=variable,geom=c("line","point")) +
geom_text(data= subset(d, variable == "cars"), aes(label=value))


with lattice, my best guess would be to use grid.text in a custom
panel function.


Hope this helps,

baptiste

On 8 Apr 2009, at 19:40, taz9 wrote:



Hi All,

I have a very simple graph:

cars <- c(1, 3, 6, 4, 9)
trucks <- c(2, 5, 4, 5, 12)
year <- c(2004, 2005, 2006, 2007, 2008)
df2<-data.frame(cars,trucks,year)
xyplot(cars+trucks~year, data=df2, type="o")

I need to show the values of "cars" on the graph. How can I do this?

Thanks.

--
View this message in context:
http://www.nabble.com/xyplot---show-values-of-a-series-on-graph-tp22956986p22956986.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@r-project.org 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.




--
View this message in context: 
http://www.nabble.com/xyplot---show-values-of-a-series-on-graph-tp22956986p22957501.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@r-project.org 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.


Re: [R] xyplot - show values of a series on graph

2009-04-08 Thread Deepayan Sarkar
On Wed, Apr 8, 2009 at 12:25 PM, taz9  wrote:
>
> Thank you very much for your help. I tried to use lattice but I'm not sure
> how to restrict it to display only the values of "cars".
>
> xyplot(cars+trucks~year, data=df2, type="o",
> panel=function(x,y,...){
>        panel.xyplot(x,y,...)
>        grid.text(unit(x,"native"),unit(y,"native"),label=y, just="top")}
>   )

A custom 'panel.groups' will let you condition on group number (see
?panel.superpose):

xyplot(cars+trucks~year, data=df2, type="o",
   panel = panel.superpose,
   panel.groups = function(x, y, ..., group.number) {
   panel.xyplot(x,y,...)
   if (group.number == 1) {
   require(grid)
   grid.text(unit(x,"native"),
 unit(y,"native"),
 label=y, just="top")
   }
   })

-Deepayan

>
>
>
> baptiste auguie-2 wrote:
>>
>> with ggplot2,
>>
>> d <- melt(df2,id="year")
>> qplot(year,value,data=d,colour=variable,geom=c("line","point")) +
>> geom_text(data= subset(d, variable == "cars"), aes(label=value))
>>
>>
>> with lattice, my best guess would be to use grid.text in a custom
>> panel function.
>>
>>
>> Hope this helps,
>>
>> baptiste
>>
>> On 8 Apr 2009, at 19:40, taz9 wrote:
>>
>>>
>>> Hi All,
>>>
>>> I have a very simple graph:
>>>
>>> cars <- c(1, 3, 6, 4, 9)
>>> trucks <- c(2, 5, 4, 5, 12)
>>> year <- c(2004, 2005, 2006, 2007, 2008)
>>> df2<-data.frame(cars,trucks,year)
>>> xyplot(cars+trucks~year, data=df2, type="o")
>>>
>>> I need to show the values of "cars" on the graph. How can I do this?
>>>
>>> Thanks.
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/xyplot---show-values-of-a-series-on-graph-tp22956986p22956986.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> __
>>> R-help@r-project.org 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.
>>
>> _
>>
>> Baptiste Auguié
>>
>> School of Physics
>> University of Exeter
>> Stocker Road,
>> Exeter, Devon,
>> EX4 4QL, UK
>>
>> Phone: +44 1392 264187
>>
>> http://newton.ex.ac.uk/research/emag

__
R-help@r-project.org 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.


Re: [R] xyplot - show values of a series on graph

2009-04-08 Thread taz9

Thank you very much for your help. I tried to use lattice but I'm not sure
how to restrict it to display only the values of "cars".

xyplot(cars+trucks~year, data=df2, type="o",
panel=function(x,y,...){
panel.xyplot(x,y,...)
grid.text(unit(x,"native"),unit(y,"native"),label=y, just="top")}
   )



baptiste auguie-2 wrote:
> 
> with ggplot2,
> 
> d <- melt(df2,id="year")
> qplot(year,value,data=d,colour=variable,geom=c("line","point")) +
> geom_text(data= subset(d, variable == "cars"), aes(label=value))
> 
> 
> with lattice, my best guess would be to use grid.text in a custom  
> panel function.
> 
> 
> Hope this helps,
> 
> baptiste
> 
> On 8 Apr 2009, at 19:40, taz9 wrote:
> 
>>
>> Hi All,
>>
>> I have a very simple graph:
>>
>> cars <- c(1, 3, 6, 4, 9)
>> trucks <- c(2, 5, 4, 5, 12)
>> year <- c(2004, 2005, 2006, 2007, 2008)
>> df2<-data.frame(cars,trucks,year)
>> xyplot(cars+trucks~year, data=df2, type="o")
>>
>> I need to show the values of "cars" on the graph. How can I do this?
>>
>> Thanks.
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/xyplot---show-values-of-a-series-on-graph-tp22956986p22956986.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org 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.
> 
> _
> 
> Baptiste Auguié
> 
> School of Physics
> University of Exeter
> Stocker Road,
> Exeter, Devon,
> EX4 4QL, UK
> 
> Phone: +44 1392 264187
> 
> http://newton.ex.ac.uk/research/emag
> 
> __
> R-help@r-project.org 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/xyplot---show-values-of-a-series-on-graph-tp22956986p22957501.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] xyplot - show values of a series on graph

2009-04-08 Thread baptiste auguie

with ggplot2,

d <- melt(df2,id="year")
qplot(year,value,data=d,colour=variable,geom=c("line","point")) +
geom_text(data= subset(d, variable == "cars"), aes(label=value))


with lattice, my best guess would be to use grid.text in a custom  
panel function.



Hope this helps,

baptiste

On 8 Apr 2009, at 19:40, taz9 wrote:



Hi All,

I have a very simple graph:

cars <- c(1, 3, 6, 4, 9)
trucks <- c(2, 5, 4, 5, 12)
year <- c(2004, 2005, 2006, 2007, 2008)
df2<-data.frame(cars,trucks,year)
xyplot(cars+trucks~year, data=df2, type="o")

I need to show the values of "cars" on the graph. How can I do this?

Thanks.

--
View this message in context: 
http://www.nabble.com/xyplot---show-values-of-a-series-on-graph-tp22956986p22956986.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@r-project.org 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.