
12

Dear R users,
I have one excel file with 5 sheets. The no. of columns vary for each
sheet. The 1st sheet consists of 38 columns. So, I want to plot 38 separate
line charts and arrange them in par(mfrow = c(4, 10)) order. Please suggest
me how to do this. I have tried with the following code by running a loop
inside of a sheet, but it is not working. Further, I want to run loops for
each sheet.
par(mfrow = c(4, 10))
loop.vector < 1:38
for (i in loop.vector)
x < JJ[,i]
library(ggplot2)
library(cowplot)
plot.mpg < ggplot(mpg, aes(x,
main = paste ("country", i),
xlab = "Scores",
xlim = c(1,500)
y = colnames[i,], colour = factor(cyl))) +
geom_line(size=2.5)
save_plot("mpg.png", plot.mpg,
base_aspect_ratio = 1.3)
I want to give my X axis name as scores of (1,500) and Y axis as the
particular column names for all graphs.
Please suggest.
Thanks in advance.

*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
[image: Mailtrack]
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
11/20/18,
11:49:42 PM
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


You need to do some studying! ggplot is built on the grid graphics system,
which is separate from the base graphics system. The par() function is part
of the *base* graphics system and so ignored by ggplot.
Others may offer you solutions using the "faceting" functionality of
ggplot. But you really should reading up on this on your own. There are
many good tutorials on ggplot2 that are available on the web.
 Bert
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 Tue, Nov 20, 2018 at 10:19 AM Subhamitra Patra <
[hidden email]> wrote:
> Dear R users,
>
> I have one excel file with 5 sheets. The no. of columns vary for each
> sheet. The 1st sheet consists of 38 columns. So, I want to plot 38 separate
> line charts and arrange them in par(mfrow = c(4, 10)) order. Please suggest
> me how to do this. I have tried with the following code by running a loop
> inside of a sheet, but it is not working. Further, I want to run loops for
> each sheet.
>
> par(mfrow = c(4, 10))
> loop.vector < 1:38
> for (i in loop.vector)
> x < JJ[,i]
> library(ggplot2)
> library(cowplot)
> plot.mpg < ggplot(mpg, aes(x,
> main = paste ("country", i),
> xlab = "Scores",
> xlim = c(1,500)
> y = colnames[i,], colour = factor(cyl))) +
> geom_line(size=2.5)
> save_plot("mpg.png", plot.mpg,
> base_aspect_ratio = 1.3)
>
> I want to give my X axis name as scores of (1,500) and Y axis as the
> particular column names for all graphs.
>
> Please suggest.
>
> Thanks in advance.
>
> 
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
>
>
>
>
>
>
>
> [image: Mailtrack]
> <
> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> >
> Sender
> notified by
> Mailtrack
> <
> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> >
> 11/20/18,
> 11:49:42 PM
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi Subhamitra,
As Bert noted, you are mixing base and grid graphics. Here is a simple
way to get a plot like what you described. It will probably take more
work to find what you actually do want and discover how to get it.
for(i in 1:38) assign(paste0("veh",i),rep(sample(10:35,1),10)+runif(10,4,4))
mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,
veh11,veh12,veh13,veh14,veh15,veh16,veh17,veh18,veh19,veh20,
veh21,veh22,veh23,veh24,veh25,veh26,veh27,veh28,veh29,veh30,
veh31,veh32,veh33,veh34,veh35,veh36,veh37,veh38)
pdf("mpg.pdf",width=30,height=12)
par(mfrow=c(4,10))
for(i in 1:38)
plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
ylab=names(mpg)[i],main="MPG by distance")
dev.off()
Jim
On Wed, Nov 21, 2018 at 5:19 AM Subhamitra Patra
< [hidden email]> wrote:
>
> Dear R users,
>
> I have one excel file with 5 sheets. The no. of columns vary for each
> sheet. The 1st sheet consists of 38 columns. So, I want to plot 38 separate
> line charts and arrange them in par(mfrow = c(4, 10)) order. Please suggest
> me how to do this. I have tried with the following code by running a loop
> inside of a sheet, but it is not working. Further, I want to run loops for
> each sheet.
>
> par(mfrow = c(4, 10))
> loop.vector < 1:38
> for (i in loop.vector)
> x < JJ[,i]
> library(ggplot2)
> library(cowplot)
> plot.mpg < ggplot(mpg, aes(x,
> main = paste ("country", i),
> xlab = "Scores",
> xlim = c(1,500)
> y = colnames[i,], colour = factor(cyl))) +
> geom_line(size=2.5)
> save_plot("mpg.png", plot.mpg,
> base_aspect_ratio = 1.3)
>
> I want to give my X axis name as scores of (1,500) and Y axis as the
> particular column names for all graphs.
>
> Please suggest.
>
> Thanks in advance.
>
> 
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
>
>
>
>
>
>
>
> [image: Mailtrack]
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
> Sender
> notified by
> Mailtrack
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
> 11/20/18,
> 11:49:42 PM
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hello Sir,
Thanks, I'll check them out.
But, I am not understanding 2 points of your suggestion.
1. In the line,* "*for(i in 1:38) assign(paste0("veh",i),rep(sam
ple(10:35,1),10)+runif(10,4,*4))", *what veh, rep(sample(10:35,1),10)
+runif(10,4,4)) indicate? Here veh indicates columns right?
*2. In the
line, mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,*
* veh11,veh12,veh13,veh14,**veh15,veh16,veh17,veh18,veh19,**veh20,*
* veh21,veh22,veh23,veh24,**veh25,veh26,veh27,veh28,veh29,**veh30,*
* veh31,veh32,veh33,veh34,**veh35,veh36,veh37,veh38) ** , *veh[i]
indicates column sequence, right? I need to give column names as the header
of their respective graphs. Please suggest me How to add this?
I am very new to R and therefore asking you these queries which might be
simple for you.
I expect positive help from you.
Thanks for your kind help.
[image: Mailtrack]
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
11/21/18,
7:02:18 AM
On Wed, Nov 21, 2018 at 4:38 AM Jim Lemon < [hidden email]> wrote:
> Hi Subhamitra,
> As Bert noted, you are mixing base and grid graphics. Here is a simple
> way to get a plot like what you described. It will probably take more
> work to find what you actually do want and discover how to get it.
>
> for(i in 1:38)
> assign(paste0("veh",i),rep(sample(10:35,1),10)+runif(10,4,4))
> mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,
> veh11,veh12,veh13,veh14,veh15,veh16,veh17,veh18,veh19,veh20,
> veh21,veh22,veh23,veh24,veh25,veh26,veh27,veh28,veh29,veh30,
> veh31,veh32,veh33,veh34,veh35,veh36,veh37,veh38)
> pdf("mpg.pdf",width=30,height=12)
> par(mfrow=c(4,10))
> for(i in 1:38)
> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
> ylab=names(mpg)[i],main="MPG by distance")
> dev.off()
>
> Jim
>
> On Wed, Nov 21, 2018 at 5:19 AM Subhamitra Patra
> < [hidden email]> wrote:
> >
> > Dear R users,
> >
> > I have one excel file with 5 sheets. The no. of columns vary for each
> > sheet. The 1st sheet consists of 38 columns. So, I want to plot 38
> separate
> > line charts and arrange them in par(mfrow = c(4, 10)) order. Please
> suggest
> > me how to do this. I have tried with the following code by running a loop
> > inside of a sheet, but it is not working. Further, I want to run loops
> for
> > each sheet.
> >
> > par(mfrow = c(4, 10))
> > loop.vector < 1:38
> > for (i in loop.vector)
> > x < JJ[,i]
> > library(ggplot2)
> > library(cowplot)
> > plot.mpg < ggplot(mpg, aes(x,
> > main = paste ("country", i),
> > xlab = "Scores",
> > xlim = c(1,500)
> > y = colnames[i,], colour = factor(cyl))) +
> > geom_line(size=2.5)
> > save_plot("mpg.png", plot.mpg,
> > base_aspect_ratio = 1.3)
> >
> > I want to give my X axis name as scores of (1,500) and Y axis as the
> > particular column names for all graphs.
> >
> > Please suggest.
> >
> > Thanks in advance.
> >
> > 
> > *Best Regards,*
> > *Subhamitra Patra*
> > *Phd. Research Scholar*
> > *Department of Humanities and Social Sciences*
> > *Indian Institute of Technology, Kharagpur*
> > *INDIA*
> >
> >
> >
> >
> >
> >
> >
> >
> > [image: Mailtrack]
> > <
> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> >
> > Sender
> > notified by
> > Mailtrack
> > <
> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> >
> > 11/20/18,
> > 11:49:42 PM
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/rhelp> > PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> > and provide commented, minimal, selfcontained, reproducible code.
>

*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi Subhamitra,
1. Here I manufacture some data so that the example is "reproducible", that
is anyone can run the code and get the same output that I do. Yes,
veh1...veh38 are the names of the variables.
2. Here I join the 38 variables I created into a data frame, which I think
is the input for your plotting routine. This names of the columns of the
data frame become the names of the variables.
When you say that you want the column names as the "header" (title) of each
plot, I think if you change the plotting loop to this:
pdf("mpg.pdf",width=30,height=12)
par(mfrow=c(4,10))
for(i in 1:38)
plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
ylab="MPG",main=names(mpg)[i])
dev.off()
you will get what you requested. Remember that I have done this in base
graphics, not ggplot.
Jim
On Wed, Nov 21, 2018 at 12:37 PM Subhamitra Patra <
[hidden email]> wrote:
> Hello Sir,
>
> Thanks, I'll check them out.
>
> But, I am not understanding 2 points of your suggestion.
>
> 1. In the line,* "*for(i in 1:38) assign(paste0("veh",i),rep(sam
> ple(10:35,1),10)+runif(10,4,*4))", *what veh, rep(sample(10:35,1),10)
> +runif(10,4,4)) indicate? Here veh indicates columns right?
> *2. In the
> line, mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,*
> * veh11,veh12,veh13,veh14,**veh15,veh16,veh17,veh18,veh19,**veh20,*
> * veh21,veh22,veh23,veh24,**veh25,veh26,veh27,veh28,veh29,**veh30,*
> * veh31,veh32,veh33,veh34,**veh35,veh36,veh37,veh38) ** , *veh[i]
> indicates column sequence, right? I need to give column names as the header
> of their respective graphs. Please suggest me How to add this?
>
>
> I am very new to R and therefore asking you these queries which might be
> simple for you.
>
> I expect positive help from you.
>
> Thanks for your kind help.
> [image: Mailtrack]
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
> notified by
> Mailtrack
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
> 7:02:18 AM
>
>
> On Wed, Nov 21, 2018 at 4:38 AM Jim Lemon < [hidden email]> wrote:
>
>> Hi Subhamitra,
>> As Bert noted, you are mixing base and grid graphics. Here is a simple
>> way to get a plot like what you described. It will probably take more
>> work to find what you actually do want and discover how to get it.
>>
>> for(i in 1:38)
>> assign(paste0("veh",i),rep(sample(10:35,1),10)+runif(10,4,4))
>> mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,
>> veh11,veh12,veh13,veh14,veh15,veh16,veh17,veh18,veh19,veh20,
>> veh21,veh22,veh23,veh24,veh25,veh26,veh27,veh28,veh29,veh30,
>> veh31,veh32,veh33,veh34,veh35,veh36,veh37,veh38)
>> pdf("mpg.pdf",width=30,height=12)
>> par(mfrow=c(4,10))
>> for(i in 1:38)
>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>> ylab=names(mpg)[i],main="MPG by distance")
>> dev.off()
>>
>> Jim
>>
>> On Wed, Nov 21, 2018 at 5:19 AM Subhamitra Patra
>> < [hidden email]> wrote:
>> >
>> > Dear R users,
>> >
>> > I have one excel file with 5 sheets. The no. of columns vary for each
>> > sheet. The 1st sheet consists of 38 columns. So, I want to plot 38
>> separate
>> > line charts and arrange them in par(mfrow = c(4, 10)) order. Please
>> suggest
>> > me how to do this. I have tried with the following code by running a
>> loop
>> > inside of a sheet, but it is not working. Further, I want to run loops
>> for
>> > each sheet.
>> >
>> > par(mfrow = c(4, 10))
>> > loop.vector < 1:38
>> > for (i in loop.vector)
>> > x < JJ[,i]
>> > library(ggplot2)
>> > library(cowplot)
>> > plot.mpg < ggplot(mpg, aes(x,
>> > main = paste ("country", i),
>> > xlab = "Scores",
>> > xlim = c(1,500)
>> > y = colnames[i,], colour = factor(cyl))) +
>> > geom_line(size=2.5)
>> > save_plot("mpg.png", plot.mpg,
>> > base_aspect_ratio = 1.3)
>> >
>> > I want to give my X axis name as scores of (1,500) and Y axis as the
>> > particular column names for all graphs.
>> >
>> > Please suggest.
>> >
>> > Thanks in advance.
>> >
>> > 
>> > *Best Regards,*
>> > *Subhamitra Patra*
>> > *Phd. Research Scholar*
>> > *Department of Humanities and Social Sciences*
>> > *Indian Institute of Technology, Kharagpur*
>> > *INDIA*
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > [image: Mailtrack]
>> > <
>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>> >
>> > Sender
>> > notified by
>> > Mailtrack
>> > <
>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>> >
>> > 11/20/18,
>> > 11:49:42 PM
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/rhelp>> > PLEASE do read the posting guide
>> http://www.Rproject.org/postingguide.html>> > and provide commented, minimal, selfcontained, reproducible code.
>>
>
>
> 
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hello Sir,
Thanks, now I understood and will check them out.
One more thing I want to ask that I have 1 excel file with multiple (i.e.
12 sheets). Each sheet contains different number of columns, for instance,
1st sheet contains 38 columns, 2nd sheet contains 10 columns, Third 2
columns, 4th 1 column and so on. Actually, due to some missing observations
in these columns, I couldn't add them in 1 sheet.
As you suggested the below code in the last mail,
par(mfrow=c(4,10))
for(i in 1:38)
plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
ylab="MPG",main=names(mpg)[i])
dev.off()
Do I need to run the code separately for each sheet?
Actually, in par (mfrow=c(4,10)), the plot for 38 columns will be added,
the space for extra 2 will remain as empty. So, I thought to add plots for
the columns from the next sheet in those emptied space.
Is there any way that I can add plots from the next sheets of the same
excel file in the emptied space? In other words, Is there any way to append
plots from all sheets?
Kindly help a new R learner Sir for which I shall be always grateful to you.
Thank you very much for your kind help.
[image: Mailtrack]
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
11/21/18,
7:30:30 AM
On Wed, Nov 21, 2018 at 7:17 AM Jim Lemon < [hidden email]> wrote:
> Hi Subhamitra,
>
> 1. Here I manufacture some data so that the example is "reproducible",
> that is anyone can run the code and get the same output that I do. Yes,
> veh1...veh38 are the names of the variables.
>
> 2. Here I join the 38 variables I created into a data frame, which I think
> is the input for your plotting routine. This names of the columns of the
> data frame become the names of the variables.
>
> When you say that you want the column names as the "header" (title) of
> each plot, I think if you change the plotting loop to this:
>
> pdf("mpg.pdf",width=30,height=12)
> par(mfrow=c(4,10))
> for(i in 1:38)
> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
> ylab="MPG",main=names(mpg)[i])
> dev.off()
>
> you will get what you requested. Remember that I have done this in base
> graphics, not ggplot.
>
> Jim
>
> On Wed, Nov 21, 2018 at 12:37 PM Subhamitra Patra <
> [hidden email]> wrote:
>
>> Hello Sir,
>>
>> Thanks, I'll check them out.
>>
>> But, I am not understanding 2 points of your suggestion.
>>
>> 1. In the line,* "*for(i in 1:38) assign(paste0("veh",i),rep(sam
>> ple(10:35,1),10)+runif(10,4,*4))", *what veh, rep(sample(10:35,1),10)
>> +runif(10,4,4)) indicate? Here veh indicates columns right?
>> *2. In the
>> line, mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,*
>> * veh11,veh12,veh13,veh14,**veh15,veh16,veh17,veh18,veh19,**veh20,*
>> * veh21,veh22,veh23,veh24,**veh25,veh26,veh27,veh28,veh29,**veh30,*
>> * veh31,veh32,veh33,veh34,**veh35,veh36,veh37,veh38) ** , *veh[i]
>> indicates column sequence, right? I need to give column names as the header
>> of their respective graphs. Please suggest me How to add this?
>>
>>
>> I am very new to R and therefore asking you these queries which might be
>> simple for you.
>>
>> I expect positive help from you.
>>
>> Thanks for your kind help.
>> [image: Mailtrack]
>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>> notified by
>> Mailtrack
>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>> 7:02:18 AM
>>
>>
>> On Wed, Nov 21, 2018 at 4:38 AM Jim Lemon < [hidden email]> wrote:
>>
>>> Hi Subhamitra,
>>> As Bert noted, you are mixing base and grid graphics. Here is a simple
>>> way to get a plot like what you described. It will probably take more
>>> work to find what you actually do want and discover how to get it.
>>>
>>> for(i in 1:38)
>>> assign(paste0("veh",i),rep(sample(10:35,1),10)+runif(10,4,4))
>>> mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,
>>> veh11,veh12,veh13,veh14,veh15,veh16,veh17,veh18,veh19,veh20,
>>> veh21,veh22,veh23,veh24,veh25,veh26,veh27,veh28,veh29,veh30,
>>> veh31,veh32,veh33,veh34,veh35,veh36,veh37,veh38)
>>> pdf("mpg.pdf",width=30,height=12)
>>> par(mfrow=c(4,10))
>>> for(i in 1:38)
>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>> ylab=names(mpg)[i],main="MPG by distance")
>>> dev.off()
>>>
>>> Jim
>>>
>>> On Wed, Nov 21, 2018 at 5:19 AM Subhamitra Patra
>>> < [hidden email]> wrote:
>>> >
>>> > Dear R users,
>>> >
>>> > I have one excel file with 5 sheets. The no. of columns vary for each
>>> > sheet. The 1st sheet consists of 38 columns. So, I want to plot 38
>>> separate
>>> > line charts and arrange them in par(mfrow = c(4, 10)) order. Please
>>> suggest
>>> > me how to do this. I have tried with the following code by running a
>>> loop
>>> > inside of a sheet, but it is not working. Further, I want to run loops
>>> for
>>> > each sheet.
>>> >
>>> > par(mfrow = c(4, 10))
>>> > loop.vector < 1:38
>>> > for (i in loop.vector)
>>> > x < JJ[,i]
>>> > library(ggplot2)
>>> > library(cowplot)
>>> > plot.mpg < ggplot(mpg, aes(x,
>>> > main = paste ("country", i),
>>> > xlab = "Scores",
>>> > xlim = c(1,500)
>>> > y = colnames[i,], colour = factor(cyl)))
>>> +
>>> > geom_line(size=2.5)
>>> > save_plot("mpg.png", plot.mpg,
>>> > base_aspect_ratio = 1.3)
>>> >
>>> > I want to give my X axis name as scores of (1,500) and Y axis as the
>>> > particular column names for all graphs.
>>> >
>>> > Please suggest.
>>> >
>>> > Thanks in advance.
>>> >
>>> > 
>>> > *Best Regards,*
>>> > *Subhamitra Patra*
>>> > *Phd. Research Scholar*
>>> > *Department of Humanities and Social Sciences*
>>> > *Indian Institute of Technology, Kharagpur*
>>> > *INDIA*
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > [image: Mailtrack]
>>> > <
>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>> >
>>> > Sender
>>> > notified by
>>> > Mailtrack
>>> > <
>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>> >
>>> > 11/20/18,
>>> > 11:49:42 PM
>>> >
>>> > [[alternative HTML version deleted]]
>>> >
>>> > ______________________________________________
>>> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
>>> > https://stat.ethz.ch/mailman/listinfo/rhelp>>> > PLEASE do read the posting guide
>>> http://www.Rproject.org/postingguide.html>>> > and provide commented, minimal, selfcontained, reproducible code.
>>>
>>
>>
>> 
>> *Best Regards,*
>> *Subhamitra Patra*
>> *Phd. Research Scholar*
>> *Department of Humanities and Social Sciences*
>> *Indian Institute of Technology, Kharagpur*
>> *INDIA*
>>
>

*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


I assume that you are importing the Excel sheets separately. When you
import a sheet, you can get the number of columns with this:
ncol(<name of data frame>)
Using the data frame "mpg" that I created:
ncolumns<ncol(mpg)
ncolumns
[1] 38
You can then substitute "ncolumns" each time you import another sheet. How
you want to deal with the varying numbers of columns you will get is
another matter. One way is to work out the total number of plots you want
and put them all onto one PDF page. Say you have 50 plots overall. You
could start a very big PDF page:
pdf("allplots.pdf",width=30,height=15)
par(mfrow=c(5,10))
# import your first sheet here (38 columns)
ncolumns<ncol(mpg)
for(i in 1:ncolumns)
plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
ylab="MPG",main=names(mpg)[i])# import your second sheet here, say 10
columns
# import your second sheet here, (10 columns)
ncolumns<ncol(mpg1)
for(i in 1:ncolumns)
plot(seq(1,500,length.out=10),mpg1[,i],type="l",xlab="Distance",
ylab="MPG",main=names(mpg)[i])# import your third sheet here, say 2
columns
# import your second sheet here, (2 columns)
ncolumns<ncol(mpg2)
for(i in 1:ncolumns)
plot(seq(1,500,length.out=10),mpg2[,i],type="l",xlab="Distance",
ylab="MPG",main=names(mpg)[i])
# finish plotting
dev.off()
You would then have 50 plots on the PDF page. I am assuming that all of
your sheets have the same number of rows and a few other things. This seems
like a lot of plots, and I suspect that you could work out a better way to
display all this information.
Jim
On Wed, Nov 21, 2018 at 1:20 PM Subhamitra Patra < [hidden email]>
wrote:
> Hello Sir,
>
> Thanks, now I understood and will check them out.
>
> One more thing I want to ask that I have 1 excel file with multiple (i.e.
> 12 sheets). Each sheet contains different number of columns, for instance,
> 1st sheet contains 38 columns, 2nd sheet contains 10 columns, Third 2
> columns, 4th 1 column and so on. Actually, due to some missing observations
> in these columns, I couldn't add them in 1 sheet.
>
> As you suggested the below code in the last mail,
>
> par(mfrow=c(4,10))
> for(i in 1:38)
> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
> ylab="MPG",main=names(mpg)[i])
> dev.off()
>
> Do I need to run the code separately for each sheet?
>
> Actually, in par (mfrow=c(4,10)), the plot for 38 columns will be added,
> the space for extra 2 will remain as empty. So, I thought to add plots for
> the columns from the next sheet in those emptied space.
>
> Is there any way that I can add plots from the next sheets of the same
> excel file in the emptied space? In other words, Is there any way to append
> plots from all sheets?
>
> Kindly help a new R learner Sir for which I shall be always grateful to
> you.
>
> Thank you very much for your kind help.
>
>
>
> [image: Mailtrack]
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
> notified by
> Mailtrack
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
> 7:30:30 AM
>
> On Wed, Nov 21, 2018 at 7:17 AM Jim Lemon < [hidden email]> wrote:
>
>> Hi Subhamitra,
>>
>> 1. Here I manufacture some data so that the example is "reproducible",
>> that is anyone can run the code and get the same output that I do. Yes,
>> veh1...veh38 are the names of the variables.
>>
>> 2. Here I join the 38 variables I created into a data frame, which I
>> think is the input for your plotting routine. This names of the columns of
>> the data frame become the names of the variables.
>>
>> When you say that you want the column names as the "header" (title) of
>> each plot, I think if you change the plotting loop to this:
>>
>> pdf("mpg.pdf",width=30,height=12)
>> par(mfrow=c(4,10))
>> for(i in 1:38)
>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>> ylab="MPG",main=names(mpg)[i])
>> dev.off()
>>
>> you will get what you requested. Remember that I have done this in base
>> graphics, not ggplot.
>>
>> Jim
>>
>> On Wed, Nov 21, 2018 at 12:37 PM Subhamitra Patra <
>> [hidden email]> wrote:
>>
>>> Hello Sir,
>>>
>>> Thanks, I'll check them out.
>>>
>>> But, I am not understanding 2 points of your suggestion.
>>>
>>> 1. In the line,* "*for(i in 1:38) assign(paste0("veh",i),rep(sam
>>> ple(10:35,1),10)+runif(10,4,*4))", *what veh, rep(sample(10:35,1),10)
>>> +runif(10,4,4)) indicate? Here veh indicates columns right?
>>> *2. In the
>>> line, mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,*
>>> * veh11,veh12,veh13,veh14,**veh15,veh16,veh17,veh18,veh19,**veh20,*
>>> * veh21,veh22,veh23,veh24,**veh25,veh26,veh27,veh28,veh29,**veh30,*
>>> * veh31,veh32,veh33,veh34,**veh35,veh36,veh37,veh38) ** , *veh[i]
>>> indicates column sequence, right? I need to give column names as the header
>>> of their respective graphs. Please suggest me How to add this?
>>>
>>>
>>> I am very new to R and therefore asking you these queries which might be
>>> simple for you.
>>>
>>> I expect positive help from you.
>>>
>>> Thanks for your kind help.
>>> [image: Mailtrack]
>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>> notified by
>>> Mailtrack
>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>> 7:02:18 AM
>>>
>>>
>>> On Wed, Nov 21, 2018 at 4:38 AM Jim Lemon < [hidden email]> wrote:
>>>
>>>> Hi Subhamitra,
>>>> As Bert noted, you are mixing base and grid graphics. Here is a simple
>>>> way to get a plot like what you described. It will probably take more
>>>> work to find what you actually do want and discover how to get it.
>>>>
>>>> for(i in 1:38)
>>>> assign(paste0("veh",i),rep(sample(10:35,1),10)+runif(10,4,4))
>>>> mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,
>>>> veh11,veh12,veh13,veh14,veh15,veh16,veh17,veh18,veh19,veh20,
>>>> veh21,veh22,veh23,veh24,veh25,veh26,veh27,veh28,veh29,veh30,
>>>> veh31,veh32,veh33,veh34,veh35,veh36,veh37,veh38)
>>>> pdf("mpg.pdf",width=30,height=12)
>>>> par(mfrow=c(4,10))
>>>> for(i in 1:38)
>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>> ylab=names(mpg)[i],main="MPG by distance")
>>>> dev.off()
>>>>
>>>> Jim
>>>>
>>>> On Wed, Nov 21, 2018 at 5:19 AM Subhamitra Patra
>>>> < [hidden email]> wrote:
>>>> >
>>>> > Dear R users,
>>>> >
>>>> > I have one excel file with 5 sheets. The no. of columns vary for each
>>>> > sheet. The 1st sheet consists of 38 columns. So, I want to plot 38
>>>> separate
>>>> > line charts and arrange them in par(mfrow = c(4, 10)) order. Please
>>>> suggest
>>>> > me how to do this. I have tried with the following code by running a
>>>> loop
>>>> > inside of a sheet, but it is not working. Further, I want to run
>>>> loops for
>>>> > each sheet.
>>>> >
>>>> > par(mfrow = c(4, 10))
>>>> > loop.vector < 1:38
>>>> > for (i in loop.vector)
>>>> > x < JJ[,i]
>>>> > library(ggplot2)
>>>> > library(cowplot)
>>>> > plot.mpg < ggplot(mpg, aes(x,
>>>> > main = paste ("country", i),
>>>> > xlab = "Scores",
>>>> > xlim = c(1,500)
>>>> > y = colnames[i,], colour =
>>>> factor(cyl))) +
>>>> > geom_line(size=2.5)
>>>> > save_plot("mpg.png", plot.mpg,
>>>> > base_aspect_ratio = 1.3)
>>>> >
>>>> > I want to give my X axis name as scores of (1,500) and Y axis as the
>>>> > particular column names for all graphs.
>>>> >
>>>> > Please suggest.
>>>> >
>>>> > Thanks in advance.
>>>> >
>>>> > 
>>>> > *Best Regards,*
>>>> > *Subhamitra Patra*
>>>> > *Phd. Research Scholar*
>>>> > *Department of Humanities and Social Sciences*
>>>> > *Indian Institute of Technology, Kharagpur*
>>>> > *INDIA*
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > [image: Mailtrack]
>>>> > <
>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>>> >
>>>> > Sender
>>>> > notified by
>>>> > Mailtrack
>>>> > <
>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>>> >
>>>> > 11/20/18,
>>>> > 11:49:42 PM
>>>> >
>>>> > [[alternative HTML version deleted]]
>>>> >
>>>> > ______________________________________________
>>>> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
>>>> > https://stat.ethz.ch/mailman/listinfo/rhelp>>>> > PLEASE do read the posting guide
>>>> http://www.Rproject.org/postingguide.html>>>> > and provide commented, minimal, selfcontained, reproducible code.
>>>>
>>>
>>>
>>> 
>>> *Best Regards,*
>>> *Subhamitra Patra*
>>> *Phd. Research Scholar*
>>> *Department of Humanities and Social Sciences*
>>> *Indian Institute of Technology, Kharagpur*
>>> *INDIA*
>>>
>>
>
> 
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hello Sir,
Thank you very much. I will try it out and will let you the result.
The no. of rows varies per sheet by a different number of observations. Due
to different no. of rows or observations, I separated the columns in
different sheets.
*Will a different number of rows create a problem for appending all plots?*
Concerning your last suggestion "*This seems like a lot of plots, and I
suspect that you could work out a better way to display all this
information.*", I am doing a multicountry study and obtained results for
each country. I would summarize the final result at the end. But, for
displaying the information for each country, I thought the plot is the best
way to give a supplementary result on each country. Sir, in this context, I
would like to take your suggestion that Is the way what I am doing, right
to proceed? If any alternative way is available, please suggest me.
Thank you very much, Sir, for your kind help and suggestions.
[image: Mailtrack]
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
11/21/18,
9:12:14 AM
On Wed, Nov 21, 2018 at 8:18 AM Jim Lemon < [hidden email]> wrote:
> I assume that you are importing the Excel sheets separately. When you
> import a sheet, you can get the number of columns with this:
>
> ncol(<name of data frame>)
>
> Using the data frame "mpg" that I created:
>
> ncolumns<ncol(mpg)
> ncolumns
> [1] 38
>
> You can then substitute "ncolumns" each time you import another sheet. How
> you want to deal with the varying numbers of columns you will get is
> another matter. One way is to work out the total number of plots you want
> and put them all onto one PDF page. Say you have 50 plots overall. You
> could start a very big PDF page:
>
> pdf("allplots.pdf",width=30,height=15)
> par(mfrow=c(5,10))
> # import your first sheet here (38 columns)
> ncolumns<ncol(mpg)
> for(i in 1:ncolumns)
> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
> ylab="MPG",main=names(mpg)[i])# import your second sheet here, say 10
> columns
> # import your second sheet here, (10 columns)
> ncolumns<ncol(mpg1)
> for(i in 1:ncolumns)
> plot(seq(1,500,length.out=10),mpg1[,i],type="l",xlab="Distance",
> ylab="MPG",main=names(mpg)[i])# import your third sheet here, say 2
> columns
> # import your second sheet here, (2 columns)
> ncolumns<ncol(mpg2)
> for(i in 1:ncolumns)
> plot(seq(1,500,length.out=10),mpg2[,i],type="l",xlab="Distance",
> ylab="MPG",main=names(mpg)[i])
> # finish plotting
> dev.off()
>
> You would then have 50 plots on the PDF page. I am assuming that all of
> your sheets have the same number of rows and a few other things. This seems
> like a lot of plots, and I suspect that you could work out a better way to
> display all this information.
>
> Jim
>
>
> On Wed, Nov 21, 2018 at 1:20 PM Subhamitra Patra <
> [hidden email]> wrote:
>
>> Hello Sir,
>>
>> Thanks, now I understood and will check them out.
>>
>> One more thing I want to ask that I have 1 excel file with multiple (i.e.
>> 12 sheets). Each sheet contains different number of columns, for instance,
>> 1st sheet contains 38 columns, 2nd sheet contains 10 columns, Third 2
>> columns, 4th 1 column and so on. Actually, due to some missing observations
>> in these columns, I couldn't add them in 1 sheet.
>>
>> As you suggested the below code in the last mail,
>>
>> par(mfrow=c(4,10))
>> for(i in 1:38)
>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>> ylab="MPG",main=names(mpg)[i])
>> dev.off()
>>
>> Do I need to run the code separately for each sheet?
>>
>> Actually, in par (mfrow=c(4,10)), the plot for 38 columns will be added,
>> the space for extra 2 will remain as empty. So, I thought to add plots for
>> the columns from the next sheet in those emptied space.
>>
>> Is there any way that I can add plots from the next sheets of the same
>> excel file in the emptied space? In other words, Is there any way to append
>> plots from all sheets?
>>
>> Kindly help a new R learner Sir for which I shall be always grateful to
>> you.
>>
>> Thank you very much for your kind help.
>>
>>
>>
>> [image: Mailtrack]
>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>> notified by
>> Mailtrack
>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>> 7:30:30 AM
>>
>> On Wed, Nov 21, 2018 at 7:17 AM Jim Lemon < [hidden email]> wrote:
>>
>>> Hi Subhamitra,
>>>
>>> 1. Here I manufacture some data so that the example is "reproducible",
>>> that is anyone can run the code and get the same output that I do. Yes,
>>> veh1...veh38 are the names of the variables.
>>>
>>> 2. Here I join the 38 variables I created into a data frame, which I
>>> think is the input for your plotting routine. This names of the columns of
>>> the data frame become the names of the variables.
>>>
>>> When you say that you want the column names as the "header" (title) of
>>> each plot, I think if you change the plotting loop to this:
>>>
>>> pdf("mpg.pdf",width=30,height=12)
>>> par(mfrow=c(4,10))
>>> for(i in 1:38)
>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>> ylab="MPG",main=names(mpg)[i])
>>> dev.off()
>>>
>>> you will get what you requested. Remember that I have done this in base
>>> graphics, not ggplot.
>>>
>>> Jim
>>>
>>> On Wed, Nov 21, 2018 at 12:37 PM Subhamitra Patra <
>>> [hidden email]> wrote:
>>>
>>>> Hello Sir,
>>>>
>>>> Thanks, I'll check them out.
>>>>
>>>> But, I am not understanding 2 points of your suggestion.
>>>>
>>>> 1. In the line,* "*for(i in 1:38) assign(paste0("veh",i),rep(sam
>>>> ple(10:35,1),10)+runif(10,4,*4))", *what veh, rep(sample(10:35,1),10)
>>>> +runif(10,4,4)) indicate? Here veh indicates columns right?
>>>> *2. In the
>>>> line, mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,*
>>>> * veh11,veh12,veh13,veh14,**veh15,veh16,veh17,veh18,veh19,**veh20,*
>>>> * veh21,veh22,veh23,veh24,**veh25,veh26,veh27,veh28,veh29,**veh30,*
>>>> * veh31,veh32,veh33,veh34,**veh35,veh36,veh37,veh38) ** , *veh[i]
>>>> indicates column sequence, right? I need to give column names as the header
>>>> of their respective graphs. Please suggest me How to add this?
>>>>
>>>>
>>>> I am very new to R and therefore asking you these queries which might
>>>> be simple for you.
>>>>
>>>> I expect positive help from you.
>>>>
>>>> Thanks for your kind help.
>>>> [image: Mailtrack]
>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>>> notified by
>>>> Mailtrack
>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>>> 7:02:18 AM
>>>>
>>>>
>>>> On Wed, Nov 21, 2018 at 4:38 AM Jim Lemon < [hidden email]> wrote:
>>>>
>>>>> Hi Subhamitra,
>>>>> As Bert noted, you are mixing base and grid graphics. Here is a simple
>>>>> way to get a plot like what you described. It will probably take more
>>>>> work to find what you actually do want and discover how to get it.
>>>>>
>>>>> for(i in 1:38)
>>>>> assign(paste0("veh",i),rep(sample(10:35,1),10)+runif(10,4,4))
>>>>> mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,
>>>>> veh11,veh12,veh13,veh14,veh15,veh16,veh17,veh18,veh19,veh20,
>>>>> veh21,veh22,veh23,veh24,veh25,veh26,veh27,veh28,veh29,veh30,
>>>>> veh31,veh32,veh33,veh34,veh35,veh36,veh37,veh38)
>>>>> pdf("mpg.pdf",width=30,height=12)
>>>>> par(mfrow=c(4,10))
>>>>> for(i in 1:38)
>>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>>> ylab=names(mpg)[i],main="MPG by distance")
>>>>> dev.off()
>>>>>
>>>>> Jim
>>>>>
>>>>> On Wed, Nov 21, 2018 at 5:19 AM Subhamitra Patra
>>>>> < [hidden email]> wrote:
>>>>> >
>>>>> > Dear R users,
>>>>> >
>>>>> > I have one excel file with 5 sheets. The no. of columns vary for each
>>>>> > sheet. The 1st sheet consists of 38 columns. So, I want to plot 38
>>>>> separate
>>>>> > line charts and arrange them in par(mfrow = c(4, 10)) order. Please
>>>>> suggest
>>>>> > me how to do this. I have tried with the following code by running a
>>>>> loop
>>>>> > inside of a sheet, but it is not working. Further, I want to run
>>>>> loops for
>>>>> > each sheet.
>>>>> >
>>>>> > par(mfrow = c(4, 10))
>>>>> > loop.vector < 1:38
>>>>> > for (i in loop.vector)
>>>>> > x < JJ[,i]
>>>>> > library(ggplot2)
>>>>> > library(cowplot)
>>>>> > plot.mpg < ggplot(mpg, aes(x,
>>>>> > main = paste ("country", i),
>>>>> > xlab = "Scores",
>>>>> > xlim = c(1,500)
>>>>> > y = colnames[i,], colour =
>>>>> factor(cyl))) +
>>>>> > geom_line(size=2.5)
>>>>> > save_plot("mpg.png", plot.mpg,
>>>>> > base_aspect_ratio = 1.3)
>>>>> >
>>>>> > I want to give my X axis name as scores of (1,500) and Y axis as the
>>>>> > particular column names for all graphs.
>>>>> >
>>>>> > Please suggest.
>>>>> >
>>>>> > Thanks in advance.
>>>>> >
>>>>> > 
>>>>> > *Best Regards,*
>>>>> > *Subhamitra Patra*
>>>>> > *Phd. Research Scholar*
>>>>> > *Department of Humanities and Social Sciences*
>>>>> > *Indian Institute of Technology, Kharagpur*
>>>>> > *INDIA*
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> > [image: Mailtrack]
>>>>> > <
>>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>>>> >
>>>>> > Sender
>>>>> > notified by
>>>>> > Mailtrack
>>>>> > <
>>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>>>> >
>>>>> > 11/20/18,
>>>>> > 11:49:42 PM
>>>>> >
>>>>> > [[alternative HTML version deleted]]
>>>>> >
>>>>> > ______________________________________________
>>>>> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
>>>>> > https://stat.ethz.ch/mailman/listinfo/rhelp>>>>> > PLEASE do read the posting guide
>>>>> http://www.Rproject.org/postingguide.html>>>>> > and provide commented, minimal, selfcontained, reproducible code.
>>>>>
>>>>
>>>>
>>>> 
>>>> *Best Regards,*
>>>> *Subhamitra Patra*
>>>> *Phd. Research Scholar*
>>>> *Department of Humanities and Social Sciences*
>>>> *Indian Institute of Technology, Kharagpur*
>>>> *INDIA*
>>>>
>>>
>>
>> 
>> *Best Regards,*
>> *Subhamitra Patra*
>> *Phd. Research Scholar*
>> *Department of Humanities and Social Sciences*
>> *Indian Institute of Technology, Kharagpur*
>> *INDIA*
>>
>

*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


For your first question, yes, you will need to adjust the number of "x"
values to match the number of "y" values. You can use the "nrow" function
to get that number. I don't really know what the abscissa scale is on your
plots, I just made up the data I used.
If you are comparing countries, you may want to divide the results into
countries of different characteristics, perhaps GDP or similar. Otherwise
you will end up with a quite large PDF page. This is okay if you are
viewing it electronically, but will present a challenge in hard copy.
Jim
On Wed, Nov 21, 2018 at 2:51 PM Subhamitra Patra < [hidden email]>
wrote:
> Hello Sir,
>
> Thank you very much. I will try it out and will let you the result.
>
> The no. of rows varies per sheet by a different number of observations.
> Due to different no. of rows or observations, I separated the columns in
> different sheets.
>
> *Will a different number of rows create a problem for appending all plots?*
>
> Concerning your last suggestion "*This seems like a lot of plots, and I
> suspect that you could work out a better way to display all this
> information.*", I am doing a multicountry study and obtained results
> for each country. I would summarize the final result at the end. But, for
> displaying the information for each country, I thought the plot is the best
> way to give a supplementary result on each country. Sir, in this context, I
> would like to take your suggestion that Is the way what I am doing, right
> to proceed? If any alternative way is available, please suggest me.
>
> Thank you very much, Sir, for your kind help and suggestions.
>
> [image: Mailtrack]
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
> notified by
> Mailtrack
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
> 9:12:14 AM
>
> On Wed, Nov 21, 2018 at 8:18 AM Jim Lemon < [hidden email]> wrote:
>
>> I assume that you are importing the Excel sheets separately. When you
>> import a sheet, you can get the number of columns with this:
>>
>> ncol(<name of data frame>)
>>
>> Using the data frame "mpg" that I created:
>>
>> ncolumns<ncol(mpg)
>> ncolumns
>> [1] 38
>>
>> You can then substitute "ncolumns" each time you import another sheet.
>> How you want to deal with the varying numbers of columns you will get is
>> another matter. One way is to work out the total number of plots you want
>> and put them all onto one PDF page. Say you have 50 plots overall. You
>> could start a very big PDF page:
>>
>> pdf("allplots.pdf",width=30,height=15)
>> par(mfrow=c(5,10))
>> # import your first sheet here (38 columns)
>> ncolumns<ncol(mpg)
>> for(i in 1:ncolumns)
>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>> ylab="MPG",main=names(mpg)[i])# import your second sheet here, say 10
>> columns
>> # import your second sheet here, (10 columns)
>> ncolumns<ncol(mpg1)
>> for(i in 1:ncolumns)
>> plot(seq(1,500,length.out=10),mpg1[,i],type="l",xlab="Distance",
>> ylab="MPG",main=names(mpg)[i])# import your third sheet here, say 2
>> columns
>> # import your second sheet here, (2 columns)
>> ncolumns<ncol(mpg2)
>> for(i in 1:ncolumns)
>> plot(seq(1,500,length.out=10),mpg2[,i],type="l",xlab="Distance",
>> ylab="MPG",main=names(mpg)[i])
>> # finish plotting
>> dev.off()
>>
>> You would then have 50 plots on the PDF page. I am assuming that all of
>> your sheets have the same number of rows and a few other things. This seems
>> like a lot of plots, and I suspect that you could work out a better way to
>> display all this information.
>>
>> Jim
>>
>>
>> On Wed, Nov 21, 2018 at 1:20 PM Subhamitra Patra <
>> [hidden email]> wrote:
>>
>>> Hello Sir,
>>>
>>> Thanks, now I understood and will check them out.
>>>
>>> One more thing I want to ask that I have 1 excel file with multiple
>>> (i.e. 12 sheets). Each sheet contains different number of columns, for
>>> instance, 1st sheet contains 38 columns, 2nd sheet contains 10 columns,
>>> Third 2 columns, 4th 1 column and so on. Actually, due to some missing
>>> observations in these columns, I couldn't add them in 1 sheet.
>>>
>>> As you suggested the below code in the last mail,
>>>
>>> par(mfrow=c(4,10))
>>> for(i in 1:38)
>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>> ylab="MPG",main=names(mpg)[i])
>>> dev.off()
>>>
>>> Do I need to run the code separately for each sheet?
>>>
>>> Actually, in par (mfrow=c(4,10)), the plot for 38 columns will be
>>> added, the space for extra 2 will remain as empty. So, I thought to add
>>> plots for the columns from the next sheet in those emptied space.
>>>
>>> Is there any way that I can add plots from the next sheets of the same
>>> excel file in the emptied space? In other words, Is there any way to append
>>> plots from all sheets?
>>>
>>> Kindly help a new R learner Sir for which I shall be always grateful to
>>> you.
>>>
>>> Thank you very much for your kind help.
>>>
>>>
>>>
>>> [image: Mailtrack]
>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>> notified by
>>> Mailtrack
>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>> 7:30:30 AM
>>>
>>> On Wed, Nov 21, 2018 at 7:17 AM Jim Lemon < [hidden email]> wrote:
>>>
>>>> Hi Subhamitra,
>>>>
>>>> 1. Here I manufacture some data so that the example is "reproducible",
>>>> that is anyone can run the code and get the same output that I do. Yes,
>>>> veh1...veh38 are the names of the variables.
>>>>
>>>> 2. Here I join the 38 variables I created into a data frame, which I
>>>> think is the input for your plotting routine. This names of the columns of
>>>> the data frame become the names of the variables.
>>>>
>>>> When you say that you want the column names as the "header" (title) of
>>>> each plot, I think if you change the plotting loop to this:
>>>>
>>>> pdf("mpg.pdf",width=30,height=12)
>>>> par(mfrow=c(4,10))
>>>> for(i in 1:38)
>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>> ylab="MPG",main=names(mpg)[i])
>>>> dev.off()
>>>>
>>>> you will get what you requested. Remember that I have done this in base
>>>> graphics, not ggplot.
>>>>
>>>> Jim
>>>>
>>>> On Wed, Nov 21, 2018 at 12:37 PM Subhamitra Patra <
>>>> [hidden email]> wrote:
>>>>
>>>>> Hello Sir,
>>>>>
>>>>> Thanks, I'll check them out.
>>>>>
>>>>> But, I am not understanding 2 points of your suggestion.
>>>>>
>>>>> 1. In the line,* "*for(i in 1:38) assign(paste0("veh",i),rep(sam
>>>>> ple(10:35,1),10)+runif(10,4,*4))", *what veh, rep(sample(10:35,1),10)
>>>>> +runif(10,4,4)) indicate? Here veh indicates columns right?
>>>>> *2. In the
>>>>> line, mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,*
>>>>> * veh11,veh12,veh13,veh14,**veh15,veh16,veh17,veh18,veh19,**veh20,*
>>>>> * veh21,veh22,veh23,veh24,**veh25,veh26,veh27,veh28,veh29,**veh30,*
>>>>> * veh31,veh32,veh33,veh34,**veh35,veh36,veh37,veh38) ** , *veh[i]
>>>>> indicates column sequence, right? I need to give column names as the header
>>>>> of their respective graphs. Please suggest me How to add this?
>>>>>
>>>>>
>>>>> I am very new to R and therefore asking you these queries which might
>>>>> be simple for you.
>>>>>
>>>>> I expect positive help from you.
>>>>>
>>>>> Thanks for your kind help.
>>>>> [image: Mailtrack]
>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>>>> notified by
>>>>> Mailtrack
>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>>>> 7:02:18 AM
>>>>>
>>>>>
>>>>> On Wed, Nov 21, 2018 at 4:38 AM Jim Lemon < [hidden email]>
>>>>> wrote:
>>>>>
>>>>>> Hi Subhamitra,
>>>>>> As Bert noted, you are mixing base and grid graphics. Here is a simple
>>>>>> way to get a plot like what you described. It will probably take more
>>>>>> work to find what you actually do want and discover how to get it.
>>>>>>
>>>>>> for(i in 1:38)
>>>>>> assign(paste0("veh",i),rep(sample(10:35,1),10)+runif(10,4,4))
>>>>>> mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,
>>>>>> veh11,veh12,veh13,veh14,veh15,veh16,veh17,veh18,veh19,veh20,
>>>>>> veh21,veh22,veh23,veh24,veh25,veh26,veh27,veh28,veh29,veh30,
>>>>>> veh31,veh32,veh33,veh34,veh35,veh36,veh37,veh38)
>>>>>> pdf("mpg.pdf",width=30,height=12)
>>>>>> par(mfrow=c(4,10))
>>>>>> for(i in 1:38)
>>>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>>>> ylab=names(mpg)[i],main="MPG by distance")
>>>>>> dev.off()
>>>>>>
>>>>>> Jim
>>>>>>
>>>>>> On Wed, Nov 21, 2018 at 5:19 AM Subhamitra Patra
>>>>>> < [hidden email]> wrote:
>>>>>> >
>>>>>> > Dear R users,
>>>>>> >
>>>>>> > I have one excel file with 5 sheets. The no. of columns vary for
>>>>>> each
>>>>>> > sheet. The 1st sheet consists of 38 columns. So, I want to plot 38
>>>>>> separate
>>>>>> > line charts and arrange them in par(mfrow = c(4, 10)) order. Please
>>>>>> suggest
>>>>>> > me how to do this. I have tried with the following code by running
>>>>>> a loop
>>>>>> > inside of a sheet, but it is not working. Further, I want to run
>>>>>> loops for
>>>>>> > each sheet.
>>>>>> >
>>>>>> > par(mfrow = c(4, 10))
>>>>>> > loop.vector < 1:38
>>>>>> > for (i in loop.vector)
>>>>>> > x < JJ[,i]
>>>>>> > library(ggplot2)
>>>>>> > library(cowplot)
>>>>>> > plot.mpg < ggplot(mpg, aes(x,
>>>>>> > main = paste ("country", i),
>>>>>> > xlab = "Scores",
>>>>>> > xlim = c(1,500)
>>>>>> > y = colnames[i,], colour =
>>>>>> factor(cyl))) +
>>>>>> > geom_line(size=2.5)
>>>>>> > save_plot("mpg.png", plot.mpg,
>>>>>> > base_aspect_ratio = 1.3)
>>>>>> >
>>>>>> > I want to give my X axis name as scores of (1,500) and Y axis as the
>>>>>> > particular column names for all graphs.
>>>>>> >
>>>>>> > Please suggest.
>>>>>> >
>>>>>> > Thanks in advance.
>>>>>> >
>>>>>> > 
>>>>>> > *Best Regards,*
>>>>>> > *Subhamitra Patra*
>>>>>> > *Phd. Research Scholar*
>>>>>> > *Department of Humanities and Social Sciences*
>>>>>> > *Indian Institute of Technology, Kharagpur*
>>>>>> > *INDIA*
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > [image: Mailtrack]
>>>>>> > <
>>>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>>>>> >
>>>>>> > Sender
>>>>>> > notified by
>>>>>> > Mailtrack
>>>>>> > <
>>>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>>>>> >
>>>>>> > 11/20/18,
>>>>>> > 11:49:42 PM
>>>>>> >
>>>>>> > [[alternative HTML version deleted]]
>>>>>> >
>>>>>> > ______________________________________________
>>>>>> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
>>>>>> > https://stat.ethz.ch/mailman/listinfo/rhelp>>>>>> > PLEASE do read the posting guide
>>>>>> http://www.Rproject.org/postingguide.html>>>>>> > and provide commented, minimal, selfcontained, reproducible code.
>>>>>>
>>>>>
>>>>>
>>>>> 
>>>>> *Best Regards,*
>>>>> *Subhamitra Patra*
>>>>> *Phd. Research Scholar*
>>>>> *Department of Humanities and Social Sciences*
>>>>> *Indian Institute of Technology, Kharagpur*
>>>>> *INDIA*
>>>>>
>>>>
>>>
>>> 
>>> *Best Regards,*
>>> *Subhamitra Patra*
>>> *Phd. Research Scholar*
>>> *Department of Humanities and Social Sciences*
>>> *Indian Institute of Technology, Kharagpur*
>>> *INDIA*
>>>
>>
>
> 
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi
When I do multiple plots of similar data I usually put the plots into the multipage pdf file
pdf("somename.pdf")
for (i in columns) {
p<ggplot(something)
print(p+geom_point(size=4)+stat_smooth(se=F, span=0.5, size=1.3)+
facet_grid(al2o3~teplota, labeller="label_both"))
or
plot(something)
}
dev.off()
This will generate somename.pdf in your working directory and plots will be definitelly bigger than 40 plots in one page.
Another approach could be to store plots as objects in a list (which is easy done with ggplot) but rather trickier with base graphics and make actual plotting after the whole list is populated with your plots.
https://www.andrewheiss.com/blog/2016/12/08/savebasegraphicsaspseudoobjectsinr/Cheers
Petr
> Original Message
> From: Rhelp < [hidden email]> On Behalf Of Subhamitra Patra
> Sent: Wednesday, November 21, 2018 4:52 AM
> To: Jim Lemon < [hidden email]>
> Cc: [hidden email]
> Subject: Re: [R] [R studio] Plotting of line chart for each columns at 1 page
>
> Hello Sir,
>
> Thank you very much. I will try it out and will let you the result.
>
> The no. of rows varies per sheet by a different number of observations. Due to
> different no. of rows or observations, I separated the columns in different
> sheets.
>
> *Will a different number of rows create a problem for appending all plots?*
>
> Concerning your last suggestion "*This seems like a lot of plots, and I suspect
> that you could work out a better way to display all this information.*", I am
> doing a multicountry study and obtained results for each country. I would
> summarize the final result at the end. But, for displaying the information for
> each country, I thought the plot is the best way to give a supplementary result
> on each country. Sir, in this context, I would like to take your suggestion that Is
> the way what I am doing, right to proceed? If any alternative way is available,
> please suggest me.
>
> Thank you very much, Sir, for your kind help and suggestions.
>
> [image: Mailtrack]
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campa> ign=signaturevirality5&>
> Sender
> notified by
> Mailtrack
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campa> ign=signaturevirality5&>
> 11/21/18,
> 9:12:14 AM
>
> On Wed, Nov 21, 2018 at 8:18 AM Jim Lemon < [hidden email]>
> wrote:
>
> > I assume that you are importing the Excel sheets separately. When you
> > import a sheet, you can get the number of columns with this:
> >
> > ncol(<name of data frame>)
> >
> > Using the data frame "mpg" that I created:
> >
> > ncolumns<ncol(mpg)
> > ncolumns
> > [1] 38
> >
> > You can then substitute "ncolumns" each time you import another sheet.
> > How you want to deal with the varying numbers of columns you will get
> > is another matter. One way is to work out the total number of plots
> > you want and put them all onto one PDF page. Say you have 50 plots
> > overall. You could start a very big PDF page:
> >
> > pdf("allplots.pdf",width=30,height=15)
> > par(mfrow=c(5,10))
> > # import your first sheet here (38 columns)
> > ncolumns<ncol(mpg)
> > for(i in 1:ncolumns)
> > plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
> > ylab="MPG",main=names(mpg)[i])# import your second sheet here, say
> > 10 columns # import your second sheet here, (10 columns)
> > ncolumns<ncol(mpg1)
> > for(i in 1:ncolumns)
> > plot(seq(1,500,length.out=10),mpg1[,i],type="l",xlab="Distance",
> > ylab="MPG",main=names(mpg)[i])# import your third sheet here, say 2
> > columns # import your second sheet here, (2 columns)
> > ncolumns<ncol(mpg2)
> > for(i in 1:ncolumns)
> > plot(seq(1,500,length.out=10),mpg2[,i],type="l",xlab="Distance",
> > ylab="MPG",main=names(mpg)[i])
> > # finish plotting
> > dev.off()
> >
> > You would then have 50 plots on the PDF page. I am assuming that all
> > of your sheets have the same number of rows and a few other things.
> > This seems like a lot of plots, and I suspect that you could work out
> > a better way to display all this information.
> >
> > Jim
> >
> >
> > On Wed, Nov 21, 2018 at 1:20 PM Subhamitra Patra <
> > [hidden email]> wrote:
> >
> >> Hello Sir,
> >>
> >> Thanks, now I understood and will check them out.
> >>
> >> One more thing I want to ask that I have 1 excel file with multiple (i.e.
> >> 12 sheets). Each sheet contains different number of columns, for
> >> instance, 1st sheet contains 38 columns, 2nd sheet contains 10
> >> columns, Third 2 columns, 4th 1 column and so on. Actually, due to
> >> some missing observations in these columns, I couldn't add them in 1 sheet.
> >>
> >> As you suggested the below code in the last mail,
> >>
> >> par(mfrow=c(4,10))
> >> for(i in 1:38)
> >> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
> >> ylab="MPG",main=names(mpg)[i])
> >> dev.off()
> >>
> >> Do I need to run the code separately for each sheet?
> >>
> >> Actually, in par (mfrow=c(4,10)), the plot for 38 columns will be
> >> added, the space for extra 2 will remain as empty. So, I thought to
> >> add plots for the columns from the next sheet in those emptied space.
> >>
> >> Is there any way that I can add plots from the next sheets of the
> >> same excel file in the emptied space? In other words, Is there any
> >> way to append plots from all sheets?
> >>
> >> Kindly help a new R learner Sir for which I shall be always grateful
> >> to you.
> >>
> >> Thank you very much for your kind help.
> >>
> >>
> >>
> >> [image: Mailtrack]
> >>
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campa> >> ign=signaturevirality5&> Sender notified by Mailtrack
> >>
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campa> >> ign=signaturevirality5&> 11/21/18,
> >> 7:30:30 AM
> >>
> >> On Wed, Nov 21, 2018 at 7:17 AM Jim Lemon < [hidden email]>
> wrote:
> >>
> >>> Hi Subhamitra,
> >>>
> >>> 1. Here I manufacture some data so that the example is
> >>> "reproducible", that is anyone can run the code and get the same
> >>> output that I do. Yes,
> >>> veh1...veh38 are the names of the variables.
> >>>
> >>> 2. Here I join the 38 variables I created into a data frame, which I
> >>> think is the input for your plotting routine. This names of the
> >>> columns of the data frame become the names of the variables.
> >>>
> >>> When you say that you want the column names as the "header" (title)
> >>> of each plot, I think if you change the plotting loop to this:
> >>>
> >>> pdf("mpg.pdf",width=30,height=12)
> >>> par(mfrow=c(4,10))
> >>> for(i in 1:38)
> >>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
> >>> ylab="MPG",main=names(mpg)[i])
> >>> dev.off()
> >>>
> >>> you will get what you requested. Remember that I have done this in
> >>> base graphics, not ggplot.
> >>>
> >>> Jim
> >>>
> >>> On Wed, Nov 21, 2018 at 12:37 PM Subhamitra Patra <
> >>> [hidden email]> wrote:
> >>>
> >>>> Hello Sir,
> >>>>
> >>>> Thanks, I'll check them out.
> >>>>
> >>>> But, I am not understanding 2 points of your suggestion.
> >>>>
> >>>> 1. In the line,* "*for(i in 1:38) assign(paste0("veh",i),rep(sam
> >>>> ple(10:35,1),10)+runif(10,4,*4))", *what veh,
> >>>> rep(sample(10:35,1),10)
> >>>> +runif(10,4,4)) indicate? Here veh indicates columns right?
> >>>> *2. In the
> >>>> line,
> >>>> mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,
> >>>> *
> >>>> *
> veh11,veh12,veh13,veh14,**veh15,veh16,veh17,veh18,veh19,**veh20,*
> >>>> *
> veh21,veh22,veh23,veh24,**veh25,veh26,veh27,veh28,veh29,**veh30,*
> >>>> * veh31,veh32,veh33,veh34,**veh35,veh36,veh37,veh38) ** , *veh[i]
> >>>> indicates column sequence, right? I need to give column names as
> >>>> the header of their respective graphs. Please suggest me How to add this?
> >>>>
> >>>>
> >>>> I am very new to R and therefore asking you these queries which
> >>>> might be simple for you.
> >>>>
> >>>> I expect positive help from you.
> >>>>
> >>>> Thanks for your kind help.
> >>>> [image: Mailtrack]
> >>>>
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_cam> >>>> paign=signaturevirality5&> Sender notified by Mailtrack
> >>>>
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_cam> >>>> paign=signaturevirality5&> 11/21/18,
> >>>> 7:02:18 AM
> >>>>
> >>>>
> >>>> On Wed, Nov 21, 2018 at 4:38 AM Jim Lemon < [hidden email]>
> wrote:
> >>>>
> >>>>> Hi Subhamitra,
> >>>>> As Bert noted, you are mixing base and grid graphics. Here is a
> >>>>> simple way to get a plot like what you described. It will probably
> >>>>> take more work to find what you actually do want and discover how to
> get it.
> >>>>>
> >>>>> for(i in 1:38)
> >>>>> assign(paste0("veh",i),rep(sample(10:35,1),10)+runif(10,4,4))
> >>>>> mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10
> >>>>> , veh11,veh12,veh13,veh14,veh15,veh16,veh17,veh18,veh19,veh20,
> >>>>> veh21,veh22,veh23,veh24,veh25,veh26,veh27,veh28,veh29,veh30,
> >>>>> veh31,veh32,veh33,veh34,veh35,veh36,veh37,veh38)
> >>>>> pdf("mpg.pdf",width=30,height=12)
> >>>>> par(mfrow=c(4,10))
> >>>>> for(i in 1:38)
> >>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
> >>>>> ylab=names(mpg)[i],main="MPG by distance")
> >>>>> dev.off()
> >>>>>
> >>>>> Jim
> >>>>>
> >>>>> On Wed, Nov 21, 2018 at 5:19 AM Subhamitra Patra
> >>>>> < [hidden email]> wrote:
> >>>>> >
> >>>>> > Dear R users,
> >>>>> >
> >>>>> > I have one excel file with 5 sheets. The no. of columns vary for
> >>>>> > each sheet. The 1st sheet consists of 38 columns. So, I want to
> >>>>> > plot 38
> >>>>> separate
> >>>>> > line charts and arrange them in par(mfrow = c(4, 10)) order.
> >>>>> > Please
> >>>>> suggest
> >>>>> > me how to do this. I have tried with the following code by
> >>>>> > running a
> >>>>> loop
> >>>>> > inside of a sheet, but it is not working. Further, I want to run
> >>>>> loops for
> >>>>> > each sheet.
> >>>>> >
> >>>>> > par(mfrow = c(4, 10))
> >>>>> > loop.vector < 1:38
> >>>>> > for (i in loop.vector)
> >>>>> > x < JJ[,i]
> >>>>> > library(ggplot2)
> >>>>> > library(cowplot)
> >>>>> > plot.mpg < ggplot(mpg, aes(x,
> >>>>> > main = paste ("country", i),
> >>>>> > xlab = "Scores",
> >>>>> > xlim = c(1,500)
> >>>>> > y = colnames[i,], colour =
> >>>>> factor(cyl))) +
> >>>>> > geom_line(size=2.5)
> >>>>> > save_plot("mpg.png", plot.mpg,
> >>>>> > base_aspect_ratio = 1.3)
> >>>>> >
> >>>>> > I want to give my X axis name as scores of (1,500) and Y axis as
> >>>>> > the particular column names for all graphs.
> >>>>> >
> >>>>> > Please suggest.
> >>>>> >
> >>>>> > Thanks in advance.
> >>>>> >
> >>>>> > 
> >>>>> > *Best Regards,*
> >>>>> > *Subhamitra Patra*
> >>>>> > *Phd. Research Scholar*
> >>>>> > *Department of Humanities and Social Sciences* *Indian Institute
> >>>>> > of Technology, Kharagpur*
> >>>>> > *INDIA*
> >>>>> >
> >>>>> >
> >>>>> >
> >>>>> >
> >>>>> >
> >>>>> >
> >>>>> >
> >>>>> >
> >>>>> > [image: Mailtrack]
> >>>>> > <
> >>>>>
> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_cam> >>>>> paign=signaturevirality5&
> >>>>> >
> >>>>> > Sender
> >>>>> > notified by
> >>>>> > Mailtrack
> >>>>> > <
> >>>>>
> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_cam> >>>>> paign=signaturevirality5&
> >>>>> >
> >>>>> > 11/20/18,
> >>>>> > 11:49:42 PM
> >>>>> >
> >>>>> > [[alternative HTML version deleted]]
> >>>>> >
> >>>>> > ______________________________________________
> >>>>> > [hidden email] mailing list  To UNSUBSCRIBE and more,
> >>>>> > see https://stat.ethz.ch/mailman/listinfo/rhelp> >>>>> > PLEASE do read the posting guide
> >>>>> http://www.Rproject.org/postingguide.html> >>>>> > and provide commented, minimal, selfcontained, reproducible code.
> >>>>>
> >>>>
> >>>>
> >>>> 
> >>>> *Best Regards,*
> >>>> *Subhamitra Patra*
> >>>> *Phd. Research Scholar*
> >>>> *Department of Humanities and Social Sciences* *Indian Institute of
> >>>> Technology, Kharagpur*
> >>>> *INDIA*
> >>>>
> >>>
> >>
> >> 
> >> *Best Regards,*
> >> *Subhamitra Patra*
> >> *Phd. Research Scholar*
> >> *Department of Humanities and Social Sciences* *Indian Institute of
> >> Technology, Kharagpur*
> >> *INDIA*
> >>
> >
>
> 
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences* *Indian Institute of
> Technology, Kharagpur*
> *INDIA*
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasadyochranyosobnichudaju/  Information about processing and protection of business partner’s personal data are available on website: https://www.precheza.cz/en/personaldataprotectionprinciples/Důvěrnost: Tento email a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: https://www.precheza.cz/01dovetek/  This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01disclaimer/______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Now we're getting somewhere. I suspect that each Excel sheet looks
something like this:
Year Tonga Samoa Fiji
2008 21.2 32.0 18.7
...
2017 23.7 31.9 19.3
# in the above there are three columns (countries) and ten rows
# import this sheet as "MPG3"
nrows<nrow(MPG3) # nrows equals 10
ncols<ncol(MPG3) # ncols equals 3
for(i in 1:ncols)
plot(seq(1:nrows,MPG3[,i],type="l",xlab="Distance",
ylab="MPG",main=names(MPG3)[i],xaxt="n")
axis(1,at=1:nrows,labels=MPG3$Year)
I probably have the structure of the imported data frame wrong, but I think
you can work that out.
Jim
On Wed, Nov 21, 2018 at 4:08 PM Subhamitra Patra < [hidden email]>
wrote:
> As per your suggestion, *"you will need to adjust the number of "x"
> values to match the number of "y" values. Now with the addition of the
> nrow function, the code for each sheet will be*
>
>
> *ncolumns<ncol(mpg)*
> * nrows<nrow(mpg) *
>
>
> *for(i in
> 1:ncolumns) plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
> ylab="MPG",main=names(mpg)[i]) *
>
> #####The no. of rows for the columns in one sheet will be the same. In the
> Xaxis, I need to mention Year which is the same for all columns in a
> sheet. But, the starting year varies from one sheet to other.
>
> *Sir, please suggest in case of any mistakes.*
>
> Second, I will definitely consider your suggestions about the division of
> sample by similar characteristics so that it can be easier to show in
> graphical. Thank you very much, sir, for such creative and wonderful
> suggestions.
>
>
>
> [image: Mailtrack]
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
> notified by
> Mailtrack
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
> 10:35:03 AM
>
> On Wed, Nov 21, 2018 at 9:40 AM Jim Lemon < [hidden email]> wrote:
>
>> For your first question, yes, you will need to adjust the number of "x"
>> values to match the number of "y" values. You can use the "nrow" function
>> to get that number. I don't really know what the abscissa scale is on your
>> plots, I just made up the data I used.
>>
>> If you are comparing countries, you may want to divide the results into
>> countries of different characteristics, perhaps GDP or similar. Otherwise
>> you will end up with a quite large PDF page. This is okay if you are
>> viewing it electronically, but will present a challenge in hard copy.
>>
>> Jim
>>
>> On Wed, Nov 21, 2018 at 2:51 PM Subhamitra Patra <
>> [hidden email]> wrote:
>>
>>> Hello Sir,
>>>
>>> Thank you very much. I will try it out and will let you the result.
>>>
>>> The no. of rows varies per sheet by a different number of observations.
>>> Due to different no. of rows or observations, I separated the columns in
>>> different sheets.
>>>
>>> *Will a different number of rows create a problem for appending all
>>> plots?*
>>>
>>> Concerning your last suggestion "*This seems like a lot of plots, and I
>>> suspect that you could work out a better way to display all this
>>> information.*", I am doing a multicountry study and obtained results
>>> for each country. I would summarize the final result at the end. But, for
>>> displaying the information for each country, I thought the plot is the best
>>> way to give a supplementary result on each country. Sir, in this context, I
>>> would like to take your suggestion that Is the way what I am doing, right
>>> to proceed? If any alternative way is available, please suggest me.
>>>
>>> Thank you very much, Sir, for your kind help and suggestions.
>>>
>>> [image: Mailtrack]
>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>> notified by
>>> Mailtrack
>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>> 9:12:14 AM
>>>
>>> On Wed, Nov 21, 2018 at 8:18 AM Jim Lemon < [hidden email]> wrote:
>>>
>>>> I assume that you are importing the Excel sheets separately. When you
>>>> import a sheet, you can get the number of columns with this:
>>>>
>>>> ncol(<name of data frame>)
>>>>
>>>> Using the data frame "mpg" that I created:
>>>>
>>>> ncolumns<ncol(mpg)
>>>> ncolumns
>>>> [1] 38
>>>>
>>>> You can then substitute "ncolumns" each time you import another sheet.
>>>> How you want to deal with the varying numbers of columns you will get is
>>>> another matter. One way is to work out the total number of plots you want
>>>> and put them all onto one PDF page. Say you have 50 plots overall. You
>>>> could start a very big PDF page:
>>>>
>>>> pdf("allplots.pdf",width=30,height=15)
>>>> par(mfrow=c(5,10))
>>>> # import your first sheet here (38 columns)
>>>> ncolumns<ncol(mpg)
>>>> for(i in 1:ncolumns)
>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>> ylab="MPG",main=names(mpg)[i])# import your second sheet here, say
>>>> 10 columns
>>>> # import your second sheet here, (10 columns)
>>>> ncolumns<ncol(mpg1)
>>>> for(i in 1:ncolumns)
>>>> plot(seq(1,500,length.out=10),mpg1[,i],type="l",xlab="Distance",
>>>> ylab="MPG",main=names(mpg)[i])# import your third sheet here, say 2
>>>> columns
>>>> # import your second sheet here, (2 columns)
>>>> ncolumns<ncol(mpg2)
>>>> for(i in 1:ncolumns)
>>>> plot(seq(1,500,length.out=10),mpg2[,i],type="l",xlab="Distance",
>>>> ylab="MPG",main=names(mpg)[i])
>>>> # finish plotting
>>>> dev.off()
>>>>
>>>> You would then have 50 plots on the PDF page. I am assuming that all of
>>>> your sheets have the same number of rows and a few other things. This seems
>>>> like a lot of plots, and I suspect that you could work out a better way to
>>>> display all this information.
>>>>
>>>> Jim
>>>>
>>>>
>>>> On Wed, Nov 21, 2018 at 1:20 PM Subhamitra Patra <
>>>> [hidden email]> wrote:
>>>>
>>>>> Hello Sir,
>>>>>
>>>>> Thanks, now I understood and will check them out.
>>>>>
>>>>> One more thing I want to ask that I have 1 excel file with multiple
>>>>> (i.e. 12 sheets). Each sheet contains different number of columns, for
>>>>> instance, 1st sheet contains 38 columns, 2nd sheet contains 10 columns,
>>>>> Third 2 columns, 4th 1 column and so on. Actually, due to some missing
>>>>> observations in these columns, I couldn't add them in 1 sheet.
>>>>>
>>>>> As you suggested the below code in the last mail,
>>>>>
>>>>> par(mfrow=c(4,10))
>>>>> for(i in 1:38)
>>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>>> ylab="MPG",main=names(mpg)[i])
>>>>> dev.off()
>>>>>
>>>>> Do I need to run the code separately for each sheet?
>>>>>
>>>>> Actually, in par (mfrow=c(4,10)), the plot for 38 columns will be
>>>>> added, the space for extra 2 will remain as empty. So, I thought to add
>>>>> plots for the columns from the next sheet in those emptied space.
>>>>>
>>>>> Is there any way that I can add plots from the next sheets of the same
>>>>> excel file in the emptied space? In other words, Is there any way to append
>>>>> plots from all sheets?
>>>>>
>>>>> Kindly help a new R learner Sir for which I shall be always grateful
>>>>> to you.
>>>>>
>>>>> Thank you very much for your kind help.
>>>>>
>>>>>
>>>>>
>>>>> [image: Mailtrack]
>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>>>> notified by
>>>>> Mailtrack
>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>>>> 7:30:30 AM
>>>>>
>>>>> On Wed, Nov 21, 2018 at 7:17 AM Jim Lemon < [hidden email]>
>>>>> wrote:
>>>>>
>>>>>> Hi Subhamitra,
>>>>>>
>>>>>> 1. Here I manufacture some data so that the example is
>>>>>> "reproducible", that is anyone can run the code and get the same output
>>>>>> that I do. Yes, veh1...veh38 are the names of the variables.
>>>>>>
>>>>>> 2. Here I join the 38 variables I created into a data frame, which I
>>>>>> think is the input for your plotting routine. This names of the columns of
>>>>>> the data frame become the names of the variables.
>>>>>>
>>>>>> When you say that you want the column names as the "header" (title)
>>>>>> of each plot, I think if you change the plotting loop to this:
>>>>>>
>>>>>> pdf("mpg.pdf",width=30,height=12)
>>>>>> par(mfrow=c(4,10))
>>>>>> for(i in 1:38)
>>>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>>>> ylab="MPG",main=names(mpg)[i])
>>>>>> dev.off()
>>>>>>
>>>>>> you will get what you requested. Remember that I have done this in
>>>>>> base graphics, not ggplot.
>>>>>>
>>>>>> Jim
>>>>>>
>>>>>> On Wed, Nov 21, 2018 at 12:37 PM Subhamitra Patra <
>>>>>> [hidden email]> wrote:
>>>>>>
>>>>>>> Hello Sir,
>>>>>>>
>>>>>>> Thanks, I'll check them out.
>>>>>>>
>>>>>>> But, I am not understanding 2 points of your suggestion.
>>>>>>>
>>>>>>> 1. In the line,* "*for(i in 1:38) assign(paste0("veh",i),rep(sam
>>>>>>> ple(10:35,1),10)+runif(10,4,*4))", *what veh, rep(sam
>>>>>>> ple(10:35,1),10)+runif(10,4,4)) indicate? Here veh indicates
>>>>>>> columns right?
>>>>>>> *2. In the
>>>>>>> line, mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,*
>>>>>>> * veh11,veh12,veh13,veh14,**veh15,veh16,veh17,veh18,veh19,**veh20,*
>>>>>>> * veh21,veh22,veh23,veh24,**veh25,veh26,veh27,veh28,veh29,**veh30,*
>>>>>>> * veh31,veh32,veh33,veh34,**veh35,veh36,veh37,veh38) ** , *veh[i]
>>>>>>> indicates column sequence, right? I need to give column names as the header
>>>>>>> of their respective graphs. Please suggest me How to add this?
>>>>>>>
>>>>>>>
>>>>>>> I am very new to R and therefore asking you these queries which
>>>>>>> might be simple for you.
>>>>>>>
>>>>>>> I expect positive help from you.
>>>>>>>
>>>>>>> Thanks for your kind help.
>>>>>>> [image: Mailtrack]
>>>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>>>>>> notified by
>>>>>>> Mailtrack
>>>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>>>>>> 7:02:18 AM
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Nov 21, 2018 at 4:38 AM Jim Lemon < [hidden email]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi Subhamitra,
>>>>>>>> As Bert noted, you are mixing base and grid graphics. Here is a
>>>>>>>> simple
>>>>>>>> way to get a plot like what you described. It will probably take
>>>>>>>> more
>>>>>>>> work to find what you actually do want and discover how to get it.
>>>>>>>>
>>>>>>>> for(i in 1:38)
>>>>>>>> assign(paste0("veh",i),rep(sample(10:35,1),10)+runif(10,4,4))
>>>>>>>> mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,
>>>>>>>> veh11,veh12,veh13,veh14,veh15,veh16,veh17,veh18,veh19,veh20,
>>>>>>>> veh21,veh22,veh23,veh24,veh25,veh26,veh27,veh28,veh29,veh30,
>>>>>>>> veh31,veh32,veh33,veh34,veh35,veh36,veh37,veh38)
>>>>>>>> pdf("mpg.pdf",width=30,height=12)
>>>>>>>> par(mfrow=c(4,10))
>>>>>>>> for(i in 1:38)
>>>>>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>>>>>> ylab=names(mpg)[i],main="MPG by distance")
>>>>>>>> dev.off()
>>>>>>>>
>>>>>>>> Jim
>>>>>>>>
>>>>>>>> On Wed, Nov 21, 2018 at 5:19 AM Subhamitra Patra
>>>>>>>> < [hidden email]> wrote:
>>>>>>>> >
>>>>>>>> > Dear R users,
>>>>>>>> >
>>>>>>>> > I have one excel file with 5 sheets. The no. of columns vary for
>>>>>>>> each
>>>>>>>> > sheet. The 1st sheet consists of 38 columns. So, I want to plot
>>>>>>>> 38 separate
>>>>>>>> > line charts and arrange them in par(mfrow = c(4, 10)) order.
>>>>>>>> Please suggest
>>>>>>>> > me how to do this. I have tried with the following code by
>>>>>>>> running a loop
>>>>>>>> > inside of a sheet, but it is not working. Further, I want to run
>>>>>>>> loops for
>>>>>>>> > each sheet.
>>>>>>>> >
>>>>>>>> > par(mfrow = c(4, 10))
>>>>>>>> > loop.vector < 1:38
>>>>>>>> > for (i in loop.vector)
>>>>>>>> > x < JJ[,i]
>>>>>>>> > library(ggplot2)
>>>>>>>> > library(cowplot)
>>>>>>>> > plot.mpg < ggplot(mpg, aes(x,
>>>>>>>> > main = paste ("country", i),
>>>>>>>> > xlab = "Scores",
>>>>>>>> > xlim = c(1,500)
>>>>>>>> > y = colnames[i,], colour =
>>>>>>>> factor(cyl))) +
>>>>>>>> > geom_line(size=2.5)
>>>>>>>> > save_plot("mpg.png", plot.mpg,
>>>>>>>> > base_aspect_ratio = 1.3)
>>>>>>>> >
>>>>>>>> > I want to give my X axis name as scores of (1,500) and Y axis as
>>>>>>>> the
>>>>>>>> > particular column names for all graphs.
>>>>>>>> >
>>>>>>>> > Please suggest.
>>>>>>>> >
>>>>>>>> > Thanks in advance.
>>>>>>>> >
>>>>>>>> > 
>>>>>>>> > *Best Regards,*
>>>>>>>> > *Subhamitra Patra*
>>>>>>>> > *Phd. Research Scholar*
>>>>>>>> > *Department of Humanities and Social Sciences*
>>>>>>>> > *Indian Institute of Technology, Kharagpur*
>>>>>>>> > *INDIA*
>>>>>>>> >
>>>>>>>> >
>>>>>>>> >
>>>>>>>> >
>>>>>>>> >
>>>>>>>> >
>>>>>>>> >
>>>>>>>> >
>>>>>>>> > [image: Mailtrack]
>>>>>>>> > <
>>>>>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>>>>>>> >
>>>>>>>> > Sender
>>>>>>>> > notified by
>>>>>>>> > Mailtrack
>>>>>>>> > <
>>>>>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>>>>>>> >
>>>>>>>> > 11/20/18,
>>>>>>>> > 11:49:42 PM
>>>>>>>> >
>>>>>>>> > [[alternative HTML version deleted]]
>>>>>>>> >
>>>>>>>> > ______________________________________________
>>>>>>>> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
>>>>>>>> > https://stat.ethz.ch/mailman/listinfo/rhelp>>>>>>>> > PLEASE do read the posting guide
>>>>>>>> http://www.Rproject.org/postingguide.html>>>>>>>> > and provide commented, minimal, selfcontained, reproducible code.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 
>>>>>>> *Best Regards,*
>>>>>>> *Subhamitra Patra*
>>>>>>> *Phd. Research Scholar*
>>>>>>> *Department of Humanities and Social Sciences*
>>>>>>> *Indian Institute of Technology, Kharagpur*
>>>>>>> *INDIA*
>>>>>>>
>>>>>>
>>>>>
>>>>> 
>>>>> *Best Regards,*
>>>>> *Subhamitra Patra*
>>>>> *Phd. Research Scholar*
>>>>> *Department of Humanities and Social Sciences*
>>>>> *Indian Institute of Technology, Kharagpur*
>>>>> *INDIA*
>>>>>
>>>>
>>>
>>> 
>>> *Best Regards,*
>>> *Subhamitra Patra*
>>> *Phd. Research Scholar*
>>> *Department of Humanities and Social Sciences*
>>> *Indian Institute of Technology, Kharagpur*
>>> *INDIA*
>>>
>>
>
> 
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Sir, in the bold portion of the below code, I have some confusion which I
am mentioning below that
"ylab="MPG",main=names(MPG3)[i],*xaxt="n"*)
axis(*1*,at=1:nrows,*labels=MPG3$Year*)"
1. Here, what *xaxt="n"* indicates? I think it indicates the no. of rows,
right?
2. 1 in the 2nd line represents the no. of graphs. Let suppose, 38
plots are having the same row, I need to mention them as *axis(38,
at=1:nrows)*, right?
3. *labels=**MPG3$Year *will give the name of all years in the Xaxis,
right?
Kindly correct me if I am wrong.
Sir, here one thing I would like to ask, my data frequency is not yearly. I
obtained results from the daily data of the period from 19942017 (that
means the no. of rows will be 5655). But, as the daily period is very
unclear to mention in the Xaxis, I wanted to give year name as the name of
the Xaxis (that means, 1995, 1997, 1999 with the increment of 2 years up
to 2017).
Sir, please suggest me how to proceed with this?
Thank you very much for your kind help.
[image: Mailtrack]
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
11/21/18,
1:46:50 PM
On Wed, Nov 21, 2018 at 1:21 PM Jim Lemon < [hidden email]> wrote:
> Now we're getting somewhere. I suspect that each Excel sheet looks
> something like this:
>
> Year Tonga Samoa Fiji
> 2008 21.2 32.0 18.7
> ...
> 2017 23.7 31.9 19.3
> # in the above there are three columns (countries) and ten rows
> # import this sheet as "MPG3"
> nrows<nrow(MPG3) # nrows equals 10
> ncols<ncol(MPG3) # ncols equals 3
> for(i in 1:ncols)
> plot(seq(1:nrows,MPG3[,i],type="l",xlab="Distance",
> ylab="MPG",main=names(MPG3)[i],xaxt="n")
> axis(1,at=1:nrows,labels=MPG3$Year)
>
> I probably have the structure of the imported data frame wrong, but I
> think you can work that out.
>
> Jim
>
>
>
> On Wed, Nov 21, 2018 at 4:08 PM Subhamitra Patra <
> [hidden email]> wrote:
>
>> As per your suggestion, *"you will need to adjust the number of "x"
>> values to match the number of "y" values. Now with the addition of the
>> nrow function, the code for each sheet will be*
>>
>>
>> *ncolumns<ncol(mpg)*
>> * nrows<nrow(mpg) *
>>
>>
>> *for(i in
>> 1:ncolumns) plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>> ylab="MPG",main=names(mpg)[i]) *
>>
>> #####The no. of rows for the columns in one sheet will be the same. In
>> the Xaxis, I need to mention Year which is the same for all columns in a
>> sheet. But, the starting year varies from one sheet to other.
>>
>> *Sir, please suggest in case of any mistakes.*
>>
>> Second, I will definitely consider your suggestions about the division of
>> sample by similar characteristics so that it can be easier to show in
>> graphical. Thank you very much, sir, for such creative and wonderful
>> suggestions.
>>
>>
>>
>> [image: Mailtrack]
>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>> notified by
>> Mailtrack
>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>> 10:35:03 AM
>>
>> On Wed, Nov 21, 2018 at 9:40 AM Jim Lemon < [hidden email]> wrote:
>>
>>> For your first question, yes, you will need to adjust the number of "x"
>>> values to match the number of "y" values. You can use the "nrow" function
>>> to get that number. I don't really know what the abscissa scale is on your
>>> plots, I just made up the data I used.
>>>
>>> If you are comparing countries, you may want to divide the results into
>>> countries of different characteristics, perhaps GDP or similar. Otherwise
>>> you will end up with a quite large PDF page. This is okay if you are
>>> viewing it electronically, but will present a challenge in hard copy.
>>>
>>> Jim
>>>
>>> On Wed, Nov 21, 2018 at 2:51 PM Subhamitra Patra <
>>> [hidden email]> wrote:
>>>
>>>> Hello Sir,
>>>>
>>>> Thank you very much. I will try it out and will let you the result.
>>>>
>>>> The no. of rows varies per sheet by a different number of observations.
>>>> Due to different no. of rows or observations, I separated the columns in
>>>> different sheets.
>>>>
>>>> *Will a different number of rows create a problem for appending all
>>>> plots?*
>>>>
>>>> Concerning your last suggestion "*This seems like a lot of plots, and
>>>> I suspect that you could work out a better way to display all this
>>>> information.*", I am doing a multicountry study and obtained results
>>>> for each country. I would summarize the final result at the end. But, for
>>>> displaying the information for each country, I thought the plot is the best
>>>> way to give a supplementary result on each country. Sir, in this context, I
>>>> would like to take your suggestion that Is the way what I am doing, right
>>>> to proceed? If any alternative way is available, please suggest me.
>>>>
>>>> Thank you very much, Sir, for your kind help and suggestions.
>>>>
>>>> [image: Mailtrack]
>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>>> notified by
>>>> Mailtrack
>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>>> 9:12:14 AM
>>>>
>>>> On Wed, Nov 21, 2018 at 8:18 AM Jim Lemon < [hidden email]> wrote:
>>>>
>>>>> I assume that you are importing the Excel sheets separately. When you
>>>>> import a sheet, you can get the number of columns with this:
>>>>>
>>>>> ncol(<name of data frame>)
>>>>>
>>>>> Using the data frame "mpg" that I created:
>>>>>
>>>>> ncolumns<ncol(mpg)
>>>>> ncolumns
>>>>> [1] 38
>>>>>
>>>>> You can then substitute "ncolumns" each time you import another sheet.
>>>>> How you want to deal with the varying numbers of columns you will get is
>>>>> another matter. One way is to work out the total number of plots you want
>>>>> and put them all onto one PDF page. Say you have 50 plots overall. You
>>>>> could start a very big PDF page:
>>>>>
>>>>> pdf("allplots.pdf",width=30,height=15)
>>>>> par(mfrow=c(5,10))
>>>>> # import your first sheet here (38 columns)
>>>>> ncolumns<ncol(mpg)
>>>>> for(i in 1:ncolumns)
>>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>>> ylab="MPG",main=names(mpg)[i])# import your second sheet here, say
>>>>> 10 columns
>>>>> # import your second sheet here, (10 columns)
>>>>> ncolumns<ncol(mpg1)
>>>>> for(i in 1:ncolumns)
>>>>> plot(seq(1,500,length.out=10),mpg1[,i],type="l",xlab="Distance",
>>>>> ylab="MPG",main=names(mpg)[i])# import your third sheet here, say 2
>>>>> columns
>>>>> # import your second sheet here, (2 columns)
>>>>> ncolumns<ncol(mpg2)
>>>>> for(i in 1:ncolumns)
>>>>> plot(seq(1,500,length.out=10),mpg2[,i],type="l",xlab="Distance",
>>>>> ylab="MPG",main=names(mpg)[i])
>>>>> # finish plotting
>>>>> dev.off()
>>>>>
>>>>> You would then have 50 plots on the PDF page. I am assuming that all
>>>>> of your sheets have the same number of rows and a few other things. This
>>>>> seems like a lot of plots, and I suspect that you could work out a better
>>>>> way to display all this information.
>>>>>
>>>>> Jim
>>>>>
>>>>>
>>>>> On Wed, Nov 21, 2018 at 1:20 PM Subhamitra Patra <
>>>>> [hidden email]> wrote:
>>>>>
>>>>>> Hello Sir,
>>>>>>
>>>>>> Thanks, now I understood and will check them out.
>>>>>>
>>>>>> One more thing I want to ask that I have 1 excel file with multiple
>>>>>> (i.e. 12 sheets). Each sheet contains different number of columns, for
>>>>>> instance, 1st sheet contains 38 columns, 2nd sheet contains 10 columns,
>>>>>> Third 2 columns, 4th 1 column and so on. Actually, due to some missing
>>>>>> observations in these columns, I couldn't add them in 1 sheet.
>>>>>>
>>>>>> As you suggested the below code in the last mail,
>>>>>>
>>>>>> par(mfrow=c(4,10))
>>>>>> for(i in 1:38)
>>>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>>>> ylab="MPG",main=names(mpg)[i])
>>>>>> dev.off()
>>>>>>
>>>>>> Do I need to run the code separately for each sheet?
>>>>>>
>>>>>> Actually, in par (mfrow=c(4,10)), the plot for 38 columns will be
>>>>>> added, the space for extra 2 will remain as empty. So, I thought to add
>>>>>> plots for the columns from the next sheet in those emptied space.
>>>>>>
>>>>>> Is there any way that I can add plots from the next sheets of the
>>>>>> same excel file in the emptied space? In other words, Is there any way to
>>>>>> append plots from all sheets?
>>>>>>
>>>>>> Kindly help a new R learner Sir for which I shall be always grateful
>>>>>> to you.
>>>>>>
>>>>>> Thank you very much for your kind help.
>>>>>>
>>>>>>
>>>>>>
>>>>>> [image: Mailtrack]
>>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>>>>> notified by
>>>>>> Mailtrack
>>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>>>>> 7:30:30 AM
>>>>>>
>>>>>> On Wed, Nov 21, 2018 at 7:17 AM Jim Lemon < [hidden email]>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Subhamitra,
>>>>>>>
>>>>>>> 1. Here I manufacture some data so that the example is
>>>>>>> "reproducible", that is anyone can run the code and get the same output
>>>>>>> that I do. Yes, veh1...veh38 are the names of the variables.
>>>>>>>
>>>>>>> 2. Here I join the 38 variables I created into a data frame, which I
>>>>>>> think is the input for your plotting routine. This names of the columns of
>>>>>>> the data frame become the names of the variables.
>>>>>>>
>>>>>>> When you say that you want the column names as the "header" (title)
>>>>>>> of each plot, I think if you change the plotting loop to this:
>>>>>>>
>>>>>>> pdf("mpg.pdf",width=30,height=12)
>>>>>>> par(mfrow=c(4,10))
>>>>>>> for(i in 1:38)
>>>>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>>>>> ylab="MPG",main=names(mpg)[i])
>>>>>>> dev.off()
>>>>>>>
>>>>>>> you will get what you requested. Remember that I have done this in
>>>>>>> base graphics, not ggplot.
>>>>>>>
>>>>>>> Jim
>>>>>>>
>>>>>>> On Wed, Nov 21, 2018 at 12:37 PM Subhamitra Patra <
>>>>>>> [hidden email]> wrote:
>>>>>>>
>>>>>>>> Hello Sir,
>>>>>>>>
>>>>>>>> Thanks, I'll check them out.
>>>>>>>>
>>>>>>>> But, I am not understanding 2 points of your suggestion.
>>>>>>>>
>>>>>>>> 1. In the line,* "*for(i in 1:38) assign(paste0("veh",i),rep(sam
>>>>>>>> ple(10:35,1),10)+runif(10,4,*4))", *what veh, rep(sam
>>>>>>>> ple(10:35,1),10)+runif(10,4,4)) indicate? Here veh indicates
>>>>>>>> columns right?
>>>>>>>> *2. In the
>>>>>>>> line, mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,*
>>>>>>>> * veh11,veh12,veh13,veh14,**veh15,veh16,veh17,veh18,veh19,**veh20,*
>>>>>>>> * veh21,veh22,veh23,veh24,**veh25,veh26,veh27,veh28,veh29,**veh30,*
>>>>>>>> * veh31,veh32,veh33,veh34,**veh35,veh36,veh37,veh38) ** , *veh[i]
>>>>>>>> indicates column sequence, right? I need to give column names as the header
>>>>>>>> of their respective graphs. Please suggest me How to add this?
>>>>>>>>
>>>>>>>>
>>>>>>>> I am very new to R and therefore asking you these queries which
>>>>>>>> might be simple for you.
>>>>>>>>
>>>>>>>> I expect positive help from you.
>>>>>>>>
>>>>>>>> Thanks for your kind help.
>>>>>>>> [image: Mailtrack]
>>>>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>>>>>>> notified by
>>>>>>>> Mailtrack
>>>>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>>>>>>> 7:02:18 AM
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, Nov 21, 2018 at 4:38 AM Jim Lemon < [hidden email]>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi Subhamitra,
>>>>>>>>> As Bert noted, you are mixing base and grid graphics. Here is a
>>>>>>>>> simple
>>>>>>>>> way to get a plot like what you described. It will probably take
>>>>>>>>> more
>>>>>>>>> work to find what you actually do want and discover how to get it.
>>>>>>>>>
>>>>>>>>> for(i in 1:38)
>>>>>>>>> assign(paste0("veh",i),rep(sample(10:35,1),10)+runif(10,4,4))
>>>>>>>>> mpg<data.frame(veh1,veh2,veh3,veh4,veh5,veh6,veh7,veh8,veh9,veh10,
>>>>>>>>> veh11,veh12,veh13,veh14,veh15,veh16,veh17,veh18,veh19,veh20,
>>>>>>>>> veh21,veh22,veh23,veh24,veh25,veh26,veh27,veh28,veh29,veh30,
>>>>>>>>> veh31,veh32,veh33,veh34,veh35,veh36,veh37,veh38)
>>>>>>>>> pdf("mpg.pdf",width=30,height=12)
>>>>>>>>> par(mfrow=c(4,10))
>>>>>>>>> for(i in 1:38)
>>>>>>>>> plot(seq(1,500,length.out=10),mpg[,i],type="l",xlab="Distance",
>>>>>>>>> ylab=names(mpg)[i],main="MPG by distance")
>>>>>>>>> dev.off()
>>>>>>>>>
>>>>>>>>> Jim
>>>>>>>>>
>>>>>>>>> On Wed, Nov 21, 2018 at 5:19 AM Subhamitra Patra
>>>>>>>>> < [hidden email]> wrote:
>>>>>>>>> >
>>>>>>>>> > Dear R users,
>>>>>>>>> >
>>>>>>>>> > I have one excel file with 5 sheets. The no. of columns vary for
>>>>>>>>> each
>>>>>>>>> > sheet. The 1st sheet consists of 38 columns. So, I want to plot
>>>>>>>>> 38 separate
>>>>>>>>> > line charts and arrange them in par(mfrow = c(4, 10)) order.
>>>>>>>>> Please suggest
>>>>>>>>> > me how to do this. I have tried with the following code by
>>>>>>>>> running a loop
>>>>>>>>> > inside of a sheet, but it is not working. Further, I want to run
>>>>>>>>> loops for
>>>>>>>>> > each sheet.
>>>>>>>>> >
>>>>>>>>> > par(mfrow = c(4, 10))
>>>>>>>>> > loop.vector < 1:38
>>>>>>>>> > for (i in loop.vector)
>>>>>>>>> > x < JJ[,i]
>>>>>>>>> > library(ggplot2)
>>>>>>>>> > library(cowplot)
>>>>>>>>> > plot.mpg < ggplot(mpg, aes(x,
>>>>>>>>> > main = paste ("country", i),
>>>>>>>>> > xlab = "Scores",
>>>>>>>>> > xlim = c(1,500)
>>>>>>>>> > y = colnames[i,], colour =
>>>>>>>>> factor(cyl))) +
>>>>>>>>> > geom_line(size=2.5)
>>>>>>>>> > save_plot("mpg.png", plot.mpg,
>>>>>>>>> > base_aspect_ratio = 1.3)
>>>>>>>>> >
>>>>>>>>> > I want to give my X axis name as scores of (1,500) and Y axis as
>>>>>>>>> the
>>>>>>>>> > particular column names for all graphs.
>>>>>>>>> >
>>>>>>>>> > Please suggest.
>>>>>>>>> >
>>>>>>>>> > Thanks in advance.
>>>>>>>>> >
>>>>>>>>> > 
>>>>>>>>> > *Best Regards,*
>>>>>>>>> > *Subhamitra Patra*
>>>>>>>>> > *Phd. Research Scholar*
>>>>>>>>> > *Department of Humanities and Social Sciences*
>>>>>>>>> > *Indian Institute of Technology, Kharagpur*
>>>>>>>>> > *INDIA*
>>>>>>>>> >
>>>>>>>>> >
>>>>>>>>> >
>>>>>>>>> >
>>>>>>>>> >
>>>>>>>>> >
>>>>>>>>> >
>>>>>>>>> >
>>>>>>>>> > [image: Mailtrack]
>>>>>>>>> > <
>>>>>>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>>>>>>>> >
>>>>>>>>> > Sender
>>>>>>>>> > notified by
>>>>>>>>> > Mailtrack
>>>>>>>>> > <
>>>>>>>>> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>>>>>>>>> >
>>>>>>>>> > 11/20/18,
>>>>>>>>> > 11:49:42 PM
>>>>>>>>> >
>>>>>>>>> > [[alternative HTML version deleted]]
>>>>>>>>> >
>>>>>>>>> > ______________________________________________
>>>>>>>>> > [hidden email] mailing list  To UNSUBSCRIBE and more,
>>>>>>>>> see
>>>>>>>>> > https://stat.ethz.ch/mailman/listinfo/rhelp>>>>>>>>> > PLEASE do read the posting guide
>>>>>>>>> http://www.Rproject.org/postingguide.html>>>>>>>>> > and provide commented, minimal, selfcontained, reproducible
>>>>>>>>> code.
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 
>>>>>>>> *Best Regards,*
>>>>>>>> *Subhamitra Patra*
>>>>>>>> *Phd. Research Scholar*
>>>>>>>> *Department of Humanities and Social Sciences*
>>>>>>>> *Indian Institute of Technology, Kharagpur*
>>>>>>>> *INDIA*
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>> 
>>>>>> *Best Regards,*
>>>>>> *Subhamitra Patra*
>>>>>> *Phd. Research Scholar*
>>>>>> *Department of Humanities and Social Sciences*
>>>>>> *Indian Institute of Technology, Kharagpur*
>>>>>> *INDIA*
>>>>>>
>>>>>
>>>>
>>>> 
>>>> *Best Regards,*
>>>> *Subhamitra Patra*
>>>> *Phd. Research Scholar*
>>>> *Department of Humanities and Social Sciences*
>>>> *Indian Institute of Technology, Kharagpur*
>>>> *INDIA*
>>>>
>>>
>>
>> 
>> *Best Regards,*
>> *Subhamitra Patra*
>> *Phd. Research Scholar*
>> *Department of Humanities and Social Sciences*
>> *Indian Institute of Technology, Kharagpur*
>> *INDIA*
>>
>

*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


1. xaxt="n" means "Don't display the X axis". See the help for "par" in the
graphics package
2. axis(1,at=1:nrows,labels=names(MPG3))
This means, "Display the bottom axis (1) with ticks at 1 to the number of
rows in the data frame"
"Use the values of MPG$Year as labels for the ticks". see the help for
"axis" in the graphics package
Note that this should be in the same loop as "plot"
Now I can see that my guess at the structure of the data was wrong. What
you could do is to collapse the daily records into the means for the years.
As I don't know what your spreadsheet looks like, I could only guess a
method for this.
You seem to be saying that you plot all 5655 values, but you want the axis
to show just the years.Rather than tell you to convert your data to a time
series, I'll suggest a quick hack.
axis(1,at=seq(1,5655,by=365),labels=1994:2014)
This _may_ work for you. I offer it because I can see that you do not have
a lot of experience in R and you want to get the job done. If you can't get
it to work, I apologize and you can blamelessly move to something else.
Jim
PS  If you don't know how to start HTML help  help.start()
On Wed, Nov 21, 2018 at 7:26 PM Subhamitra Patra < [hidden email]>
wrote:
> Sir, in the bold portion of the below code, I have some confusion which I
> am mentioning below that
>
> "ylab="MPG",main=names(MPG3)[i],*xaxt="n"*)
> axis(*1*,at=1:nrows,*labels=MPG3$Year*)"
>
> 1. Here, what *xaxt="n"* indicates? I think it indicates the no. of rows,
> right?
> 2. 1 in the 2nd line represents the no. of graphs. Let suppose, 38
> plots are having the same row, I need to mention them as *axis(38,
> at=1:nrows)*, right?
> 3. *labels=**MPG3$Year *will give the name of all years in the Xaxis,
> right?
>
> Kindly correct me if I am wrong.
>
> Sir, here one thing I would like to ask, my data frequency is not yearly.
> I obtained results from the daily data of the period from 19942017 (that
> means the no. of rows will be 5655). But, as the daily period is very
> unclear to mention in the Xaxis, I wanted to give year name as the name of
> the Xaxis (that means, 1995, 1997, 1999 with the increment of 2 years up
> to 2017).
>
> Sir, please suggest me how to proceed with this?
>
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


OK, Sir. I will try as per your suggestions.
Thank you very much for your kind help.
[image: Mailtrack]
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
11/21/18,
3:07:47 PM
On Wed, Nov 21, 2018 at 2:41 PM Jim Lemon < [hidden email]> wrote:
> 1. xaxt="n" means "Don't display the X axis". See the help for "par" in
> the graphics package
>
> 2. axis(1,at=1:nrows,labels=names(MPG3))
> This means, "Display the bottom axis (1) with ticks at 1 to the number of
> rows in the data frame"
> "Use the values of MPG$Year as labels for the ticks". see the help for
> "axis" in the graphics package
> Note that this should be in the same loop as "plot"
>
> Now I can see that my guess at the structure of the data was wrong. What
> you could do is to collapse the daily records into the means for the years.
> As I don't know what your spreadsheet looks like, I could only guess a
> method for this.
>
> You seem to be saying that you plot all 5655 values, but you want the axis
> to show just the years.Rather than tell you to convert your data to a time
> series, I'll suggest a quick hack.
>
> axis(1,at=seq(1,5655,by=365),labels=1994:2014)
>
> This _may_ work for you. I offer it because I can see that you do not have
> a lot of experience in R and you want to get the job done. If you can't get
> it to work, I apologize and you can blamelessly move to something else.
>
> Jim
>
> PS  If you don't know how to start HTML help  help.start()
>
> On Wed, Nov 21, 2018 at 7:26 PM Subhamitra Patra <
> [hidden email]> wrote:
>
>> Sir, in the bold portion of the below code, I have some confusion which
>> I am mentioning below that
>>
>> "ylab="MPG",main=names(MPG3)[i],*xaxt="n"*)
>> axis(*1*,at=1:nrows,*labels=MPG3$Year*)"
>>
>> 1. Here, what *xaxt="n"* indicates? I think it indicates the no. of
>> rows, right?
>> 2. 1 in the 2nd line represents the no. of graphs. Let suppose, 38
>> plots are having the same row, I need to mention them as *axis(38,
>> at=1:nrows)*, right?
>> 3. *labels=**MPG3$Year *will give the name of all years in the Xaxis,
>> right?
>>
>> Kindly correct me if I am wrong.
>>
>> Sir, here one thing I would like to ask, my data frequency is not yearly.
>> I obtained results from the daily data of the period from 19942017 (that
>> means the no. of rows will be 5655). But, as the daily period is very
>> unclear to mention in the Xaxis, I wanted to give year name as the name of
>> the Xaxis (that means, 1995, 1997, 1999 with the increment of 2 years up
>> to 2017).
>>
>> Sir, please suggest me how to proceed with this?
>>
>>

*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Dear Sir,
The method you suggested for arranging multiple plots in 1 pdf page has
finally worked.
Thank you very much.
But, I have 3 more queries as follows.
1. Is there any way that I can merge the respective plots from the
different excel files into 1? For instance, I have 3 excel files (i.e. EMs
1, EMs 2 and EMs 3) having 4 plots each. I want to merge 1st plots from 3
excel files into 1, 2nd plots from 3 excel files into 1, similarly 3rd and
4th plots from each respective files into 1?
2. Is there any way to range the scale of Yaxis for all plots because I
think if the range of the Yaxis for each plot is same, it can be easy to
interpret and compare the results. I used Ylim function. But, after using
the Ylim function, the plot is looking unclear than before. For your
convenience, I am providing my code.
pdf("EMs.pdf",width=20,height=20)
par(mfrow=c(5,4))
# import your first sheet here (38 columns)
ncolumns<ncol(EMs1)
for(i in 1:ncolumns)
plot(EMs1[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", ylim=c(0.1,2), main=names(EMs1)[i])
library(zoo)
*APEn=zoo(EMs1, seq(from = as.Date("19940101"), to =
as.Date("20170803"), by = 1))*
#import your second sheet here, (10 columns)
ncolumns<ncol(EMs2)
for(i in 1:ncolumns)
plot(EMs2[,i],type="l",col = "Red", xlab="Time",
ylab="APEn",ylim=c(0.1,2), main=names(EMs2)[i])
*APEn=zoo(EMs2, seq(from = as.Date("19940101"), to =
as.Date("20170803"), by = 1))*
# import your Third sheet here, (2 columns)
ncolumns<ncol(EMs3)
for(i in 1:ncolumns)
plot(EMs3[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", ylim=c(0.1,2), main=names(EMs3)[i])
*APEn=zoo(EMs3, seq(from = as.Date("19960101"), to =
as.Date("20170803"), by = 1)) *
# finish plotting
dev.off()
3. I want the corresponding date column (which is the daily date) on Xaxis
of each plot. Thus, I added 1 line after the plot in the above (i.e. the
bold line). Please suggest me Is it the correct way that I am doing?
Sir, I am new in R and doing by learning.
Kindly suggest me regarding my previous queries for which I shall be always
grateful to you.
Thank you very much for educating a new R learner.
On Wed, Nov 21, 2018 at 3:20 PM Subhamitra Patra < [hidden email]>
wrote:
> Thank you very much for your suggestions and help.
>
> [image: Mailtrack]
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
> notified by
> Mailtrack
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
> 3:19:55 PM
>
> On Wed, Nov 21, 2018 at 3:09 PM Subhamitra Patra <
> [hidden email]> wrote:
>
>> OK, Sir. I will try as per your suggestions.
>>
>> Thank you very much for your kind help.
>>
>> [image: Mailtrack]
>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>> notified by
>> Mailtrack
>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>> 3:07:47 PM
>>
>> On Wed, Nov 21, 2018 at 2:41 PM Jim Lemon < [hidden email]> wrote:
>>
>>> 1. xaxt="n" means "Don't display the X axis". See the help for "par" in
>>> the graphics package
>>>
>>> 2. axis(1,at=1:nrows,labels=names(MPG3))
>>> This means, "Display the bottom axis (1) with ticks at 1 to the number
>>> of rows in the data frame"
>>> "Use the values of MPG$Year as labels for the ticks". see the help for
>>> "axis" in the graphics package
>>> Note that this should be in the same loop as "plot"
>>>
>>> Now I can see that my guess at the structure of the data was wrong. What
>>> you could do is to collapse the daily records into the means for the years.
>>> As I don't know what your spreadsheet looks like, I could only guess a
>>> method for this.
>>>
>>> You seem to be saying that you plot all 5655 values, but you want the
>>> axis to show just the years.Rather than tell you to convert your data to a
>>> time series, I'll suggest a quick hack.
>>>
>>> axis(1,at=seq(1,5655,by=365),labels=1994:2014)
>>>
>>> This _may_ work for you. I offer it because I can see that you do not
>>> have a lot of experience in R and you want to get the job done. If you
>>> can't get it to work, I apologize and you can blamelessly move to something
>>> else.
>>>
>>> Jim
>>>
>>> PS  If you don't know how to start HTML help  help.start()
>>>
>>> On Wed, Nov 21, 2018 at 7:26 PM Subhamitra Patra <
>>> [hidden email]> wrote:
>>>
>>>> Sir, in the bold portion of the below code, I have some confusion
>>>> which I am mentioning below that
>>>>
>>>> "ylab="MPG",main=names(MPG3)[i],*xaxt="n"*)
>>>> axis(*1*,at=1:nrows,*labels=MPG3$Year*)"
>>>>
>>>> 1. Here, what *xaxt="n"* indicates? I think it indicates the no. of
>>>> rows, right?
>>>> 2. 1 in the 2nd line represents the no. of graphs. Let suppose, 38
>>>> plots are having the same row, I need to mention them as *axis(38,
>>>> at=1:nrows)*, right?
>>>> 3. *labels=**MPG3$Year *will give the name of all years in the Xaxis,
>>>> right?
>>>>
>>>> Kindly correct me if I am wrong.
>>>>
>>>> Sir, here one thing I would like to ask, my data frequency is not
>>>> yearly. I obtained results from the daily data of the period from
>>>> 19942017 (that means the no. of rows will be 5655). But, as the daily
>>>> period is very unclear to mention in the Xaxis, I wanted to give year name
>>>> as the name of the Xaxis (that means, 1995, 1997, 1999 with the increment
>>>> of 2 years up to 2017).
>>>>
>>>> Sir, please suggest me how to proceed with this?
>>>>
>>>>
>>
>> 
>> *Best Regards,*
>> *Subhamitra Patra*
>> *Phd. Research Scholar*
>> *Department of Humanities and Social Sciences*
>> *Indian Institute of Technology, Kharagpur*
>> *INDIA*
>>
>
>
> 
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>

*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi Subhamitra,
As before, I don't have your data, so I cannot run your code. Similarly,
when you say the plot is looking unclear, I have almost no idea what that
means in terms of a plot that I could see and possibly correct. Let's start
at the top anyway. You set up an array of 20 plots, then plot 38 series.
This is going to cycle through your array almost twice, as each time you
plot, you step forward one plot in the array. At the end of the first Excel
data sheet, you will be at plot 18 out of the 20. You then display another
10 plots, leaving you at plot 8 in the array. Each time you plot into the
same section of the array, you will wipe out the previous plot. Maybe this
is why you are not getting what you want. Finally, you display a further
two plots, leaving you at plot 10. If I am correct, you will have plots 31
to 38 from sheet 1 in the bottom two rows, with plots 1 and 2 from sheet
two in positions 19 and 20, then 3 to 10 from sheet 2 in the top rows,
finishing off with the two plots from sheet 3 in the 9th and 10th positions
in the second row of the plot array. Of course I can't see what you
actually have plotted, so this is but a desperate guess. I apologize for
the complicated answer which is probably no use whatever, but without data
and hopefully the output of your code, I am unable to read your mind.
Jim
On Fri, Dec 14, 2018 at 4:26 PM Subhamitra Patra < [hidden email]>
wrote:
> Sorry not previous queries, the 3 queries which I mentioned in my last
> email.
>
> On Fri, Dec 14, 2018 at 10:52 AM Subhamitra Patra <
> [hidden email]> wrote:
>
>> Dear Sir,
>>
>> The method you suggested for arranging multiple plots in 1 pdf page has
>> finally worked.
>>
>> Thank you very much.
>>
>> But, I have 3 more queries as follows.
>>
>> 1. Is there any way that I can merge the respective plots from the
>> different excel files into 1? For instance, I have 3 excel files (i.e. EMs
>> 1, EMs 2 and EMs 3) having 4 plots each. I want to merge 1st plots from 3
>> excel files into 1, 2nd plots from 3 excel files into 1, similarly 3rd and
>> 4th plots from each respective files into 1?
>> 2. Is there any way to range the scale of Yaxis for all plots because I
>> think if the range of the Yaxis for each plot is same, it can be easy to
>> interpret and compare the results. I used Ylim function. But, after using
>> the Ylim function, the plot is looking unclear than before. For your
>> convenience, I am providing my code.
>>
>> pdf("EMs.pdf",width=20,height=20)
>> par(mfrow=c(5,4))
>> # import your first sheet here (38 columns)
>> ncolumns<ncol(EMs1)
>> for(i in 1:ncolumns)
>> plot(EMs1[,i],type="l",col = "Red", xlab="Time",
>> ylab="APEn", ylim=c(0.1,2), main=names(EMs1)[i])
>> library(zoo)
>> *APEn=zoo(EMs1, seq(from = as.Date("19940101"), to =
>> as.Date("20170803"), by = 1))*
>> #import your second sheet here, (10 columns)
>> ncolumns<ncol(EMs2)
>> for(i in 1:ncolumns)
>> plot(EMs2[,i],type="l",col = "Red", xlab="Time",
>> ylab="APEn",ylim=c(0.1,2), main=names(EMs2)[i])
>> *APEn=zoo(EMs2, seq(from = as.Date("19940101"), to =
>> as.Date("20170803"), by = 1))*
>> # import your Third sheet here, (2 columns)
>> ncolumns<ncol(EMs3)
>> for(i in 1:ncolumns)
>> plot(EMs3[,i],type="l",col = "Red", xlab="Time",
>> ylab="APEn", ylim=c(0.1,2), main=names(EMs3)[i])
>> *APEn=zoo(EMs3, seq(from = as.Date("19960101"), to =
>> as.Date("20170803"), by = 1)) *
>> # finish plotting
>> dev.off()
>>
>> 3. I want the corresponding date column (which is the daily date) on
>> Xaxis of each plot. Thus, I added 1 line after the plot in the above (i.e.
>> the bold line). Please suggest me Is it the correct way that I am doing?
>>
>>
>> Sir, I am new in R and doing by learning.
>>
>> Kindly suggest me regarding my previous queries for which I shall be
>> always grateful to you.
>>
>> Thank you very much for educating a new R learner.
>>
>>
>>
>>
>> On Wed, Nov 21, 2018 at 3:20 PM Subhamitra Patra <
>> [hidden email]> wrote:
>>
>>> Thank you very much for your suggestions and help.
>>>
>>> [image: Mailtrack]
>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>> notified by
>>> Mailtrack
>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>> 3:19:55 PM
>>>
>>> On Wed, Nov 21, 2018 at 3:09 PM Subhamitra Patra <
>>> [hidden email]> wrote:
>>>
>>>> OK, Sir. I will try as per your suggestions.
>>>>
>>>> Thank you very much for your kind help.
>>>>
>>>> [image: Mailtrack]
>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>>> notified by
>>>> Mailtrack
>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>>> 3:07:47 PM
>>>>
>>>> On Wed, Nov 21, 2018 at 2:41 PM Jim Lemon < [hidden email]> wrote:
>>>>
>>>>> 1. xaxt="n" means "Don't display the X axis". See the help for "par"
>>>>> in the graphics package
>>>>>
>>>>> 2. axis(1,at=1:nrows,labels=names(MPG3))
>>>>> This means, "Display the bottom axis (1) with ticks at 1 to the number
>>>>> of rows in the data frame"
>>>>> "Use the values of MPG$Year as labels for the ticks". see the help for
>>>>> "axis" in the graphics package
>>>>> Note that this should be in the same loop as "plot"
>>>>>
>>>>> Now I can see that my guess at the structure of the data was wrong.
>>>>> What you could do is to collapse the daily records into the means for the
>>>>> years. As I don't know what your spreadsheet looks like, I could only guess
>>>>> a method for this.
>>>>>
>>>>> You seem to be saying that you plot all 5655 values, but you want the
>>>>> axis to show just the years.Rather than tell you to convert your data to a
>>>>> time series, I'll suggest a quick hack.
>>>>>
>>>>> axis(1,at=seq(1,5655,by=365),labels=1994:2014)
>>>>>
>>>>> This _may_ work for you. I offer it because I can see that you do not
>>>>> have a lot of experience in R and you want to get the job done. If you
>>>>> can't get it to work, I apologize and you can blamelessly move to something
>>>>> else.
>>>>>
>>>>> Jim
>>>>>
>>>>> PS  If you don't know how to start HTML help  help.start()
>>>>>
>>>>> On Wed, Nov 21, 2018 at 7:26 PM Subhamitra Patra <
>>>>> [hidden email]> wrote:
>>>>>
>>>>>> Sir, in the bold portion of the below code, I have some confusion
>>>>>> which I am mentioning below that
>>>>>>
>>>>>> "ylab="MPG",main=names(MPG3)[i],*xaxt="n"*)
>>>>>> axis(*1*,at=1:nrows,*labels=MPG3$Year*)"
>>>>>>
>>>>>> 1. Here, what *xaxt="n"* indicates? I think it indicates the no. of
>>>>>> rows, right?
>>>>>> 2. 1 in the 2nd line represents the no. of graphs. Let suppose, 38
>>>>>> plots are having the same row, I need to mention them as *axis(38,
>>>>>> at=1:nrows)*, right?
>>>>>> 3. *labels=**MPG3$Year *will give the name of all years in the
>>>>>> Xaxis, right?
>>>>>>
>>>>>> Kindly correct me if I am wrong.
>>>>>>
>>>>>> Sir, here one thing I would like to ask, my data frequency is not
>>>>>> yearly. I obtained results from the daily data of the period from
>>>>>> 19942017 (that means the no. of rows will be 5655). But, as the daily
>>>>>> period is very unclear to mention in the Xaxis, I wanted to give year name
>>>>>> as the name of the Xaxis (that means, 1995, 1997, 1999 with the increment
>>>>>> of 2 years up to 2017).
>>>>>>
>>>>>> Sir, please suggest me how to proceed with this?
>>>>>>
>>>>>>
>>>>
>>>> 
>>>> *Best Regards,*
>>>> *Subhamitra Patra*
>>>> *Phd. Research Scholar*
>>>> *Department of Humanities and Social Sciences*
>>>> *Indian Institute of Technology, Kharagpur*
>>>> *INDIA*
>>>>
>>>
>>>
>>> 
>>> *Best Regards,*
>>> *Subhamitra Patra*
>>> *Phd. Research Scholar*
>>> *Department of Humanities and Social Sciences*
>>> *Indian Institute of Technology, Kharagpur*
>>> *INDIA*
>>>
>>
>>
>> 
>> *Best Regards,*
>> *Subhamitra Patra*
>> *Phd. Research Scholar*
>> *Department of Humanities and Social Sciences*
>> *Indian Institute of Technology, Kharagpur*
>> *INDIA*
>>
>
>
> 
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hello Sir,
I am extremely Sorry for the late reply.
Ok now, I am sending my data and output, and would like to discuss my
queries one by one.
This is my final code.
pdf("EMs.pdf",width=20,height=20)
par(mfrow=c(5,4))
# import your first sheet here (16 columns)
ncolumns<ncol(EMs1.1)
for(i in 1:ncolumns)
plot(EMs1.1[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", main=names(EMs1.1)[i])
#import your second sheet here, (1 column)
ncolumns<ncol(EMs2.1)
for(i in 1:ncolumns)
plot(EMs2.1[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", main=names(EMs2.1)[i])
# import your Third sheet here, (1 column)
ncolumns<ncol(EMs3.1)
for(i in 1:ncolumns)
plot(EMs3.1[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", main=names(EMs3.1)[i])
# import your fourth sheet here, (1 column)
ncolumns<ncol(EMs4.1)
for(i in 1:ncolumns)
plot(EMs4.1[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", main=names(EMs4.1)[i])
# finish plotting
dev.off()
With this code, I found the following results. I attached The data files
(in rar file containing 4 excel files) and the output of my result.
*My First query is :*
I am having daily data, and without defining the date column, I obtained
the results. Therefore, I found the no. of observation in my Xaxis of the
plots (in the attached result Pdf file). Now, I need the date column in my
Xaxis with the corresponding data. I considered 03011994 to 03082017
(DateMonthYear) by excluding 2 nontrading days per week.
I know that the frequency for defining yearly data is 1. So, I tried with
the following code being attached to the plot code, but not sure that
whether It is giving the appropriate plot or not?
*library(zoo)*
*y=zoo(EMs1, seq(from = as.Date("19940101"), to = as.Date("20170803"),
by = 1))*
*Therefore, kindly suggest me instead of getting the no. of observations in
the Xaxis, how to get the date column in Xaxis? *
[image: Mailtrack]
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
12/15/18,
10:39:06 AM
On Fri, Dec 14, 2018 at 2:48 PM Jim Lemon < [hidden email]> wrote:
> Hi Subhamitra,
> As before, I don't have your data, so I cannot run your code. Similarly,
> when you say the plot is looking unclear, I have almost no idea what that
> means in terms of a plot that I could see and possibly correct. Let's start
> at the top anyway. You set up an array of 20 plots, then plot 38 series.
> This is going to cycle through your array almost twice, as each time you
> plot, you step forward one plot in the array. At the end of the first Excel
> data sheet, you will be at plot 18 out of the 20. You then display another
> 10 plots, leaving you at plot 8 in the array. Each time you plot into the
> same section of the array, you will wipe out the previous plot. Maybe this
> is why you are not getting what you want. Finally, you display a further
> two plots, leaving you at plot 10. If I am correct, you will have plots 31
> to 38 from sheet 1 in the bottom two rows, with plots 1 and 2 from sheet
> two in positions 19 and 20, then 3 to 10 from sheet 2 in the top rows,
> finishing off with the two plots from sheet 3 in the 9th and 10th positions
> in the second row of the plot array. Of course I can't see what you
> actually have plotted, so this is but a desperate guess. I apologize for
> the complicated answer which is probably no use whatever, but without data
> and hopefully the output of your code, I am unable to read your mind.
>
> Jim
>
>
> On Fri, Dec 14, 2018 at 4:26 PM Subhamitra Patra <
> [hidden email]> wrote:
>
>> Sorry not previous queries, the 3 queries which I mentioned in my last
>> email.
>>
>> On Fri, Dec 14, 2018 at 10:52 AM Subhamitra Patra <
>> [hidden email]> wrote:
>>
>>> Dear Sir,
>>>
>>> The method you suggested for arranging multiple plots in 1 pdf page has
>>> finally worked.
>>>
>>> Thank you very much.
>>>
>>> But, I have 3 more queries as follows.
>>>
>>> 1. Is there any way that I can merge the respective plots from the
>>> different excel files into 1? For instance, I have 3 excel files (i.e. EMs
>>> 1, EMs 2 and EMs 3) having 4 plots each. I want to merge 1st plots from 3
>>> excel files into 1, 2nd plots from 3 excel files into 1, similarly 3rd and
>>> 4th plots from each respective files into 1?
>>> 2. Is there any way to range the scale of Yaxis for all plots because I
>>> think if the range of the Yaxis for each plot is same, it can be easy to
>>> interpret and compare the results. I used Ylim function. But, after using
>>> the Ylim function, the plot is looking unclear than before. For your
>>> convenience, I am providing my code.
>>>
>>> pdf("EMs.pdf",width=20,height=20)
>>> par(mfrow=c(5,4))
>>> # import your first sheet here (38 columns)
>>> ncolumns<ncol(EMs1)
>>> for(i in 1:ncolumns)
>>> plot(EMs1[,i],type="l",col = "Red", xlab="Time",
>>> ylab="APEn", ylim=c(0.1,2), main=names(EMs1)[i])
>>> library(zoo)
>>> *APEn=zoo(EMs1, seq(from = as.Date("19940101"), to =
>>> as.Date("20170803"), by = 1))*
>>> #import your second sheet here, (10 columns)
>>> ncolumns<ncol(EMs2)
>>> for(i in 1:ncolumns)
>>> plot(EMs2[,i],type="l",col = "Red", xlab="Time",
>>> ylab="APEn",ylim=c(0.1,2), main=names(EMs2)[i])
>>> *APEn=zoo(EMs2, seq(from = as.Date("19940101"), to =
>>> as.Date("20170803"), by = 1))*
>>> # import your Third sheet here, (2 columns)
>>> ncolumns<ncol(EMs3)
>>> for(i in 1:ncolumns)
>>> plot(EMs3[,i],type="l",col = "Red", xlab="Time",
>>> ylab="APEn", ylim=c(0.1,2), main=names(EMs3)[i])
>>> *APEn=zoo(EMs3, seq(from = as.Date("19960101"), to =
>>> as.Date("20170803"), by = 1)) *
>>> # finish plotting
>>> dev.off()
>>>
>>> 3. I want the corresponding date column (which is the daily date) on
>>> Xaxis of each plot. Thus, I added 1 line after the plot in the above (i.e.
>>> the bold line). Please suggest me Is it the correct way that I am doing?
>>>
>>>
>>> Sir, I am new in R and doing by learning.
>>>
>>> Kindly suggest me regarding my previous queries for which I shall be
>>> always grateful to you.
>>>
>>> Thank you very much for educating a new R learner.
>>>
>>>
>>>
>>>
>>> On Wed, Nov 21, 2018 at 3:20 PM Subhamitra Patra <
>>> [hidden email]> wrote:
>>>
>>>> Thank you very much for your suggestions and help.
>>>>
>>>> [image: Mailtrack]
>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>>> notified by
>>>> Mailtrack
>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>>> 3:19:55 PM
>>>>
>>>> On Wed, Nov 21, 2018 at 3:09 PM Subhamitra Patra <
>>>> [hidden email]> wrote:
>>>>
>>>>> OK, Sir. I will try as per your suggestions.
>>>>>
>>>>> Thank you very much for your kind help.
>>>>>
>>>>> [image: Mailtrack]
>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
>>>>> notified by
>>>>> Mailtrack
>>>>> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 11/21/18,
>>>>> 3:07:47 PM
>>>>>
>>>>> On Wed, Nov 21, 2018 at 2:41 PM Jim Lemon < [hidden email]>
>>>>> wrote:
>>>>>
>>>>>> 1. xaxt="n" means "Don't display the X axis". See the help for "par"
>>>>>> in the graphics package
>>>>>>
>>>>>> 2. axis(1,at=1:nrows,labels=names(MPG3))
>>>>>> This means, "Display the bottom axis (1) with ticks at 1 to the
>>>>>> number of rows in the data frame"
>>>>>> "Use the values of MPG$Year as labels for the ticks". see the help
>>>>>> for "axis" in the graphics package
>>>>>> Note that this should be in the same loop as "plot"
>>>>>>
>>>>>> Now I can see that my guess at the structure of the data was wrong.
>>>>>> What you could do is to collapse the daily records into the means for the
>>>>>> years. As I don't know what your spreadsheet looks like, I could only guess
>>>>>> a method for this.
>>>>>>
>>>>>> You seem to be saying that you plot all 5655 values, but you want the
>>>>>> axis to show just the years.Rather than tell you to convert your data to a
>>>>>> time series, I'll suggest a quick hack.
>>>>>>
>>>>>> axis(1,at=seq(1,5655,by=365),labels=1994:2014)
>>>>>>
>>>>>> This _may_ work for you. I offer it because I can see that you do not
>>>>>> have a lot of experience in R and you want to get the job done. If you
>>>>>> can't get it to work, I apologize and you can blamelessly move to something
>>>>>> else.
>>>>>>
>>>>>> Jim
>>>>>>
>>>>>> PS  If you don't know how to start HTML help  help.start()
>>>>>>
>>>>>> On Wed, Nov 21, 2018 at 7:26 PM Subhamitra Patra <
>>>>>> [hidden email]> wrote:
>>>>>>
>>>>>>> Sir, in the bold portion of the below code, I have some confusion
>>>>>>> which I am mentioning below that
>>>>>>>
>>>>>>> "ylab="MPG",main=names(MPG3)[i],*xaxt="n"*)
>>>>>>> axis(*1*,at=1:nrows,*labels=MPG3$Year*)"
>>>>>>>
>>>>>>> 1. Here, what *xaxt="n"* indicates? I think it indicates the no. of
>>>>>>> rows, right?
>>>>>>> 2. 1 in the 2nd line represents the no. of graphs. Let suppose, 38
>>>>>>> plots are having the same row, I need to mention them as *axis(38,
>>>>>>> at=1:nrows)*, right?
>>>>>>> 3. *labels=**MPG3$Year *will give the name of all years in the
>>>>>>> Xaxis, right?
>>>>>>>
>>>>>>> Kindly correct me if I am wrong.
>>>>>>>
>>>>>>> Sir, here one thing I would like to ask, my data frequency is not
>>>>>>> yearly. I obtained results from the daily data of the period from
>>>>>>> 19942017 (that means the no. of rows will be 5655). But, as the daily
>>>>>>> period is very unclear to mention in the Xaxis, I wanted to give year name
>>>>>>> as the name of the Xaxis (that means, 1995, 1997, 1999 with the increment
>>>>>>> of 2 years up to 2017).
>>>>>>>
>>>>>>> Sir, please suggest me how to proceed with this?
>>>>>>>
>>>>>>>
>>>>>
>>>>> 
>>>>> *Best Regards,*
>>>>> *Subhamitra Patra*
>>>>> *Phd. Research Scholar*
>>>>> *Department of Humanities and Social Sciences*
>>>>> *Indian Institute of Technology, Kharagpur*
>>>>> *INDIA*
>>>>>
>>>>
>>>>
>>>> 
>>>> *Best Regards,*
>>>> *Subhamitra Patra*
>>>> *Phd. Research Scholar*
>>>> *Department of Humanities and Social Sciences*
>>>> *Indian Institute of Technology, Kharagpur*
>>>> *INDIA*
>>>>
>>>
>>>
>>> 
>>> *Best Regards,*
>>> *Subhamitra Patra*
>>> *Phd. Research Scholar*
>>> *Department of Humanities and Social Sciences*
>>> *Indian Institute of Technology, Kharagpur*
>>> *INDIA*
>>>
>>
>>
>> 
>> *Best Regards,*
>> *Subhamitra Patra*
>> *Phd. Research Scholar*
>> *Department of Humanities and Social Sciences*
>> *Indian Institute of Technology, Kharagpur*
>> *INDIA*
>>
>

*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi Subhamitra,
Thanks. Now I can provide some assistance instead of just complaining. Your
first problem is the temporal extent of the data. There are 8613 days and
6512 weekdays between the two dates you list, but only 5655 observations in
your data. Therefore it is unlikely that you have a complete data series,
or perhaps you have the wrong dates. For the moment I'll assume that there
are missing observations. What I am going to do is to match the 24 years
(19942017) to their approximate positions in the time series. This will
give you the xaxis labels that you want, close enough for this
illustration. I doubt that you will need anything more accurate. You have a
span of 24.58 years, which means that if your missing observations are
uniformly distributed, you will have almost exactly 226 observations per
year. When i tried this, I got too many intervals, so I increased the
increment to 229 and that worked. To get the positions for the middle of
each year in the indices of the data:
year_mids<seq(182,5655,by=229)
Now I suppress the xaxis by adding xaxt="n" to each call to plot. Then I
add a command to display the years at the positions I have calculated:
axis(1,at=year_mids,labels=1994:2017)
Also note that I have added braces to the "for" loop. Putting it all
together:
year_mids<seq(182,5655,by=229)
pdf("EMs.pdf",width=20,height=20)
par(mfrow=c(5,4))
# import your first sheet here (16 columns)
EMs1.1<read.csv("EMs1.1.csv")
ncolumns<ncol(EMs1.1)
for(i in 1:ncolumns) {
plot(EMs1.1[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", main=names(EMs1.1)[i],xaxt="n")
axis(1,at=year_mids,labels=1994:2017)
}
#import your second sheet here, (1 column)
EMs2.1<read.csv("EMs2.1.csv")
ncolumns<ncol(EMs2.1)
for(i in 1:ncolumns) {
plot(EMs2.1[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", main=names(EMs2.1)[i],xaxt="n")
axis(1,at=year_mids,labels=1994:2017)
}
# import your Third sheet here, (1 column)
EMs3.1<read.csv("EMs3.1.csv")
ncolumns<ncol(EMs3.1)
for(i in 1:ncolumns) {
plot(EMs3.1[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", main=names(EMs3.1)[i],xaxt="n")
axis(1,at=year_mids,labels=1994:2017)
}
# import your fourth sheet here, (1 column)
EMs4.1<read.csv("EMs4.1.csv")
ncolumns<ncol(EMs4.1)
for(i in 1:ncolumns) {
plot(EMs4.1[,i],type="l",col = "Red", xlab="Time",
ylab="APEn", main=names(EMs4.1)[i],xaxt="n")
axis(1,at=year_mids,labels=1994:2017)
}
# finish plotting
dev.off()
With any luck, you are now okay. Remember, this is a hack to deal with data
that are not what you think they are.
Jim
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thank you very much sir. Actually, I excluded all the nontrading days.
Therefore, Each year will have 226 observations and total 6154 observations
for each column. The data which I plotted is not rough data. I obtained the
rolling observations of window 500 from my original data. So, the no. of
observations for each resulted column is (6154500)+1=5655. So, It is not
accurate as per the days of calculations of each year.
Ok, Sir, I will go through your suggestion, obtain the results for each
column of my data and would like to discuss the results with you. After
solving of this problem, I would like to discuss another 2 queries.
Thank you very much Sir for educating a new R learner.
[image: Mailtrack]
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
12/16/18,
12:20:17 PM
On Sun, Dec 16, 2018 at 8:10 AM Jim Lemon < [hidden email]> wrote:
> Hi Subhamitra,
> Thanks. Now I can provide some assistance instead of just complaining.
> Your first problem is the temporal extent of the data. There are 8613 days
> and 6512 weekdays between the two dates you list, but only 5655
> observations in your data. Therefore it is unlikely that you have a
> complete data series, or perhaps you have the wrong dates. For the moment
> I'll assume that there are missing observations. What I am going to do is
> to match the 24 years (19942017) to their approximate positions in the
> time series. This will give you the xaxis labels that you want, close
> enough for this illustration. I doubt that you will need anything more
> accurate. You have a span of 24.58 years, which means that if your missing
> observations are uniformly distributed, you will have almost exactly 226
> observations per year. When i tried this, I got too many intervals, so I
> increased the increment to 229 and that worked. To get the positions for
> the middle of each year in the indices of the data:
>
> year_mids<seq(182,5655,by=229)
>
> Now I suppress the xaxis by adding xaxt="n" to each call to plot. Then I
> add a command to display the years at the positions I have calculated:
>
> axis(1,at=year_mids,labels=1994:2017)
>
> Also note that I have added braces to the "for" loop. Putting it all
> together:
>
> year_mids<seq(182,5655,by=229)
> pdf("EMs.pdf",width=20,height=20)
> par(mfrow=c(5,4))
> # import your first sheet here (16 columns)
> EMs1.1<read.csv("EMs1.1.csv")
> ncolumns<ncol(EMs1.1)
> for(i in 1:ncolumns) {
> plot(EMs1.1[,i],type="l",col = "Red", xlab="Time",
> ylab="APEn", main=names(EMs1.1)[i],xaxt="n")
> axis(1,at=year_mids,labels=1994:2017)
> }
> #import your second sheet here, (1 column)
> EMs2.1<read.csv("EMs2.1.csv")
> ncolumns<ncol(EMs2.1)
> for(i in 1:ncolumns) {
> plot(EMs2.1[,i],type="l",col = "Red", xlab="Time",
> ylab="APEn", main=names(EMs2.1)[i],xaxt="n")
> axis(1,at=year_mids,labels=1994:2017)
> }
> # import your Third sheet here, (1 column)
> EMs3.1<read.csv("EMs3.1.csv")
> ncolumns<ncol(EMs3.1)
> for(i in 1:ncolumns) {
> plot(EMs3.1[,i],type="l",col = "Red", xlab="Time",
> ylab="APEn", main=names(EMs3.1)[i],xaxt="n")
> axis(1,at=year_mids,labels=1994:2017)
> }
> # import your fourth sheet here, (1 column)
> EMs4.1<read.csv("EMs4.1.csv")
> ncolumns<ncol(EMs4.1)
> for(i in 1:ncolumns) {
> plot(EMs4.1[,i],type="l",col = "Red", xlab="Time",
> ylab="APEn", main=names(EMs4.1)[i],xaxt="n")
> axis(1,at=year_mids,labels=1994:2017)
> }
> # finish plotting
> dev.off()
>
> With any luck, you are now okay. Remember, this is a hack to deal with
> data that are not what you think they are.
>
> Jim
>
>

*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hello Sir,
I have three queries regarding your suggested code.
*1. *In my last email, I mentioned why there are missing observations in my
data series. In the line, *year_mids<seq(182,5655,by=229), *
*A. what 182 indicates and what is the logic behind the consideration of
229 increments, although there are 226 observations per year?*
*B. Each excel file is having different observations depending on the
variation of starting dates. So, is it required to add **year_mids in the
loop? I think I need to justify **year_mids object each time after
importing the individual excel files. If I am wrong, kindly correct me.*
2. Further, in the command* axis(1,at=year_mids,labels=1994:2017), 1
indicates the no. of increments of year name, right?*
Kindly clarify my queries Sir for which I shall be always grateful to you.
Thank you very much.
[image: Mailtrack]
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
< https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
12/16/18,
1:29:05 PM
On Sun, Dec 16, 2018 at 12:24 PM Subhamitra Patra <
[hidden email]> wrote:
> Thank you very much sir. Actually, I excluded all the nontrading days.
> Therefore, Each year will have 226 observations and total 6154 observations
> for each column. The data which I plotted is not rough data. I obtained the
> rolling observations of window 500 from my original data. So, the no. of
> observations for each resulted column is (6154500)+1=5655. So, It is not
> accurate as per the days of calculations of each year.
>
> Ok, Sir, I will go through your suggestion, obtain the results for each
> column of my data and would like to discuss the results with you. After
> solving of this problem, I would like to discuss another 2 queries.
>
> Thank you very much Sir for educating a new R learner.
>
> [image: Mailtrack]
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender
> notified by
> Mailtrack
> < https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 12/16/18,
> 12:20:17 PM
>
> On Sun, Dec 16, 2018 at 8:10 AM Jim Lemon < [hidden email]> wrote:
>
>> Hi Subhamitra,
>> Thanks. Now I can provide some assistance instead of just complaining.
>> Your first problem is the temporal extent of the data. There are 8613 days
>> and 6512 weekdays between the two dates you list, but only 5655
>> observations in your data. Therefore it is unlikely that you have a
>> complete data series, or perhaps you have the wrong dates. For the moment
>> I'll assume that there are missing observations. What I am going to do is
>> to match the 24 years (19942017) to their approximate positions in the
>> time series. This will give you the xaxis labels that you want, close
>> enough for this illustration. I doubt that you will need anything more
>> accurate. You have a span of 24.58 years, which means that if your missing
>> observations are uniformly distributed, you will have almost exactly 226
>> observations per year. When i tried this, I got too many intervals, so I
>> increased the increment to 229 and that worked. To get the positions for
>> the middle of each year in the indices of the data:
>>
>> year_mids<seq(182,5655,by=229)
>>
>> Now I suppress the xaxis by adding xaxt="n" to each call to plot. Then I
>> add a command to display the years at the positions I have calculated:
>>
>> axis(1,at=year_mids,labels=1994:2017)
>>
>> Also note that I have added braces to the "for" loop. Putting it all
>> together:
>>
>> year_mids<seq(182,5655,by=229)
>> pdf("EMs.pdf",width=20,height=20)
>> par(mfrow=c(5,4))
>> # import your first sheet here (16 columns)
>> EMs1.1<read.csv("EMs1.1.csv")
>> ncolumns<ncol(EMs1.1)
>> for(i in 1:ncolumns) {
>> plot(EMs1.1[,i],type="l",col = "Red", xlab="Time",
>> ylab="APEn", main=names(EMs1.1)[i],xaxt="n")
>> axis(1,at=year_mids,labels=1994:2017)
>> }
>> #import your second sheet here, (1 column)
>> EMs2.1<read.csv("EMs2.1.csv")
>> ncolumns<ncol(EMs2.1)
>> for(i in 1:ncolumns) {
>> plot(EMs2.1[,i],type="l",col = "Red", xlab="Time",
>> ylab="APEn", main=names(EMs2.1)[i],xaxt="n")
>> axis(1,at=year_mids,labels=1994:2017)
>> }
>> # import your Third sheet here, (1 column)
>> EMs3.1<read.csv("EMs3.1.csv")
>> ncolumns<ncol(EMs3.1)
>> for(i in 1:ncolumns) {
>> plot(EMs3.1[,i],type="l",col = "Red", xlab="Time",
>> ylab="APEn", main=names(EMs3.1)[i],xaxt="n")
>> axis(1,at=year_mids,labels=1994:2017)
>> }
>> # import your fourth sheet here, (1 column)
>> EMs4.1<read.csv("EMs4.1.csv")
>> ncolumns<ncol(EMs4.1)
>> for(i in 1:ncolumns) {
>> plot(EMs4.1[,i],type="l",col = "Red", xlab="Time",
>> ylab="APEn", main=names(EMs4.1)[i],xaxt="n")
>> axis(1,at=year_mids,labels=1994:2017)
>> }
>> # finish plotting
>> dev.off()
>>
>> With any luck, you are now okay. Remember, this is a hack to deal with
>> data that are not what you think they are.
>>
>> Jim
>>
>>
>
> 
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>

*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

12
