[R] [R studio] Plotting of line chart for each columns at 1 page

Subhamitra Patra @ubh@mitr@@p@tr@ @ending from gm@il@com
Wed Nov 21 02:37:49 CET 2018


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 <drjimlemon using gmail.com> 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
> <subhamitra.patra using gmail.com> 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]]
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>


-- 
*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*

	[[alternative HTML version deleted]]



More information about the R-help mailing list