[R] Please guide

Avi Gross @v|gro@@ @end|ng |rom ver|zon@net
Mon Jul 11 07:21:39 CEST 2022


Cultures differ and we can put up with it but the feedback you get is that plenty of parts of the wider world are not like Pakistan. We simply do not invent honorifics for people who we do not know for sure has earned them, and even then, many people do not want or need a title used when not in that job but just here helping out. If you want to keep calling us Professors, feel free. You have been notified many of us are not impressed and may act accordingly. I know people with more than one Doctorate who do not feel any need to use the titles.


But enough of that. Your level of understanding what you are doing is a bigger issue as you may not know enough to be easy to help. My guess is you got some code from someone and are trying to adapt it without knowing much. That works sometimes but maybe not now.

Anyone there can probably show you how to NOT SEND a huge EXCEL file because your problem probably will happen if you make a copy of your file and edit it and save just the first few rows and toss the rest. If you did that and your code still failed, you could cut and paste a small sample of the data, or even better do as Jeff suggested, albeit in this case, he needs to consider that if you are not reading in the data properly, how can you use dput() on an in-memory data structure and send us the output.


As Jeff pointed out, the part of your code you shared looked at two files and I assumed the error you reported was only for the second. But did you notice for the other file you did it in steps:

Data <- read_excel("Data_oil_agri.xlsx", sheet = "Sheet1")

You specifically asked for Sheet1 and the second time did not. Does that matter? Maybe not. But it is not consistent. You also removed the first column from that file another way:

Data <- Data[,2:22]


Just FYI, there is an easier way to remove a column by setting it to NULL as in

Data$ColNAME <- NULL  # if you know the name of the column

or: Data[,1] <- NULL
You do not need to know how many columns you have BUT the above only works if you properly have read in something. Your code for the other file probably did not read it in properly.
I suggest again making your code more like the above rather than one long complex one, so you can catch where it broke. My guess is earlier before you asked it to remove a non-existent column.



-----Original Message-----
From: Muhammad Zubair Chishti <mzchishti using eco.qau.edu.pk>
To: Jeff Newmiller <jdnewmil using dcn.davis.ca.us>; r-help using r-project.org
Sent: Mon, Jul 11, 2022 12:45 am
Subject: Re: [R] Please guide

Dear Jeff,
1) Being a PhD student, I am obliged to pay deep homage to all experts like
you on this forum who provide free knowledge.

2) Since the data is too large and I cannot cut it, I have no other
suitable option to send my full data.

3) This is the same file that I used in the codes mentioned in my
first email. The codes work well while using the data file I sent you till
this code line:

*sp_bk_roll <- spilloverRollingBK12(Data, n.ahead = 100, no.corr = F,
func_est = "VAR", params_est = params_est, window = 260, partition =
bounds)*

**Till now the code works well. After that, when I run the following:*

con      = as.matrix(read_excel("DY_Table.xlsx")[,-1])*100

*I face the following error:*
*Error in* *`vectbl_as_col_location()`:*
! Can't negate columns past the end.
ℹ Location 1 doesn't exist.
ℹ There are only 0 columns.
Run `rlang::last_error()` to see where the error occurred.

Now kindly check my issue.

Regards
Chishti

On Mon, Jul 11, 2022 at 9:30 AM Jeff Newmiller <jdnewmil using dcn.davis.ca.us>
wrote:

> 1) Thank you for trying to be respectful, but calling me a professor is
> not a good way to do that. I have no PhD, nor do I work for a university. A
> simple "Jeff" or if you prefer "Mr. Newmiller" will be fine
>
> 2) Because you replied to me, I can see your file, but no-one else on the
> list can... most attachments are removed by the mailing list. Do read the
> Posting Guide and try to embed data with dput rather than attaching things.
> Again, you limit the number of people who can help you by failing to use
> the list properly.
>
> 3) The name of the file you attached suggests that this is not the one
> that was causing you trouble. Your code references two different filenames.
>
> On July 10, 2022 8:50:23 PM PDT, Muhammad Zubair Chishti <
> mzchishti using eco.qau.edu.pk> wrote:
> >Dear Respected Professor,
> >You are right. I strongly agree with you. Besides, Thank you so much for
> >your kind reply. As you said, the data file mentioned in the above code is
> >attached herewith. Kindly consider my request.
> >
> > Data_oil_agri.xlsx
> ><
> https://drive.google.com/file/d/1heMlPfUtB-RthKYv4jRM3PGFI8CJ4fck/view?usp=drive_web
> >
> >
> >Regards
> >Muhammad Zubair Chishti
> >
> >On Sat, Jul 9, 2022 at 11:48 PM Jeff Newmiller <jdnewmil using dcn.davis.ca.us>
> >wrote:
> >
> >> This is a mailing list whose members are random people with an interest
> in
> >> R. We are not a tech support call center. If we have time, and you
> invest
> >> some effort into making it easier for us to reproduce your problem, then
> >> someone may respond... but no guarantees. Your current efforts are
> missing
> >> key elements that impede our efforts and there isn't much here to
> persuade
> >> many people to dig further. You may garner more responses if you make
> the
> >> following changes to your approach:
> >>
> >> 1) Make your example reproducible. We need access to the data you are
> >> working with, or at least a small fake similar data set. We don't have
> your
> >> Excel files... dead end for us. But see next point about files. Also,
> >> verify that your code can start from a fresh R environment and
> demonstrate
> >> your problem... the reprex package may be useful for this.
> >>
> >> 2) Make your example minimal. If you are having trouble with data
> >> importing, give us the data file or something similar that gives you the
> >> same error. If you are having trouble with data calculations or
> >> manipulations, then use dput [1] to give us a snippet of the data you
> are
> >> referring to in the troublesome line of code... don't give us a data
> file
> >> and a bunch of code that isn't giving you trouble before the error
> code...
> >> we don't want to wade through it.
> >>
> >> 3) Remove garbage from your posts (formatting). Look at the extra
> >> asterisks in your message as we see it [2]. We cannot run this code
> without
> >> guessing which symbols belong and which don't. I know you did not put
> them
> >> there intentionally, but neither did you disable HTML formatting in your
> >> email client when you composed the message, and that was responsible for
> >> the extra mess. The Posting Guide warns you to post plain text, and
> there
> >> are way too many email client programs out there for us to be able to
> tell
> >> you how to alter this setting... but it is essential that you do it if
> you
> >> want to encourage responses here.
> >>
> >> I considered not responding at all due to these deficiencies, but
> figured
> >> I would spell out the problems you have missed in the Posting Guide
> once.
> >> Mailing lists are tough ways to get help... but the expertise here is
> kind
> >> of rare. You decide whether to make things easy or hard for yourself.
> >>
> >> As for the "con =" line below, it seems to have nothing at all to do
> with
> >> the code or data referred to earlier. That would be a hint for point 2
> >> above. Try calling the read_excel function alone without the rest of the
> >> indexing and matrix conversion. Only when the result you get from that
> step
> >> makes sense should you try indexing it or converting it. Maybe you need
> a
> >> "sheet=" argument?
> >>
> >> ---
> >> [1]
> >>
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> >>
> >> [2] https://stat.ethz.ch/pipermail/r-help/2022-July/475212.html
> >>
> >> On July 9, 2022 10:40:29 AM PDT, Muhammad Zubair Chishti <
> >> mzchishti using eco.qau.edu.pk> wrote:
> >> >Dear Experts,
> >> >A kind reminder. Please help me.
> >> >
> >> >
> >> >On Fri, 8 Jul 2022, 21:56 Muhammad Zubair Chishti, <
> >> mzchishti using eco.qau.edu.pk>
> >> >wrote:
> >> >
> >> >>
> >> >> *Dear Experts,*
> >> >> *Greetings from Pakistan*.
> >> >> *When I run the following code in R*
> >> >> library(frequencyConnectedness)
> >> >> library(readxl)
> >> >> ##Add data here##
> >> >> Data <- read_excel("Data_oil_agri.xlsx", sheet = "Sheet1")
> >> >> Data <- Data[,2:22]
> >> >> Data=na.omit(Data)
> >> >> Bnames=colnames(Data)
> >> >>
> >> >> lags=VARselect(Data, lag.max = 12, type = "const")  ## "const",
> "trend",
> >> >> "both", "none"
> >> >> p=lags$selection[[3]]
> >> >>
> >> >> est <- VAR(Data, p = p, type = "const")
> >> >> sp <- spilloverDY12(est, n.ahead = 10, no.corr = F)
> >> >>
> >> >> params_est = list(p = p, type = "const")
> >> >> sp_roll <- spilloverRollingDY12(Data, n.ahead = 10, no.corr = F,
> "VAR",
> >> >> params_est = params_est, window = 260)
> >> >> bounds <- c(pi+0.00001, pi/5, 0)
> >> >> sp_bk <- spilloverBK12(est, n.ahead = 100, no.corr = F, partition =
> >> bounds)
> >> >>
> >> >> sp_bk_roll <- spilloverRollingBK12(Data, n.ahead = 100, no.corr = F,
> >> >> func_est = "VAR", params_est = params_est, window = 260, partition =
> >> bounds)
> >> >>
> >> >> **Till now the code works well. After that, when I run the
> following:*
> >> >>
> >> >> con      = as.matrix(read_excel("DY_Table.xlsx")[,-1])*100
> >> >>
> >> >> *I face the following error:*
> >> >> *Error in* *`vectbl_as_col_location()`:*
> >> >> ! Can't negate columns past the end.
> >> >> ℹ Location 1 doesn't exist.
> >> >> ℹ There are only 0 columns.
> >> >> Run `rlang::last_error()` to see where the error occurred.
> >> >>
> >> >> Kindly please guide me.
> >> >>
> >> >> Regards
> >> >> Muhammad Zubair Chishti
> >> >> Ph.D. Student
> >> >> School of Business,
> >> >> Zhengzhou University, Henan, China.
> >> >> My Google scholar link:
> >> >> https://scholar.google.com/citationshl=en&user=YPqNJMwAAAAJ
> >> >> My ResearchGate link:
> >> >> https://www.researchgate.net/profile/Muhammad-Chishti
> >> >>
> >> >
> >> >      [[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.
> >>
> >> --
> >> Sent from my phone. Please excuse my brevity.
> >>
>
> --
> Sent from my phone. Please excuse my brevity.
>

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

	[[alternative HTML version deleted]]



More information about the R-help mailing list