Re: [R] Plotting in R

2019-07-18 Thread nstefi
Thanks Jim,

I appreciate that you spend so much time helping me on this.
I translated your code to use my plot_ly function this way, I'm not sure if 
this is correct, but tried to match your x and y axis and the labels. Here is 
the complete code including data below, but it seems like my code "ticktext =" 
is ignored, and it still shows the years in the x axis as labels:

sydf<-read.table(text="year monthday rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE,
 stringsAsFactors=FALSE)

sydf$date<-as.Date(paste(sydf$year,sydf$monthday),"%Y %m-%d")
every3rd<-seq(1,length(sydf$date),3)

library(plotly)
plot_ly(sydf,
x = ~date,
y = ~rate,
type = 'scatter', mode = 'lines') %>%
  layout(
xaxis = list(
  ticktext = sydf$monthday[every3rd],
  tickvals = sydf$year,
  tickmode = "array",
  tickangle = 270
))


Thanks,
Steven

-Original Message-
From: Jim Lemon  
Sent: Thursday, July 18, 2019 5:25 AM
To: nst...@gmail.com
Cc: r-help mailing list 
Subject: Re: [R] Plotting in R

Hi Steven,
I caved in and installed plotly. Not an easy task. When I tried your example, I 
got a blank HTML page displayed. I then created a plot with your data above 
showing every third monthday label. If this is what you want, maybe the way I 
have coded it will work in plotly.

sydf$date<-as.Date(paste(sydf$year,sydf$monthday),"%Y %m-%d")
plot(sydf$date,sydf$rate,type="l",xaxt="n")
every3rd<-seq(1,length(sydf$date),3)
axis(1,at=sydf$date[every3rd],labels=sydf$monthday[every3rd])

Jim

On Wed, Jul 17, 2019 at 4:58 AM  wrote:
>
> Sorry, this still doesn't work.
>
> When I use that expression in "ticktext" parameter, it shows those every 3rd 
> label in the beginning, and after they finished, it shows some remaining 
> values from "year" column.
> When I tried with my real data, it was showing the original x axis values as 
> lables, it seems like it ignored the "ticktext" parameter.
> This is my short example:
> sydf<-read.table(text="year monthday rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE,
>  stringsAsFactors=FALSE)
>
> library(plotly)
> plot_ly(sydf,
> x = ~year,
> y = ~rate,
> type = 'scatter', mode = 'lines') %>%
>   layout(
> xaxis = list(
>   ticktext = sydf$monthday[seq(1, length(sydf$monthday), 3)],
>   tickvals = sydf$year,
>   tickmode = "array",
>   tickangle = 270
> ))
>
> Any ideas?
>
> Thanks,
> Steven
>
> -Original Message-
> From: nst...@gmail.com 
> Sent: Tuesday, July 16, 2019 9:55 AM
> To: 'Jim Lemon' 
> Cc: 'r-help mailing list' 
> Subject: RE: [R] Plotting in R
>
> OK, I think I got this:
>
> For example every 3rd element would be:
> sydf$monthday[seq(1, length(sydf$monthday), 3)]
>
> Thanks,
> Steven
>
> -Original Message-
> From: nst...@gmail.com 
> Sent: Tuesday, July 16, 2019 9:39 AM
> To: 'Jim Lemon' 
> Cc: 'r-help mailing list' 
> Subject: RE: [R] Plotting in R
>
> Thanks Jim,
>
> Yes, I only want to show the month and day as labels, because on my chart I 
> am actually showing 2 line charts, one from the previous year, and one from 
> this year, to compare them, and the month and day are matching for them, but 
> the year would be different, so it makes sense to show only month and day on 
> the x axis.
> So it looks like I got the solution already for that part, the new challenge 
> is that there were too many labels and overlapping on each other.
> What is the best way to evenly sample values from a long list of string 
> values?
> So let's say my data was this overly simplified:
> sydf<-read.table(text="year monthday rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  heade

Re: [R] Plotting in R

2019-07-18 Thread Jim Lemon
Hi Steven,
I caved in and installed plotly. Not an easy task. When I tried your
example, I got a blank HTML page displayed. I then created a plot with
your data above showing every third monthday label. If this is what
you want, maybe the way I have coded it will work in plotly.

sydf$date<-as.Date(paste(sydf$year,sydf$monthday),"%Y %m-%d")
plot(sydf$date,sydf$rate,type="l",xaxt="n")
every3rd<-seq(1,length(sydf$date),3)
axis(1,at=sydf$date[every3rd],labels=sydf$monthday[every3rd])

Jim

On Wed, Jul 17, 2019 at 4:58 AM  wrote:
>
> Sorry, this still doesn't work.
>
> When I use that expression in "ticktext" parameter, it shows those every 3rd 
> label in the beginning, and after they finished, it shows some remaining 
> values from "year" column.
> When I tried with my real data, it was showing the original x axis values as 
> lables, it seems like it ignored the "ticktext" parameter.
> This is my short example:
> sydf<-read.table(text="year monthday rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE,
>  stringsAsFactors=FALSE)
>
> library(plotly)
> plot_ly(sydf,
> x = ~year,
> y = ~rate,
> type = 'scatter', mode = 'lines') %>%
>   layout(
> xaxis = list(
>   ticktext = sydf$monthday[seq(1, length(sydf$monthday), 3)],
>   tickvals = sydf$year,
>   tickmode = "array",
>   tickangle = 270
> ))
>
> Any ideas?
>
> Thanks,
> Steven
>
> -Original Message-
> From: nst...@gmail.com 
> Sent: Tuesday, July 16, 2019 9:55 AM
> To: 'Jim Lemon' 
> Cc: 'r-help mailing list' 
> Subject: RE: [R] Plotting in R
>
> OK, I think I got this:
>
> For example every 3rd element would be:
> sydf$monthday[seq(1, length(sydf$monthday), 3)]
>
> Thanks,
> Steven
>
> -Original Message-
> From: nst...@gmail.com 
> Sent: Tuesday, July 16, 2019 9:39 AM
> To: 'Jim Lemon' 
> Cc: 'r-help mailing list' 
> Subject: RE: [R] Plotting in R
>
> Thanks Jim,
>
> Yes, I only want to show the month and day as labels, because on my chart I 
> am actually showing 2 line charts, one from the previous year, and one from 
> this year, to compare them, and the month and day are matching for them, but 
> the year would be different, so it makes sense to show only month and day on 
> the x axis.
> So it looks like I got the solution already for that part, the new challenge 
> is that there were too many labels and overlapping on each other.
> What is the best way to evenly sample values from a long list of string 
> values?
> So let's say my data was this overly simplified:
> sydf<-read.table(text="year monthday rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE,
>  stringsAsFactors=FALSE)
>
> Then my x axis would be based on the values of sydf$monthday - In my case 
> there are lots of values. How can I subset this to have only every n-th 
> value? I guess this must be some common operation in R.
> So if I have 200 values, and I only want to show 20 of them as labels, I 
> would calculate n = 200/20 = 10 and I want to get every 10th value in the 
> list sydf$monthday. But the list has strings, so I cannot use "by =".
>
> Thank you,
> Steven
>
> -Original Message-
> From: Jim Lemon 
> Sent: Friday, July 12, 2019 6:41 PM
> To: nst...@gmail.com
> Cc: r-help mailing list 
> Subject: Re: [R] Plotting in R
>
> Oh, sorry, I think I see what you have tried to do. You want yearly ticks but 
> month-day labels. These won't mean much unless you also have the year. If you 
> ask for a date with just the year, as.Date will give you a date in the middle 
> of that year:
>
> as.Date("2002","%Y")
> [1] "2002-07-13"
>
> So making the labels these mid-year dates as character strings might do what 
> you want:
>
> yrlabels<-as.character(yrticks)
>
> Jim
>
> On Sat, Jul 13, 2019 at 8:33 AM Jim Lemon  wrote:
> >
> > Hi Steven,
> > year1

Re: [R] Plotting in R

2019-07-16 Thread nstefi
Sorry, this still doesn't work.

When I use that expression in "ticktext" parameter, it shows those every 3rd 
label in the beginning, and after they finished, it shows some remaining values 
from "year" column.
When I tried with my real data, it was showing the original x axis values as 
lables, it seems like it ignored the "ticktext" parameter.
This is my short example:
sydf<-read.table(text="year monthday rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE,
 stringsAsFactors=FALSE)

library(plotly)
plot_ly(sydf,
x = ~year,
y = ~rate,
type = 'scatter', mode = 'lines') %>%
  layout(
xaxis = list(
  ticktext = sydf$monthday[seq(1, length(sydf$monthday), 3)],
  tickvals = sydf$year,
  tickmode = "array",
  tickangle = 270
))

Any ideas?

Thanks,
Steven

-Original Message-
From: nst...@gmail.com  
Sent: Tuesday, July 16, 2019 9:55 AM
To: 'Jim Lemon' 
Cc: 'r-help mailing list' 
Subject: RE: [R] Plotting in R

OK, I think I got this:

For example every 3rd element would be:
sydf$monthday[seq(1, length(sydf$monthday), 3)]

Thanks,
Steven

-Original Message-
From: nst...@gmail.com 
Sent: Tuesday, July 16, 2019 9:39 AM
To: 'Jim Lemon' 
Cc: 'r-help mailing list' 
Subject: RE: [R] Plotting in R

Thanks Jim,

Yes, I only want to show the month and day as labels, because on my chart I am 
actually showing 2 line charts, one from the previous year, and one from this 
year, to compare them, and the month and day are matching for them, but the 
year would be different, so it makes sense to show only month and day on the x 
axis.
So it looks like I got the solution already for that part, the new challenge is 
that there were too many labels and overlapping on each other.
What is the best way to evenly sample values from a long list of string values?
So let's say my data was this overly simplified:
sydf<-read.table(text="year monthday rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE,
 stringsAsFactors=FALSE)

Then my x axis would be based on the values of sydf$monthday - In my case there 
are lots of values. How can I subset this to have only every n-th value? I 
guess this must be some common operation in R.
So if I have 200 values, and I only want to show 20 of them as labels, I would 
calculate n = 200/20 = 10 and I want to get every 10th value in the list 
sydf$monthday. But the list has strings, so I cannot use "by =".

Thank you,
Steven

-----Original Message-
From: Jim Lemon 
Sent: Friday, July 12, 2019 6:41 PM
To: nst...@gmail.com
Cc: r-help mailing list 
Subject: Re: [R] Plotting in R

Oh, sorry, I think I see what you have tried to do. You want yearly ticks but 
month-day labels. These won't mean much unless you also have the year. If you 
ask for a date with just the year, as.Date will give you a date in the middle 
of that year:

as.Date("2002","%Y")
[1] "2002-07-13"

So making the labels these mid-year dates as character strings might do what 
you want:

yrlabels<-as.character(yrticks)

Jim

On Sat, Jul 13, 2019 at 8:33 AM Jim Lemon  wrote:
>
> Hi Steven,
> year1 is a number (e.g. 1993), monthday (e.g. 05-01) is not.
>
> Jim
>
> On Fri, Jul 12, 2019 at 10:56 PM  wrote:
> >
> > Thanks Jim.
> >
> > I am trying to apply this to my version with plot_ly, and couldn't make it 
> > to work.
> > The sydf$year1 field is numeric, so the min() and max() works, but when I 
> > tried to use your formula for the sydf$monthday field I get an error:
> > yrticks <- 
> > as.Date(as.character(seq(min(sydf$monthday),max(sydf$monthday),by=2)),
> >   "%Y")
> >
> > Error in seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
> >   'from' must be a finite number
> > In addition: Warning message:
> > In seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
> >   NAs introduced by coercion
> >
> > So I thought maybe you need to sample the tickvals not the ticktext and it 
> > would show the corresponding tick labels in the right palaces. Then I tried 
> > the way you had like this:
> > sydf<-read.table(text="year1 monthday rate
> >  1993 05-01 0.608
> >  1994 0

Re: [R] Plotting in R

2019-07-16 Thread nstefi
OK, I think I got this:

For example every 3rd element would be:
sydf$monthday[seq(1, length(sydf$monthday), 3)]

Thanks,
Steven

-Original Message-
From: nst...@gmail.com  
Sent: Tuesday, July 16, 2019 9:39 AM
To: 'Jim Lemon' 
Cc: 'r-help mailing list' 
Subject: RE: [R] Plotting in R

Thanks Jim,

Yes, I only want to show the month and day as labels, because on my chart I am 
actually showing 2 line charts, one from the previous year, and one from this 
year, to compare them, and the month and day are matching for them, but the 
year would be different, so it makes sense to show only month and day on the x 
axis.
So it looks like I got the solution already for that part, the new challenge is 
that there were too many labels and overlapping on each other.
What is the best way to evenly sample values from a long list of string values?
So let's say my data was this overly simplified:
sydf<-read.table(text="year monthday rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE,
 stringsAsFactors=FALSE)

Then my x axis would be based on the values of sydf$monthday - In my case there 
are lots of values. How can I subset this to have only every n-th value? I 
guess this must be some common operation in R.
So if I have 200 values, and I only want to show 20 of them as labels, I would 
calculate n = 200/20 = 10 and I want to get every 10th value in the list 
sydf$monthday. But the list has strings, so I cannot use "by =".

Thank you,
Steven

-Original Message-
From: Jim Lemon 
Sent: Friday, July 12, 2019 6:41 PM
To: nst...@gmail.com
Cc: r-help mailing list 
Subject: Re: [R] Plotting in R

Oh, sorry, I think I see what you have tried to do. You want yearly ticks but 
month-day labels. These won't mean much unless you also have the year. If you 
ask for a date with just the year, as.Date will give you a date in the middle 
of that year:

as.Date("2002","%Y")
[1] "2002-07-13"

So making the labels these mid-year dates as character strings might do what 
you want:

yrlabels<-as.character(yrticks)

Jim

On Sat, Jul 13, 2019 at 8:33 AM Jim Lemon  wrote:
>
> Hi Steven,
> year1 is a number (e.g. 1993), monthday (e.g. 05-01) is not.
>
> Jim
>
> On Fri, Jul 12, 2019 at 10:56 PM  wrote:
> >
> > Thanks Jim.
> >
> > I am trying to apply this to my version with plot_ly, and couldn't make it 
> > to work.
> > The sydf$year1 field is numeric, so the min() and max() works, but when I 
> > tried to use your formula for the sydf$monthday field I get an error:
> > yrticks <- 
> > as.Date(as.character(seq(min(sydf$monthday),max(sydf$monthday),by=2)),
> >   "%Y")
> >
> > Error in seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
> >   'from' must be a finite number
> > In addition: Warning message:
> > In seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
> >   NAs introduced by coercion
> >
> > So I thought maybe you need to sample the tickvals not the ticktext and it 
> > would show the corresponding tick labels in the right palaces. Then I tried 
> > the way you had like this:
> > sydf<-read.table(text="year1 monthday rate
> >  1993 05-01 0.608
> >  1994 06-01 0.622
> >  1996 07-01 0.623
> >  1998 08-01 0.647
> >  2000 09-01 0.646
> >  2002 10-01 0.625
> >  2004 11-01 0.628
> >  2006 12-01 0.685
> >  2008 01-01 0.679
> >  2010 02-01 0.595
> >  2012 03-01 0.567
> >  2014 04-01 0.599
> >  2016 05-01 0.642
> >  2018 06-01 0.685",
> >  header=TRUE,
> >  stringsAsFactors=FALSE)
> >
> > yrticks <- as.Date(as.character(seq(min(sydf$year1),max(sydf$year1),by=2)),
> >   "%Y")
> >
> > library(plotly)
> > plot_ly(sydf,
> > x = ~year1,
> > y = ~rate,
> > type = 'scatter', mode = 'lines') %>%
> >   layout(
> > xaxis = list(
> >   ticktext = sydf$monthday,
> >   tickvals = sydf$yrticks,
> >   tickmode = "array",
> >   tickangle = 270
> > ))
> >
> > But the chart didn't show any tick labels.
> > I guess I need to sample sydf$monthday, right? Because that's what I want 
> > to show as tick labels. But the problem is that monthday is string, and 
> > can't use a value for "by=", maybe I need to

Re: [R] Plotting in R

2019-07-16 Thread nstefi
Thanks Jim,

Yes, I only want to show the month and day as labels, because on my chart I am 
actually showing 2 line charts, one from the previous year, and one from this 
year, to compare them, and the month and day are matching for them, but the 
year would be different, so it makes sense to show only month and day on the x 
axis.
So it looks like I got the solution already for that part, the new challenge is 
that there were too many labels and overlapping on each other.
What is the best way to evenly sample values from a long list of string values?
So let's say my data was this overly simplified:
sydf<-read.table(text="year monthday rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE,
 stringsAsFactors=FALSE)

Then my x axis would be based on the values of sydf$monthday - In my case there 
are lots of values. How can I subset this to have only every n-th value? I 
guess this must be some common operation in R.
So if I have 200 values, and I only want to show 20 of them as labels, I would 
calculate n = 200/20 = 10 and I want to get every 10th value in the list 
sydf$monthday. But the list has strings, so I cannot use "by =".

Thank you,
Steven

-Original Message-
From: Jim Lemon  
Sent: Friday, July 12, 2019 6:41 PM
To: nst...@gmail.com
Cc: r-help mailing list 
Subject: Re: [R] Plotting in R

Oh, sorry, I think I see what you have tried to do. You want yearly ticks but 
month-day labels. These won't mean much unless you also have the year. If you 
ask for a date with just the year, as.Date will give you a date in the middle 
of that year:

as.Date("2002","%Y")
[1] "2002-07-13"

So making the labels these mid-year dates as character strings might do what 
you want:

yrlabels<-as.character(yrticks)

Jim

On Sat, Jul 13, 2019 at 8:33 AM Jim Lemon  wrote:
>
> Hi Steven,
> year1 is a number (e.g. 1993), monthday (e.g. 05-01) is not.
>
> Jim
>
> On Fri, Jul 12, 2019 at 10:56 PM  wrote:
> >
> > Thanks Jim.
> >
> > I am trying to apply this to my version with plot_ly, and couldn't make it 
> > to work.
> > The sydf$year1 field is numeric, so the min() and max() works, but when I 
> > tried to use your formula for the sydf$monthday field I get an error:
> > yrticks <- 
> > as.Date(as.character(seq(min(sydf$monthday),max(sydf$monthday),by=2)),
> >   "%Y")
> >
> > Error in seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
> >   'from' must be a finite number
> > In addition: Warning message:
> > In seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
> >   NAs introduced by coercion
> >
> > So I thought maybe you need to sample the tickvals not the ticktext and it 
> > would show the corresponding tick labels in the right palaces. Then I tried 
> > the way you had like this:
> > sydf<-read.table(text="year1 monthday rate
> >  1993 05-01 0.608
> >  1994 06-01 0.622
> >  1996 07-01 0.623
> >  1998 08-01 0.647
> >  2000 09-01 0.646
> >  2002 10-01 0.625
> >  2004 11-01 0.628
> >  2006 12-01 0.685
> >  2008 01-01 0.679
> >  2010 02-01 0.595
> >  2012 03-01 0.567
> >  2014 04-01 0.599
> >  2016 05-01 0.642
> >  2018 06-01 0.685",
> >  header=TRUE,
> >  stringsAsFactors=FALSE)
> >
> > yrticks <- as.Date(as.character(seq(min(sydf$year1),max(sydf$year1),by=2)),
> >   "%Y")
> >
> > library(plotly)
> > plot_ly(sydf,
> > x = ~year1,
> > y = ~rate,
> > type = 'scatter', mode = 'lines') %>%
> >   layout(
> > xaxis = list(
> >   ticktext = sydf$monthday,
> >   tickvals = sydf$yrticks,
> >   tickmode = "array",
> >   tickangle = 270
> > ))
> >
> > But the chart didn't show any tick labels.
> > I guess I need to sample sydf$monthday, right? Because that's what I want 
> > to show as tick labels. But the problem is that monthday is string, and 
> > can't use a value for "by=", maybe I need to sample somehow by the index 
> > position.
> >
> > Thanks,
> > Steven
> >
> > -Original Message-
> > From: Jim Lemon 
> > Sent: Thursday, July 11, 2019 10:41 PM
> > To: nst...@gmail.com
> > Cc: r-help mailing list 
> > Subject: Re: [R] Plotti

Re: [R] Plotting in R

2019-07-12 Thread Jim Lemon
Oh, sorry, I think I see what you have tried to do. You want yearly
ticks but month-day labels. These won't mean much unless you also have
the year. If you ask for a date with just the year, as.Date will give
you a date in the middle of that year:

as.Date("2002","%Y")
[1] "2002-07-13"

So making the labels these mid-year dates as character strings might
do what you want:

yrlabels<-as.character(yrticks)

Jim

On Sat, Jul 13, 2019 at 8:33 AM Jim Lemon  wrote:
>
> Hi Steven,
> year1 is a number (e.g. 1993), monthday (e.g. 05-01) is not.
>
> Jim
>
> On Fri, Jul 12, 2019 at 10:56 PM  wrote:
> >
> > Thanks Jim.
> >
> > I am trying to apply this to my version with plot_ly, and couldn't make it 
> > to work.
> > The sydf$year1 field is numeric, so the min() and max() works, but when I 
> > tried to use your formula for the sydf$monthday field I get an error:
> > yrticks <- 
> > as.Date(as.character(seq(min(sydf$monthday),max(sydf$monthday),by=2)),
> >   "%Y")
> >
> > Error in seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
> >   'from' must be a finite number
> > In addition: Warning message:
> > In seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
> >   NAs introduced by coercion
> >
> > So I thought maybe you need to sample the tickvals not the ticktext and it 
> > would show the corresponding tick labels in the right palaces. Then I tried 
> > the way you had like this:
> > sydf<-read.table(text="year1 monthday rate
> >  1993 05-01 0.608
> >  1994 06-01 0.622
> >  1996 07-01 0.623
> >  1998 08-01 0.647
> >  2000 09-01 0.646
> >  2002 10-01 0.625
> >  2004 11-01 0.628
> >  2006 12-01 0.685
> >  2008 01-01 0.679
> >  2010 02-01 0.595
> >  2012 03-01 0.567
> >  2014 04-01 0.599
> >  2016 05-01 0.642
> >  2018 06-01 0.685",
> >  header=TRUE,
> >  stringsAsFactors=FALSE)
> >
> > yrticks <- as.Date(as.character(seq(min(sydf$year1),max(sydf$year1),by=2)),
> >   "%Y")
> >
> > library(plotly)
> > plot_ly(sydf,
> > x = ~year1,
> > y = ~rate,
> > type = 'scatter', mode = 'lines') %>%
> >   layout(
> > xaxis = list(
> >   ticktext = sydf$monthday,
> >   tickvals = sydf$yrticks,
> >   tickmode = "array",
> >   tickangle = 270
> > ))
> >
> > But the chart didn't show any tick labels.
> > I guess I need to sample sydf$monthday, right? Because that's what I want 
> > to show as tick labels. But the problem is that monthday is string, and 
> > can't use a value for "by=", maybe I need to sample somehow by the index 
> > position.
> >
> > Thanks,
> > Steven
> >
> > -Original Message-
> > From: Jim Lemon 
> > Sent: Thursday, July 11, 2019 10:41 PM
> > To: nst...@gmail.com
> > Cc: r-help mailing list 
> > Subject: Re: [R] Plotting in R
> >
> > Hi Steven,
> > Neat solution. With a lot more values on the time axis, you will be better 
> > off with something like:
> >
> > yrticks<-as.Date(as.character(seq(min(sydf$year1),max(sydf$year1),by=2)),
> >  "%Y")
> > axis(1,at=yrticks,labels=format(yrticks,"%Y"))
> >
> > You probably won't need staxlab for that.
> >
> > Jim
> >
> > On Fri, Jul 12, 2019 at 11:55 AM  wrote:
> > >
> > > Thanks Jim, that worked.
> > >
> > > > I expected that the axis labels would be crowded so I used the plotrix 
> > > > library to stagger the x-axis labels. Hope this solves your problem.
> > > I liked how that showed, not overlapping on each other. I wasn't aware of 
> > > the plotrix library.
> > >
> > > In my code I was using plot_ly for visualization, because it looked nicer 
> > > compared to the simple plot() function, and I have the chart in a Shiny 
> > > dashboard (RMD file).
> > > I found in the meantime today some code example for plot_ly and using the 
> > > same data it looks like this:
> > > sydf<-read.table(text="year1 monthday rate
> > >  1993 05-01 0.608
> > >  1994 06-01 0.622
> > >  1996 07-01 0.623
> > >  1998 08-01 0.647
> > >  2000 09-01 0.646
> > >  2002 10-01 0.625
> > >  2004 11-01 0.628
> > >  2006 12-01 0.685
> > >  2008 01-01 0

Re: [R] Plotting in R

2019-07-12 Thread Jim Lemon
Hi Steven,
year1 is a number (e.g. 1993), monthday (e.g. 05-01) is not.

Jim

On Fri, Jul 12, 2019 at 10:56 PM  wrote:
>
> Thanks Jim.
>
> I am trying to apply this to my version with plot_ly, and couldn't make it to 
> work.
> The sydf$year1 field is numeric, so the min() and max() works, but when I 
> tried to use your formula for the sydf$monthday field I get an error:
> yrticks <- 
> as.Date(as.character(seq(min(sydf$monthday),max(sydf$monthday),by=2)),
>   "%Y")
>
> Error in seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
>   'from' must be a finite number
> In addition: Warning message:
> In seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
>   NAs introduced by coercion
>
> So I thought maybe you need to sample the tickvals not the ticktext and it 
> would show the corresponding tick labels in the right palaces. Then I tried 
> the way you had like this:
> sydf<-read.table(text="year1 monthday rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE,
>  stringsAsFactors=FALSE)
>
> yrticks <- as.Date(as.character(seq(min(sydf$year1),max(sydf$year1),by=2)),
>   "%Y")
>
> library(plotly)
> plot_ly(sydf,
> x = ~year1,
> y = ~rate,
> type = 'scatter', mode = 'lines') %>%
>   layout(
> xaxis = list(
>   ticktext = sydf$monthday,
>   tickvals = sydf$yrticks,
>   tickmode = "array",
>   tickangle = 270
> ))
>
> But the chart didn't show any tick labels.
> I guess I need to sample sydf$monthday, right? Because that's what I want to 
> show as tick labels. But the problem is that monthday is string, and can't 
> use a value for "by=", maybe I need to sample somehow by the index position.
>
> Thanks,
> Steven
>
> -Original Message-
> From: Jim Lemon 
> Sent: Thursday, July 11, 2019 10:41 PM
> To: nst...@gmail.com
> Cc: r-help mailing list 
> Subject: Re: [R] Plotting in R
>
> Hi Steven,
> Neat solution. With a lot more values on the time axis, you will be better 
> off with something like:
>
> yrticks<-as.Date(as.character(seq(min(sydf$year1),max(sydf$year1),by=2)),
>  "%Y")
> axis(1,at=yrticks,labels=format(yrticks,"%Y"))
>
> You probably won't need staxlab for that.
>
> Jim
>
> On Fri, Jul 12, 2019 at 11:55 AM  wrote:
> >
> > Thanks Jim, that worked.
> >
> > > I expected that the axis labels would be crowded so I used the plotrix 
> > > library to stagger the x-axis labels. Hope this solves your problem.
> > I liked how that showed, not overlapping on each other. I wasn't aware of 
> > the plotrix library.
> >
> > In my code I was using plot_ly for visualization, because it looked nicer 
> > compared to the simple plot() function, and I have the chart in a Shiny 
> > dashboard (RMD file).
> > I found in the meantime today some code example for plot_ly and using the 
> > same data it looks like this:
> > sydf<-read.table(text="year1 monthday rate
> >  1993 05-01 0.608
> >  1994 06-01 0.622
> >  1996 07-01 0.623
> >  1998 08-01 0.647
> >  2000 09-01 0.646
> >  2002 10-01 0.625
> >  2004 11-01 0.628
> >  2006 12-01 0.685
> >  2008 01-01 0.679
> >  2010 02-01 0.595
> >  2012 03-01 0.567
> >  2014 04-01 0.599
> >  2016 05-01 0.642
> >  2018 06-01 0.685",
> >  header=TRUE,
> >  stringsAsFactors=FALSE)
> >
> > library(plotly)
> > plot_ly(sydf,
> > x = ~year1,
> > y = ~rate,
> > type = 'scatter', mode = 'lines') %>%
> >   layout(
> > xaxis = list(
> >   ticktext = sydf$monthday,
> >   tickvals = sydf$year1,
> >   tickmode = "array",
> >   tickangle = 270
> >     ))
> >
> > This is where I found about the parameters:
> > https://plot.ly/r/tick-formatting/
> >
> > Now my other challenge is that with my data I have a lot more values on the 
> > x axis, and they overlap even when turned vertically. I guess there must be 
> > a way of taking a number of values evenly from the list of x axis lables, 
> > and use that for the

Re: [R] Plotting in R

2019-07-12 Thread nstefi
Thanks Jim.

I am trying to apply this to my version with plot_ly, and couldn't make it to 
work.
The sydf$year1 field is numeric, so the min() and max() works, but when I tried 
to use your formula for the sydf$monthday field I get an error:
yrticks <- 
as.Date(as.character(seq(min(sydf$monthday),max(sydf$monthday),by=2)),
  "%Y")

Error in seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) : 
  'from' must be a finite number
In addition: Warning message:
In seq.default(min(sydf$monthday), max(sydf$monthday), by = 2) :
  NAs introduced by coercion

So I thought maybe you need to sample the tickvals not the ticktext and it 
would show the corresponding tick labels in the right palaces. Then I tried the 
way you had like this:
sydf<-read.table(text="year1 monthday rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE,
 stringsAsFactors=FALSE)

yrticks <- as.Date(as.character(seq(min(sydf$year1),max(sydf$year1),by=2)),
  "%Y")

library(plotly)
plot_ly(sydf,
x = ~year1,
y = ~rate,
type = 'scatter', mode = 'lines') %>%
  layout(
xaxis = list(
  ticktext = sydf$monthday,
  tickvals = sydf$yrticks,
  tickmode = "array",
  tickangle = 270
))

But the chart didn't show any tick labels.
I guess I need to sample sydf$monthday, right? Because that's what I want to 
show as tick labels. But the problem is that monthday is string, and can't use 
a value for "by=", maybe I need to sample somehow by the index position.

Thanks,
Steven

-Original Message-
From: Jim Lemon  
Sent: Thursday, July 11, 2019 10:41 PM
To: nst...@gmail.com
Cc: r-help mailing list 
Subject: Re: [R] Plotting in R

Hi Steven,
Neat solution. With a lot more values on the time axis, you will be better off 
with something like:

yrticks<-as.Date(as.character(seq(min(sydf$year1),max(sydf$year1),by=2)),
 "%Y")
axis(1,at=yrticks,labels=format(yrticks,"%Y"))

You probably won't need staxlab for that.

Jim

On Fri, Jul 12, 2019 at 11:55 AM  wrote:
>
> Thanks Jim, that worked.
>
> > I expected that the axis labels would be crowded so I used the plotrix 
> > library to stagger the x-axis labels. Hope this solves your problem.
> I liked how that showed, not overlapping on each other. I wasn't aware of the 
> plotrix library.
>
> In my code I was using plot_ly for visualization, because it looked nicer 
> compared to the simple plot() function, and I have the chart in a Shiny 
> dashboard (RMD file).
> I found in the meantime today some code example for plot_ly and using the 
> same data it looks like this:
> sydf<-read.table(text="year1 monthday rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE,
>  stringsAsFactors=FALSE)
>
> library(plotly)
> plot_ly(sydf,
> x = ~year1,
> y = ~rate,
> type = 'scatter', mode = 'lines') %>%
>   layout(
> xaxis = list(
>   ticktext = sydf$monthday,
>   tickvals = sydf$year1,
>   tickmode = "array",
>   tickangle = 270
> ))
>
> This is where I found about the parameters:
> https://plot.ly/r/tick-formatting/
>
> Now my other challenge is that with my data I have a lot more values on the x 
> axis, and they overlap even when turned vertically. I guess there must be a 
> way of taking a number of values evenly from the list of x axis lables, and 
> use that for the "ticktext" parameter.
> I thought it must be some variation of the seq(from, to, by= ). Can I use 
> that with a list of strings?
>
> Thanks,
> Steven
>
> -Original Message-
> From: Jim Lemon 
> Sent: Thursday, July 11, 2019 7:46 PM
> To: nst...@gmail.com; r-help mailing list 
> Subject: Re: [R] Plotting in R
>
> Hi Steven,
> It is pretty easy, but there are one or two things to watch for.
> First, don't use a hyphen in a field name unless you enclose it in 
> single quotes when extracting it. I've just removed the hyphen in this
> example:
>
> sydf<-read.table(text="year1 monthday rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  199

Re: [R] Plotting in R

2019-07-11 Thread Jim Lemon
Hi Steven,
Neat solution. With a lot more values on the time axis, you will be
better off with something like:

yrticks<-as.Date(as.character(seq(min(sydf$year1),max(sydf$year1),by=2)),
 "%Y")
axis(1,at=yrticks,labels=format(yrticks,"%Y"))

You probably won't need staxlab for that.

Jim

On Fri, Jul 12, 2019 at 11:55 AM  wrote:
>
> Thanks Jim, that worked.
>
> > I expected that the axis labels would be crowded so I used the plotrix 
> > library to stagger the x-axis labels. Hope this solves your problem.
> I liked how that showed, not overlapping on each other. I wasn't aware of the 
> plotrix library.
>
> In my code I was using plot_ly for visualization, because it looked nicer 
> compared to the simple plot() function, and I have the chart in a Shiny 
> dashboard (RMD file).
> I found in the meantime today some code example for plot_ly and using the 
> same data it looks like this:
> sydf<-read.table(text="year1 monthday rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE,
>  stringsAsFactors=FALSE)
>
> library(plotly)
> plot_ly(sydf,
> x = ~year1,
> y = ~rate,
> type = 'scatter', mode = 'lines') %>%
>   layout(
> xaxis = list(
>   ticktext = sydf$monthday,
>   tickvals = sydf$year1,
>   tickmode = "array",
>   tickangle = 270
> ))
>
> This is where I found about the parameters:
> https://plot.ly/r/tick-formatting/
>
> Now my other challenge is that with my data I have a lot more values on the x 
> axis, and they overlap even when turned vertically. I guess there must be a 
> way of taking a number of values evenly from the list of x axis lables, and 
> use that for the "ticktext" parameter.
> I thought it must be some variation of the seq(from, to, by= ). Can I use 
> that with a list of strings?
>
> Thanks,
> Steven
>
> -Original Message-
> From: Jim Lemon 
> Sent: Thursday, July 11, 2019 7:46 PM
> To: nst...@gmail.com; r-help mailing list 
> Subject: Re: [R] Plotting in R
>
> Hi Steven,
> It is pretty easy, but there are one or two things to watch for.
> First, don't use a hyphen in a field name unless you enclose it in single 
> quotes when extracting it. I've just removed the hyphen in this
> example:
>
> sydf<-read.table(text="year1 monthday rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE,
>  stringsAsFactors=FALSE)
> sydf$date<-as.Date(paste(sydf$year1,sydf$monthday),"%Y %m-%d")
> library(plotrix)
> par(mar=c(6,4,4,2))
> plot(sydf$date,sydf$rate,type="b",xaxt="n")
> staxlab(1,at=sydf$date,labels=sydf$monthday)
>
> Note that I have also added the stringsAsFactors argument to prevent 
> monthdate being read as a factor. I expected that the axis labels would be 
> crowded so I used the plotrix library to stagger the x-axis labels. Hope this 
> solves your problem.
>
> Jim
>
> On Fri, Jul 12, 2019 at 1:59 AM  wrote:
> >
> > Hi Jim,
> >
> > Thanks for your email.
> > My question was: how to change the x axis labels without changing the chart.
> > Or is that not possible?
> > Using your example, I added another column:
> > sydf<-read.table(text="year1 month-day rate
> >  1993 05-01 0.608
> >  1994 06-01 0.622
> >  1996 07-01 0.623
> >  1998 08-01 0.647
> >  2000 09-01 0.646
> >  2002 10-01 0.625
> >  2004 11-01 0.628
> >  2006 12-01 0.685
> >  2008 01-01 0.679
> >  2010 02-01 0.595
> >  2012 03-01 0.567
> >  2014 04-01 0.599
> >  2016 05-01 0.642
> >  2018 06-01 0.685",
> >  header=TRUE)
> >
> > How can I show the column "month-day" as labels on the x axis, but
> > still have the plot showing the chart as rate based on year?
> > I tried this:
> > plot(sydf$year,sydf$rate,type="b",
> >  xlab="month-day",ylab="Rate")
> >
> > but this only changes the title of the x axis to "month-day". I want
> > the 

Re: [R] Plotting in R

2019-07-11 Thread nstefi
Thanks Jim, that worked.

> I expected that the axis labels would be crowded so I used the plotrix 
> library to stagger the x-axis labels. Hope this solves your problem.
I liked how that showed, not overlapping on each other. I wasn't aware of the 
plotrix library.

In my code I was using plot_ly for visualization, because it looked nicer 
compared to the simple plot() function, and I have the chart in a Shiny 
dashboard (RMD file).
I found in the meantime today some code example for plot_ly and using the same 
data it looks like this:
sydf<-read.table(text="year1 monthday rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE,
 stringsAsFactors=FALSE)

library(plotly)
plot_ly(sydf,
x = ~year1,
y = ~rate,
type = 'scatter', mode = 'lines') %>%
  layout(
xaxis = list(
  ticktext = sydf$monthday,
  tickvals = sydf$year1,
  tickmode = "array",
  tickangle = 270
))

This is where I found about the parameters:
https://plot.ly/r/tick-formatting/

Now my other challenge is that with my data I have a lot more values on the x 
axis, and they overlap even when turned vertically. I guess there must be a way 
of taking a number of values evenly from the list of x axis lables, and use 
that for the "ticktext" parameter.
I thought it must be some variation of the seq(from, to, by= ). Can I use that 
with a list of strings?

Thanks,
Steven

-Original Message-
From: Jim Lemon  
Sent: Thursday, July 11, 2019 7:46 PM
To: nst...@gmail.com; r-help mailing list 
Subject: Re: [R] Plotting in R

Hi Steven,
It is pretty easy, but there are one or two things to watch for.
First, don't use a hyphen in a field name unless you enclose it in single 
quotes when extracting it. I've just removed the hyphen in this
example:

sydf<-read.table(text="year1 monthday rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE,
 stringsAsFactors=FALSE)
sydf$date<-as.Date(paste(sydf$year1,sydf$monthday),"%Y %m-%d")
library(plotrix)
par(mar=c(6,4,4,2))
plot(sydf$date,sydf$rate,type="b",xaxt="n")
staxlab(1,at=sydf$date,labels=sydf$monthday)

Note that I have also added the stringsAsFactors argument to prevent monthdate 
being read as a factor. I expected that the axis labels would be crowded so I 
used the plotrix library to stagger the x-axis labels. Hope this solves your 
problem.

Jim

On Fri, Jul 12, 2019 at 1:59 AM  wrote:
>
> Hi Jim,
>
> Thanks for your email.
> My question was: how to change the x axis labels without changing the chart.
> Or is that not possible?
> Using your example, I added another column:
> sydf<-read.table(text="year1 month-day rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE)
>
> How can I show the column "month-day" as labels on the x axis, but 
> still have the plot showing the chart as rate based on year?
> I tried this:
> plot(sydf$year,sydf$rate,type="b",
>  xlab="month-day",ylab="Rate")
>
> but this only changes the title of the x axis to "month-day". I want 
> the values on the x axis to show 05-01  06-01, etc.
> Is that possible?
>
> Thanks,
> Steven
>
> -Original Message-
> From: R-help  On Behalf Of Jim Lemon
> Sent: Sunday, July 7, 2019 2:59 AM
> To: Steven Yen ; r-help mailing list 
> 
> Subject: Re: [R] Plotting in R
>
> Hi Steven,
> A basic plot can be displayed like this:
>
> sydf<-read.table(text="year rate
>  1993 0.608
>  1994 0.622
>  1996 0.623
>  1998 0.647
>  2000 0.646
>  2002 0.625
>  2004 0.628
>  2006 0.685
>  2008 0.679
>  2010 0.595
>  2012 0.567
>  2014 0.599
>  2016 0.642
>  2018 0.685",
> header=TRUE)
> plot(sydf$year,sydf$rate,type="b",
> xlab="Year",ylab="Rate")
>
> When you add more years and rates to the data frame, the axes will 
> change to include the years and rates outside the ones in your 
> example. As some have noted, this is a very basic question.
>
> Jim
&g

Re: [R] Plotting in R

2019-07-11 Thread Jim Lemon
Hi Steven,
It is pretty easy, but there are one or two things to watch for.
First, don't use a hyphen in a field name unless you enclose it in
single quotes when extracting it. I've just removed the hyphen in this
example:

sydf<-read.table(text="year1 monthday rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE,
 stringsAsFactors=FALSE)
sydf$date<-as.Date(paste(sydf$year1,sydf$monthday),"%Y %m-%d")
library(plotrix)
par(mar=c(6,4,4,2))
plot(sydf$date,sydf$rate,type="b",xaxt="n")
staxlab(1,at=sydf$date,labels=sydf$monthday)

Note that I have also added the stringsAsFactors argument to prevent
monthdate being read as a factor. I expected that the axis labels
would be crowded so I used the plotrix library to stagger the x-axis
labels. Hope this solves your problem.

Jim

On Fri, Jul 12, 2019 at 1:59 AM  wrote:
>
> Hi Jim,
>
> Thanks for your email.
> My question was: how to change the x axis labels without changing the chart.
> Or is that not possible?
> Using your example, I added another column:
> sydf<-read.table(text="year1 month-day rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE)
>
> How can I show the column "month-day" as labels on the x axis, but still
> have the plot showing the chart as rate based on year?
> I tried this:
> plot(sydf$year,sydf$rate,type="b",
>  xlab="month-day",ylab="Rate")
>
> but this only changes the title of the x axis to "month-day". I want the
> values on the x axis to show 05-01  06-01, etc.
> Is that possible?
>
> Thanks,
> Steven
>
> -Original Message-
> From: R-help  On Behalf Of Jim Lemon
> Sent: Sunday, July 7, 2019 2:59 AM
> To: Steven Yen ; r-help mailing list
> 
> Subject: Re: [R] Plotting in R
>
> Hi Steven,
> A basic plot can be displayed like this:
>
> sydf<-read.table(text="year rate
>  1993 0.608
>  1994 0.622
>  1996 0.623
>  1998 0.647
>  2000 0.646
>  2002 0.625
>  2004 0.628
>  2006 0.685
>  2008 0.679
>  2010 0.595
>  2012 0.567
>  2014 0.599
>  2016 0.642
>  2018 0.685",
> header=TRUE)
> plot(sydf$year,sydf$rate,type="b",
> xlab="Year",ylab="Rate")
>
> When you add more years and rates to the data frame, the axes will change to
> include the years and rates outside the ones in your example. As some have
> noted, this is a very basic question.
>
> Jim
>
> On Sat, Jul 6, 2019 at 11:33 PM Steven Yen  wrote:
> >
> > I have a data frame containing two variables: year and rate (shown below).
> > Which function can I use to plot rate (y-axis) against year (x-axis)?
> > There will be more columns of rate later on.
> > Thank you.
> >
> > year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000
> > 0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010
> > 0.595
> > 11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685
> >
> >
> > --
> > st...@ntu.edu.tw (S.T. Yen)
> >
> >
> >
> > ---
> > This email has been checked for viruses by Avast antivirus software.
> > https://www.avast.com/antivirus
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@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.
>
> __
> R-help@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.
>

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


Re: [R] Plotting in R

2019-07-11 Thread Bert Gunter
?axis
-- And note the examples!

*Please* go through one or more of the web tutorials on plotting in R. I
feel that it is unfair of you to ask for such basic tutorials here when
resources are already available to you (others may disagree, of course). If
you have questions *after* reading, then feel free to ask here.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, Jul 11, 2019 at 8:59 AM  wrote:

> Hi Jim,
>
> Thanks for your email.
> My question was: how to change the x axis labels without changing the
> chart.
> Or is that not possible?
> Using your example, I added another column:
> sydf<-read.table(text="year1 month-day rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE)
>
> How can I show the column "month-day" as labels on the x axis, but still
> have the plot showing the chart as rate based on year?
> I tried this:
> plot(sydf$year,sydf$rate,type="b",
>  xlab="month-day",ylab="Rate")
>
> but this only changes the title of the x axis to "month-day". I want the
> values on the x axis to show 05-01  06-01, etc.
> Is that possible?
>
> Thanks,
> Steven
>
> -Original Message-
> From: R-help  On Behalf Of Jim Lemon
> Sent: Sunday, July 7, 2019 2:59 AM
> To: Steven Yen ; r-help mailing list
> 
> Subject: Re: [R] Plotting in R
>
> Hi Steven,
> A basic plot can be displayed like this:
>
> sydf<-read.table(text="year rate
>  1993 0.608
>  1994 0.622
>  1996 0.623
>  1998 0.647
>  2000 0.646
>  2002 0.625
>  2004 0.628
>  2006 0.685
>  2008 0.679
>  2010 0.595
>  2012 0.567
>  2014 0.599
>  2016 0.642
>  2018 0.685",
> header=TRUE)
> plot(sydf$year,sydf$rate,type="b",
> xlab="Year",ylab="Rate")
>
> When you add more years and rates to the data frame, the axes will change
> to
> include the years and rates outside the ones in your example. As some have
> noted, this is a very basic question.
>
> Jim
>
> On Sat, Jul 6, 2019 at 11:33 PM Steven Yen  wrote:
> >
> > I have a data frame containing two variables: year and rate (shown
> below).
> > Which function can I use to plot rate (y-axis) against year (x-axis)?
> > There will be more columns of rate later on.
> > Thank you.
> >
> > year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000
> > 0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010
> > 0.595
> > 11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685
> >
> >
> > --
> > st...@ntu.edu.tw (S.T. Yen)
> >
> >
> >
> > ---
> > This email has been checked for viruses by Avast antivirus software.
> > https://www.avast.com/antivirus
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@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.
>
> __
> R-help@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.
>
> __
> R-help@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.
>

[[alternative HTML version deleted]]

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


Re: [R] Plotting in R

2019-07-11 Thread David Carlson
There's a typo in the first column name of your data - "year1" should
be "year". Sometimes R will do partial matching and find it, but not
always. Is this closer to what you're looking for?

plot(rate~year, sydf, type="b", xaxt="n", xlab="Month-Day")
axis(1, sydf$year, sydf$month.day)

This will probably leave out some labels because there is not enough
room. You can print the labels smaller:

axis(1, sydf$year, sydf$month.day, cex.axis=.75)

or rotate them 90 degrees:

axis(1, sydf$year, sydf$month.day, las=2)'


David L Carlson
Department of Anthropology
Texas A&M University

On Thu, Jul 11, 2019 at 10:59 AM  wrote:
>
> Hi Jim,
>
> Thanks for your email.
> My question was: how to change the x axis labels without changing the chart.
> Or is that not possible?
> Using your example, I added another column:
> sydf<-read.table(text="year1 month-day rate
>  1993 05-01 0.608
>  1994 06-01 0.622
>  1996 07-01 0.623
>  1998 08-01 0.647
>  2000 09-01 0.646
>  2002 10-01 0.625
>  2004 11-01 0.628
>  2006 12-01 0.685
>  2008 01-01 0.679
>  2010 02-01 0.595
>  2012 03-01 0.567
>  2014 04-01 0.599
>  2016 05-01 0.642
>  2018 06-01 0.685",
>  header=TRUE)
>
> How can I show the column "month-day" as labels on the x axis, but still
> have the plot showing the chart as rate based on year?
> I tried this:
> plot(sydf$year,sydf$rate,type="b",
>  xlab="month-day",ylab="Rate")
>
> but this only changes the title of the x axis to "month-day". I want the
> values on the x axis to show 05-01  06-01, etc.
> Is that possible?
>
> Thanks,
> Steven
>
> -Original Message-
> From: R-help  On Behalf Of Jim Lemon
> Sent: Sunday, July 7, 2019 2:59 AM
> To: Steven Yen ; r-help mailing list
> 
> Subject: Re: [R] Plotting in R
>
> Hi Steven,
> A basic plot can be displayed like this:
>
> sydf<-read.table(text="year rate
>  1993 0.608
>  1994 0.622
>  1996 0.623
>  1998 0.647
>  2000 0.646
>  2002 0.625
>  2004 0.628
>  2006 0.685
>  2008 0.679
>  2010 0.595
>  2012 0.567
>  2014 0.599
>  2016 0.642
>  2018 0.685",
> header=TRUE)
> plot(sydf$year,sydf$rate,type="b",
> xlab="Year",ylab="Rate")
>
> When you add more years and rates to the data frame, the axes will change to
> include the years and rates outside the ones in your example. As some have
> noted, this is a very basic question.
>
> Jim
>
> On Sat, Jul 6, 2019 at 11:33 PM Steven Yen  wrote:
> >
> > I have a data frame containing two variables: year and rate (shown below).
> > Which function can I use to plot rate (y-axis) against year (x-axis)?
> > There will be more columns of rate later on.
> > Thank you.
> >
> > year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000
> > 0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010
> > 0.595
> > 11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685
> >
> >
> > --
> > st...@ntu.edu.tw (S.T. Yen)
> >
> >
> >
> > ---
> > This email has been checked for viruses by Avast antivirus software.
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__www.avast.com_antivirus&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=VAaHUElasUXjP9TzIcfIrXdkDpHnJBBZ9Q1u5LcXz9s&m=23NXOUvOhO2PZnfjNak-qt7MYdttWJs3O634wqpLE4A&s=Psw17kUMNN42CxAcroDYQ-fU3UzzQlXgwSdzbvb23Lc&e=
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=VAaHUElasUXjP9TzIcfIrXdkDpHnJBBZ9Q1u5LcXz9s&m=23NXOUvOhO2PZnfjNak-qt7MYdttWJs3O634wqpLE4A&s=uruiNGrA6F82mRo7L3az2sIVhJv58RS7O3bC9JxKfKc&e=
> > PLEASE do read the posting guide
> > https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=VAaHUElasUXjP9TzIcfIrXdkDpHnJBBZ9Q1u5LcXz9s&m=23NXOUvOhO2PZnfjNak-qt7MYdttWJs3O634wqpLE4A&s=Ic4wt1QLwaqf-_Ncfy9aN_dp_fqkFLoZl4zwa2Xj-r4&e=
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=VAaHUElasUXjP9TzIcf

Re: [R] Plotting in R

2019-07-11 Thread nstefi
Sorry Jim, I saw that you answered to the other Steven.
I had a question and nobody responded to that yet, I thought you responded
to me.
I searched for mine and your email came up, but I realize the subject line
is different. My question was:
"How to change x axes labels in plot_ly?"

-Original Message-
From: nst...@gmail.com  
Sent: Thursday, July 11, 2019 11:59 AM
To: 'Jim Lemon' ; 'Steven Yen' ;
'r-help mailing list' 
Subject: RE: [R] Plotting in R

Hi Jim,

Thanks for your email.
My question was: how to change the x axis labels without changing the chart.
Or is that not possible?
Using your example, I added another column:
sydf<-read.table(text="year1 month-day rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE)

How can I show the column "month-day" as labels on the x axis, but still
have the plot showing the chart as rate based on year?
I tried this:
plot(sydf$year,sydf$rate,type="b",
 xlab="month-day",ylab="Rate")

but this only changes the title of the x axis to "month-day". I want the
values on the x axis to show 05-01  06-01, etc.
Is that possible?

Thanks,
Steven

-Original Message-
From: R-help  On Behalf Of Jim Lemon
Sent: Sunday, July 7, 2019 2:59 AM
To: Steven Yen ; r-help mailing list

Subject: Re: [R] Plotting in R

Hi Steven,
A basic plot can be displayed like this:

sydf<-read.table(text="year rate
 1993 0.608
 1994 0.622
 1996 0.623
 1998 0.647
 2000 0.646
 2002 0.625
 2004 0.628
 2006 0.685
 2008 0.679
 2010 0.595
 2012 0.567
 2014 0.599
 2016 0.642
 2018 0.685",
header=TRUE)
plot(sydf$year,sydf$rate,type="b",
xlab="Year",ylab="Rate")

When you add more years and rates to the data frame, the axes will change to
include the years and rates outside the ones in your example. As some have
noted, this is a very basic question.

Jim

On Sat, Jul 6, 2019 at 11:33 PM Steven Yen  wrote:
>
> I have a data frame containing two variables: year and rate (shown below).
> Which function can I use to plot rate (y-axis) against year (x-axis)?
> There will be more columns of rate later on.
> Thank you.
>
> year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000
> 0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010
> 0.595
> 11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685
>
>
> --
> st...@ntu.edu.tw (S.T. Yen)
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> [[alternative HTML version deleted]]
>
> __
> R-help@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.

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

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


Re: [R] Plotting in R

2019-07-11 Thread nstefi
Hi Jim,

Thanks for your email.
My question was: how to change the x axis labels without changing the chart.
Or is that not possible?
Using your example, I added another column:
sydf<-read.table(text="year1 month-day rate
 1993 05-01 0.608
 1994 06-01 0.622
 1996 07-01 0.623
 1998 08-01 0.647
 2000 09-01 0.646
 2002 10-01 0.625
 2004 11-01 0.628
 2006 12-01 0.685
 2008 01-01 0.679
 2010 02-01 0.595
 2012 03-01 0.567
 2014 04-01 0.599
 2016 05-01 0.642
 2018 06-01 0.685",
 header=TRUE)

How can I show the column "month-day" as labels on the x axis, but still
have the plot showing the chart as rate based on year?
I tried this:
plot(sydf$year,sydf$rate,type="b",
 xlab="month-day",ylab="Rate")

but this only changes the title of the x axis to "month-day". I want the
values on the x axis to show 05-01  06-01, etc.
Is that possible?

Thanks,
Steven

-Original Message-
From: R-help  On Behalf Of Jim Lemon
Sent: Sunday, July 7, 2019 2:59 AM
To: Steven Yen ; r-help mailing list

Subject: Re: [R] Plotting in R

Hi Steven,
A basic plot can be displayed like this:

sydf<-read.table(text="year rate
 1993 0.608
 1994 0.622
 1996 0.623
 1998 0.647
 2000 0.646
 2002 0.625
 2004 0.628
 2006 0.685
 2008 0.679
 2010 0.595
 2012 0.567
 2014 0.599
 2016 0.642
 2018 0.685",
header=TRUE)
plot(sydf$year,sydf$rate,type="b",
xlab="Year",ylab="Rate")

When you add more years and rates to the data frame, the axes will change to
include the years and rates outside the ones in your example. As some have
noted, this is a very basic question.

Jim

On Sat, Jul 6, 2019 at 11:33 PM Steven Yen  wrote:
>
> I have a data frame containing two variables: year and rate (shown below).
> Which function can I use to plot rate (y-axis) against year (x-axis)?
> There will be more columns of rate later on.
> Thank you.
>
> year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000
> 0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010 
> 0.595
> 11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685
>
>
> --
> st...@ntu.edu.tw (S.T. Yen)
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> [[alternative HTML version deleted]]
>
> __
> R-help@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.

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

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


Re: [R] Plotting in R

2019-07-07 Thread Jim Lemon
Hi Steven,
A basic plot can be displayed like this:

sydf<-read.table(text="year rate
 1993 0.608
 1994 0.622
 1996 0.623
 1998 0.647
 2000 0.646
 2002 0.625
 2004 0.628
 2006 0.685
 2008 0.679
 2010 0.595
 2012 0.567
 2014 0.599
 2016 0.642
 2018 0.685",
header=TRUE)
plot(sydf$year,sydf$rate,type="b",
xlab="Year",ylab="Rate")

When you add more years and rates to the data frame, the axes will
change to include the years and rates outside the ones in your
example. As some have noted, this is a very basic question.

Jim

On Sat, Jul 6, 2019 at 11:33 PM Steven Yen  wrote:
>
> I have a data frame containing two variables: year and rate (shown below).
> Which function can I use to plot rate (y-axis) against year (x-axis)?
> There will be more columns of rate later on.
> Thank you.
>
> year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000
> 0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010 0.595
> 11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685
>
>
> --
> st...@ntu.edu.tw (S.T. Yen)
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> [[alternative HTML version deleted]]
>
> __
> R-help@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.

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


[R] Plotting in R

2019-07-06 Thread Steven Yen
I have a data frame containing two variables: year and rate (shown below).
Which function can I use to plot rate (y-axis) against year (x-axis)?
There will be more columns of rate later on.
Thank you.

year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000 
0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010 0.595 
11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

[[alternative HTML version deleted]]

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


Re: [R] Plotting in R

2019-07-06 Thread John Kane
Please do not post in html.

You could use ggplot to do this. But you need to do a bit of work yourself.

On Sat, 6 Jul 2019 at 10:51,  wrote:
>
> Hello,
>
> Please don't post inHTML, the data is unreadable.
>
> As for the question, it is very basic. try any of
>
>
> plot(rate ~ year, data = df)# df is your dataframe
> plot(df$year, df$rate)
>
>
> Then read ?plot and ?par to see how to customize the graph, by
> changing the plot type, how to add colors, etc.
>
> Hope this helps,
>
> Rui Barradas
>
>
>
> Citando Steven Yen :
>
> > I have a data frame containing two variables: year and rate (shown below).
> > Which function can I use to plot rate (y-axis) against year (x-axis)?
> > There will be more columns of rate later on.
> > Thank you.
> >
> > year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000
> > 0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010 0.595
> > 11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685
> >
> >
> > --
> > st...@ntu.edu.tw (S.T. Yen)
> >
> >
> >
> > ---
> > This email has been checked for viruses by Avast antivirus software.
> > https://www.avast.com/antivirus
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@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.
>
> __
> R-help@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.



-- 
John Kane
Kingston ON Canada

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


Re: [R] Plotting in R

2019-07-06 Thread ruipbarradas

Hello,

Please don't post inHTML, the data is unreadable.

As for the question, it is very basic. try any of


plot(rate ~ year, data = df)# df is your dataframe
plot(df$year, df$rate)


Then read ?plot and ?par to see how to customize the graph, by  
changing the plot type, how to add colors, etc.


Hope this helps,

Rui Barradas



Citando Steven Yen :


I have a data frame containing two variables: year and rate (shown below).
Which function can I use to plot rate (y-axis) against year (x-axis)?
There will be more columns of rate later on.
Thank you.

year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000
0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010 0.595
11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685


--
st...@ntu.edu.tw (S.T. Yen)



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

[[alternative HTML version deleted]]

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


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


Re: [R] Plotting in R

2019-07-06 Thread Bert Gunter
Oh come on!

Please do your homework and spend time with some basic R tutorials, one of
which ships with R, although there are tons more good ones on the web.

And FYI, there are *several* different plotting systems that one can access
using various R packages. Probably the most basic -- but still quite
powerful -- uses the function ?plot  !!


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sat, Jul 6, 2019 at 6:33 AM Steven Yen  wrote:

> I have a data frame containing two variables: year and rate (shown below).
> Which function can I use to plot rate (y-axis) against year (x-axis)?
> There will be more columns of rate later on.
> Thank you.
>
> year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000
> 0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010 0.595
> 11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685
>
>
> --
> st...@ntu.edu.tw (S.T. Yen)
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> [[alternative HTML version deleted]]
>
> __
> R-help@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.
>

[[alternative HTML version deleted]]

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


[R] Plotting in R

2019-07-06 Thread Steven Yen
I have a data frame containing two variables: year and rate (shown below).
Which function can I use to plot rate (y-axis) against year (x-axis)?
There will be more columns of rate later on.
Thank you.

year rate 1 1993 0.608 2 1994 0.622 3 1996 0.623 4 1998 0.647 5 2000 
0.646 6 2002 0.625 7 2004 0.628 8 2006 0.685 9 2008 0.679 10 2010 0.595 
11 2012 0.567 12 2014 0.599 13 2016 0.642 14 2018 0.685


-- 
st...@ntu.edu.tw (S.T. Yen)



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

[[alternative HTML version deleted]]

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


Re: [R] plotting in R

2010-01-15 Thread jim holtman
Could you at least show how you were plotting it when you got the error.  It
is not clear what you are trying to plot.  The statement
plot("insert_file_name_here") did not make sense.

On Fri, Jan 15, 2010 at 5:48 PM, cobbler_squad  wrote:

>
> Hello,
>
> As a result of running linear discriminant analysis, I need to be able to
> plot the resulting file. I am not sure what the best way to do this is. So
> far I have tried regular plot("insert_file_name_here") command but the
> error
> it gives me is Error in plot.new() : figure margins too large
>
> here is sample LDA code I am working with 
>
>
> library(MASS)
>
> example <- data.frame(as.matrix(t(read.table(file="trial.txt"))),syll =
> c(rep("one",3),rep("two",3),rep("three",3)))
>
> table(lda(syll ~ ., example, CV =TRUE)$class,example$syll)
>
> what is the best way to plot the example file?
>
> sample "trial.txt" contents...
>
> 0.004764-0.008445   0.0150450.0146580.004095
>  -0.001678   0.011231-0.003612
> 0.011409
> 0.010761-0.009416   0.0060080.001603-0.004214
> -0.015367   0.014689-0.003415
> -0.001983
> 0.004339-0.018069   -0.001695   0.0026320.011438
>  -0.013996   0.012927-0.002597
> -0.005044
>
> thank you for your help.
> --
> View this message in context:
> http://n4.nabble.com/plotting-in-R-tp1015355p1015355.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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

[[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.


[R] plotting in R

2010-01-15 Thread cobbler_squad

Hello,

As a result of running linear discriminant analysis, I need to be able to
plot the resulting file. I am not sure what the best way to do this is. So
far I have tried regular plot("insert_file_name_here") command but the error
it gives me is Error in plot.new() : figure margins too large

here is sample LDA code I am working with 


library(MASS)

example <- data.frame(as.matrix(t(read.table(file="trial.txt"))),syll =
c(rep("one",3),rep("two",3),rep("three",3)))

table(lda(syll ~ ., example, CV =TRUE)$class,example$syll)

what is the best way to plot the example file?

sample "trial.txt" contents...

0.004764-0.008445   0.0150450.0146580.004095
-0.001678   0.011231-0.003612
0.011409
0.010761-0.009416   0.0060080.001603-0.004214   
-0.015367   0.014689-0.003415
-0.001983   
0.004339-0.018069   -0.001695   0.0026320.011438
-0.013996   0.012927-0.002597
-0.005044   

thank you for your help.
-- 
View this message in context: 
http://n4.nabble.com/plotting-in-R-tp1015355p1015355.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.