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

Subhamitra Patra @ubh@mitr@@p@tr@ @ending from gm@il@com
Sun Dec 16 09:03:35 CET 2018

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]
notified by
1:29:05 PM

On Sun, Dec 16, 2018 at 12:24 PM Subhamitra Patra <
subhamitra.patra using gmail.com> wrote:

> Thank you very much sir. Actually, I excluded all the non-trading 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 (6154-500)+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 <drjimlemon using gmail.com> 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 (1994-2017) to their approximate positions in the
>> time series. This will give you the x-axis 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 x-axis 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*

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

	[[alternative HTML version deleted]]

More information about the R-help mailing list