[R] Please guide
Muhammad Zubair Chishti
mzch|@ht| @end|ng |rom eco@q@u@edu@pk
Mon Jul 11 18:37:06 CEST 2022
Dear Respected Sir,
Accept my deepest apologies for not explaining my issue clearly and taking
your precious time.
I hope that my this mistake will not discourage you to help others in
future.
Again, sorry for that.
Regards
Muhammad Zubair Chishti
PhD student, School of Business,
Zhengzhou University, Henan, China
On Mon, 11 Jul 2022, 21:36 Muhammad Zubair Chishti, <
mzchishti using eco.qau.edu.pk> wrote:
> Dear Respected Sir,
> Accept my deepest apologies for not explaining my issue clearly and taking
> your precious time.
> I hope that my this mistake will not discourage you to help others in
> future.
> Again, sorry for that.
>
> Regards
> Muhammad Zubair Chishti
> PhD student, School of Business,
> Zhengzhou University, Henan, China
>
> On Mon, 11 Jul 2022, 18:29 Richard O'Keefe, <raoknz using gmail.com> wrote:
>
>> 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 using 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 using 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 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.
>>>>>
>>>>
[[alternative HTML version deleted]]
More information about the R-help
mailing list