*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
Please guide
11 messages · Muhammad Zubair Chishti, Jeff Newmiller, Avi Gross +1 more
1 day later
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
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.
1 day later
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.
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.
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 at 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 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 <
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]
[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.
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 at eco.qau.edu.pk>
To: Jeff Newmiller <jdnewmil at dcn.davis.ca.us>; r-help at 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 at 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 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 <
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]
[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.
??? [[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.
(1) Your sample code refers to a file DY_Table.xlsx
but the file you attached to a later message is
called Data_oil_agri.xlsx and I find it hard to
believe that they are the same file.
(2) gmail offered me two different ways to download
the file, but neither of them worked. Fortunately,
the third way worked.
(3) Here's what I get with Data_oil_agri.xlsx
d<-read_excel("Data_oil_agri.xlsx", sheet=1)
str(d)
tibble [3,870 x 22] (S3: tbl_df/tbl/data.frame)
So that's a table with 3870 rows and 22 columns.
But your code got this error message:
! 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.
This is why I wonder if you really sent the right file.
The error message told you to do something.
WHAT DID YOU SEE WHEN YOU ENTERED THE COMMAND
rlang::last_error()
?
When you are reading from an .xls or .xlsx file, it is always
a good idea to be explicit about which sheet you want.
In another message, you wrote something that seems very strange.
"Since the data is too large and I cannot cut it".
It's an Excel spreadsheet! (Or rather, three sheets.)
OF COURSE YOU CAN CUT IT! That's like saying
"Because this banana is on my plate and I have a knife,
I cannot cut it."
If you do not have Excel (and why would you? I don't myself)
you could use LibreOffice or Google Sheets or WPS Office
or even Python
https://stackabuse.com/reading-and-writing-excel-files-in-python-with-the-pandas-library/
Libre Office and Google Sheets have worked well for me.
These things you must do.
(A) Check that DY_Table.xlsx and Data_oil_agri.xlsx
are the same. If they are not, make sure you are
using the right one.
(B) Open the file in a spreadsheet program and see
what is actually there. Write down on a piece of
paper how many sheets there are, what the sheet
you want is called, and how many rows and columns it has.
What are the first few columns called?
(C) Start up a fresh R session and use read_excel to read
the right sheet from the right file.
Use head() on the result. Does it have the right
number of columns? Do they have the right names?
Does the result have the right number of rows?
(D) Try the rest of the failing line.
x <- as.matrix(the.tibble[,-1])*100
(E) If anything goes wrong, DO WHAT THE ERROR MESSAGE SAYS
TO DO.
Got that?
By the way, I'm old school. I love the assignment arrow <-
and find the abuse of "=" confusing and ugly. But you just
taught me that there is something even uglier and more
confusing, and that's randomly switching between them. Pick
one and stick to it.
Oh yeah, one final point. The line where you say your code
has trouble doesn't seem to be connected in any way to the
preceding lines. We didn't need to see them.
On Sat, 9 Jul 2022 at 04:57, 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.
Dear Respected Sir,
My exact question is how to develop "DY_Table.xlsx" for the following code:
(While considering [,-1])*100)
con = as.matrix(read_excel("DY_Table.xlsx")[,-1])*100
I asked that code writer about it, he just reply to write the table. So, I
need to know how to write the table for the code mentioned above?
I hope that you got my question now.
Regards
Chishti
On Mon, Jul 11, 2022 at 3:05 PM Richard O'Keefe <raoknz at gmail.com> wrote:
(1) Your sample code refers to a file DY_Table.xlsx
but the file you attached to a later message is
called Data_oil_agri.xlsx and I find it hard to
believe that they are the same file.
(2) gmail offered me two different ways to download
the file, but neither of them worked. Fortunately,
the third way worked.
(3) Here's what I get with Data_oil_agri.xlsx
d<-read_excel("Data_oil_agri.xlsx", sheet=1)
str(d)
tibble [3,870 x 22] (S3: tbl_df/tbl/data.frame)
So that's a table with 3870 rows and 22 columns.
But your code got this error message:
! 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.
This is why I wonder if you really sent the right file.
The error message told you to do something.
WHAT DID YOU SEE WHEN YOU ENTERED THE COMMAND
rlang::last_error()
?
When you are reading from an .xls or .xlsx file, it is always
a good idea to be explicit about which sheet you want.
In another message, you wrote something that seems very strange.
"Since the data is too large and I cannot cut it".
It's an Excel spreadsheet! (Or rather, three sheets.)
OF COURSE YOU CAN CUT IT! That's like saying
"Because this banana is on my plate and I have a knife,
I cannot cut it."
If you do not have Excel (and why would you? I don't myself)
you could use LibreOffice or Google Sheets or WPS Office
or even Python
https://stackabuse.com/reading-and-writing-excel-files-in-python-with-the-pandas-library/
Libre Office and Google Sheets have worked well for me.
These things you must do.
(A) Check that DY_Table.xlsx and Data_oil_agri.xlsx
are the same. If they are not, make sure you are
using the right one.
(B) Open the file in a spreadsheet program and see
what is actually there. Write down on a piece of
paper how many sheets there are, what the sheet
you want is called, and how many rows and columns it has.
What are the first few columns called?
(C) Start up a fresh R session and use read_excel to read
the right sheet from the right file.
Use head() on the result. Does it have the right
number of columns? Do they have the right names?
Does the result have the right number of rows?
(D) Try the rest of the failing line.
x <- as.matrix(the.tibble[,-1])*100
(E) If anything goes wrong, DO WHAT THE ERROR MESSAGE SAYS
TO DO.
Got that?
By the way, I'm old school. I love the assignment arrow <-
and find the abuse of "=" confusing and ugly. But you just
taught me that there is something even uglier and more
confusing, and that's randomly switching between them. Pick
one and stick to it.
Oh yeah, one final point. The line where you say your code
has trouble doesn't seem to be connected in any way to the
preceding lines. We didn't need to see them.
On Sat, 9 Jul 2022 at 04:57, 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.
ARGH! Now I understand less than ever! Previously you said that you HAD a file and that you got an error message when you tried to read and process it. You showed us the line of code. You sent us what was supposed to be a copy of the file! Now you say that - is not your code - the person who did write the code told you "just write the table" - you want us to tell you how to write the table. Nobody is paying me for my time. In fact if I hadn't had to run the dishes through the dishwasher a second time I wouldn't even be awake to do it. We do not even know - what the code is supposed to do - what information is supposed to be in the table - what table you are actually talking about * is it the one of the sheets in the XLSX file? * is it the tibble that read_excel creates? - what you mean by "write the table" It sounds as though there is someone well placed to help you who refuses to do so. Actually, there is someone else who can help you, and does not seem to be interested in doing so, and that is you yourself. I gave you a list of things to do. Did you do them? On Tue, 12 Jul 2022 at 01:17, Muhammad Zubair Chishti <
mzchishti at eco.qau.edu.pk> wrote:
Dear Respected Sir,
My exact question is how to develop "DY_Table.xlsx" for the following
code: (While considering [,-1])*100)
con = as.matrix(read_excel("DY_Table.xlsx")[,-1])*100
I asked that code writer about it, he just reply to write the table. So, I
need to know how to write the table for the code mentioned above?
I hope that you got my question now.
Regards
Chishti
On Mon, Jul 11, 2022 at 3:05 PM Richard O'Keefe <raoknz at gmail.com> wrote:
(1) Your sample code refers to a file DY_Table.xlsx
but the file you attached to a later message is
called Data_oil_agri.xlsx and I find it hard to
believe that they are the same file.
(2) gmail offered me two different ways to download
the file, but neither of them worked. Fortunately,
the third way worked.
(3) Here's what I get with Data_oil_agri.xlsx
d<-read_excel("Data_oil_agri.xlsx", sheet=1)
str(d)
tibble [3,870 x 22] (S3: tbl_df/tbl/data.frame)
So that's a table with 3870 rows and 22 columns.
But your code got this error message:
! 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.
This is why I wonder if you really sent the right file.
The error message told you to do something.
WHAT DID YOU SEE WHEN YOU ENTERED THE COMMAND
rlang::last_error()
?
When you are reading from an .xls or .xlsx file, it is always
a good idea to be explicit about which sheet you want.
In another message, you wrote something that seems very strange.
"Since the data is too large and I cannot cut it".
It's an Excel spreadsheet! (Or rather, three sheets.)
OF COURSE YOU CAN CUT IT! That's like saying
"Because this banana is on my plate and I have a knife,
I cannot cut it."
If you do not have Excel (and why would you? I don't myself)
you could use LibreOffice or Google Sheets or WPS Office
or even Python
https://stackabuse.com/reading-and-writing-excel-files-in-python-with-the-pandas-library/
Libre Office and Google Sheets have worked well for me.
These things you must do.
(A) Check that DY_Table.xlsx and Data_oil_agri.xlsx
are the same. If they are not, make sure you are
using the right one.
(B) Open the file in a spreadsheet program and see
what is actually there. Write down on a piece of
paper how many sheets there are, what the sheet
you want is called, and how many rows and columns it has.
What are the first few columns called?
(C) Start up a fresh R session and use read_excel to read
the right sheet from the right file.
Use head() on the result. Does it have the right
number of columns? Do they have the right names?
Does the result have the right number of rows?
(D) Try the rest of the failing line.
x <- as.matrix(the.tibble[,-1])*100
(E) If anything goes wrong, DO WHAT THE ERROR MESSAGE SAYS
TO DO.
Got that?
By the way, I'm old school. I love the assignment arrow <-
and find the abuse of "=" confusing and ugly. But you just
taught me that there is something even uglier and more
confusing, and that's randomly switching between them. Pick
one and stick to it.
Oh yeah, one final point. The line where you say your code
has trouble doesn't seem to be connected in any way to the
preceding lines. We didn't need to see them.
On Sat, 9 Jul 2022 at 04:57, 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.