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 at 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 at eco.qau.edu.pk> wrote: > >Dear Experts, > >A kind reminder. Please help me. > > > > > >On Fri, 8 Jul 2022, 21:56 Muhammad Zubair Chishti, < > mzchishti at 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 at 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. >[[alternative HTML version deleted]]
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 at 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 at 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 at eco.qau.edu.pk> wrote: >> >Dear Experts, >> >A kind reminder. Please help me. >> > >> > >> >On Fri, 8 Jul 2022, 21:56 Muhammad Zubair Chishti, < >> mzchishti at 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 at 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.
I am sure if Jeff Newmiller is a Professor, he may well be respected but he has not said he is nor most of us. He specifically said the people here are random people with an interest in R. A few may indeed be professors or once taught? like I did ages ago but few of us relate particularly to be called an honorific and unlike in some cultures, many simply get a bit annoyed at such phrases and some move on and won't reply. May I suggest that on this forum, we appreciate it is some asks a properly formatted question which shows attempts to solve the problem and supplies a minimum of details with NONE of the details in an attached file which we will not see even if sent repeatedly. I think you may have received replies and have not followed through on them. Let me try ONCE, and if a reply refers to me being a professor I will just press DELETE and go on with my life. Your error message seems clear. It says that what you asked for has NO columns.? Did you type what it asked for IMMEDIATELY?? rlang::last_error() The above might return MORE INFO and you have not shared that here. Is it possible it would have been helpful? Now consider NOT running complex code in one long line when trying to see what failed. This line is too complex: as.matrix(read_excel("DY_Table.xlsx")[,-1])*100 Try this: temp <-?read_excel("DY_Table.xlsx") See what it returns If the file exists in the current directory/folder and is spelled exactly that way and has only one tab, maybe it does.?But if that fails, DEBUG that before moving on. You need to look at temp and see if it is a valid data.frame. So ONLY if it looks OK, do you move on to the next idea. What do you think temp[, -1] means??Your code seems to want all rows kept and I think the you want the FIRST column removed, leaving all the rest.?Note if the data only has ONE column, you are left with no columns. If the data already is empty or nonsense,trying to do the [, -1] indexing will fail, perhaps with that complaint. So, if the above still worked as in you typed head(temp[, -1]) then continue, else go FIX what you already have till it works. You now seem to want to change a data.frame into a matrix. Note that will really only work if everything is numeric. I mean?if it has any character data, everything will be character and probably not useful.? So these two lines let you examine: temp <- temp[, -1] temp <- as.matrix(temp) Any error messages so far? I highly doubt the next line generates that message, but as noted, the contents better be numeric. temp <- temp * 100 When you get all those steps working, feel free to resume your original code: con? ? ? = as.matrix(read_excel("DY_Table.xlsx")[,-1])*100 Just FYI, although "=" is a legal use in that line, many people use "<-" when writing in R. And note again, we have no idea what is in what you call a DATA file except that a file whose name?ends in .XSLX is not what we think of as a data file. It is a newer format for an EXCEL SPREADSHEET?as compared to a .CSV file that has simpler comma separated values in a text compatible file. To read data?from EXCEL is much more complex and you may need to tell it which of the tabbed sheets to use and where?in that sheet to look for data. It often makes a good guess of looking at the first sheet and if it finds what looks?like columns of data and NOTHING ELSE on that sheet, brings it in. Chances are your data is not set up?for that default and you have several options. One is to open the file in EXCEL and clean it so it fits, and another?is to save a sheet, or a region, as a new .CSV file and change your code to use a function like read.csv() with?appropriate options. Again, politeness here is wasted and volunteers have no obligation to you. If the above is helpful, great. If not,so be it. Ask your actual Professor who presumably will love being respected and speak your language well?and be able to see your data. Avi -----Original Message----- From: Muhammad Zubair Chishti <mzchishti at eco.qau.edu.pk> To: Jeff Newmiller <jdnewmil at dcn.davis.ca.us>; r-help at r-project.org Sent: Sun, Jul 10, 2022 11:50 pm Subject: Re: [R] Please guide 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 at 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 at eco.qau.edu.pk> wrote: > >Dear Experts, > >A kind reminder. Please help me. > > > > > >On Fri, 8 Jul 2022, 21:56 Muhammad Zubair Chishti, < > mzchishti at 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 at 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. >??? [[alternative HTML version deleted]] ______________________________________________ R-help at 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]]