Seek for a solution to fix error messages using R-studio

Dear everyone,

I hope this post finds you well. I encounter several similar error messages when I use my R code. The RStudio shows the following message when I run my code under the “REMOVE BAD DATA” section.

Error in vapply(as.character(key.urls), function(i) which(randomized.urls == :
** values must be length 1,**
but FUN(X[[1]]) result is length 0

The similar error message was displayed when I run the code under the “PARSE CURSOR DATA” section.

Error in vapply(as.character(key.urls), function(i) which(randomized.urls == : **
** values must be length 1,

** but FUN(X[[1]]) result is length 8**

I have been suffering from these errors and try to figure out any solutions to address them. I have attached my R code and data file (named “data”) and you can download them from the link.

Do everyone have any thoughts about this issue, and if so, would you mind checking the error for me? If not, I definitely understand, and would greatly appreciate any pointers you might have about this issue.

Thank you very much for your time on this matter!

I downloaded your zip file and had a look at data.csv which I named dat1

I think you have something seriously wrong with that file.

For example

dat1[1:3,1:4]

gives me

1                                            Start Date
2 {"ImportId":"startDate","timeZone":"America/Chicago"}
3                                   2021-01-19 14:10:32
                                              EndDate                Status
1                                            End Date         Response Type
2 {"ImportId":"endDate","timeZone":"America/Chicago"} {"ImportId":"status"}
3                                 2021-01-19 14:15:20                     0
                 IPAddress
1               IP Address
2 {"ImportId":"ipAddress"}
3           24.162.183.119

and

dat1[1:5, 1]

gives me me:


[1] "Start Date"                                                   
[2] "{\"ImportId\":\"startDate\",\"timeZone\":\"America/Chicago\"}"
[3] "2021-01-19 14:10:32"                                          
[4] "2021-01-20 17:07:21"                                          
[5] "2021-01-22 21:45:30"                                          

We need a clean data set before we can do much. However I would point out that in the file data_prep.R

source("general_helper.R")

seems to be loading something we do not have.

Thank you for the new link and the new data file, data_clean.csv and the general_helper.R file..

There still seems to be some serious problems with the data file. How was this data gathered and how was it saved to the .csv file?

This is a shot of the first part of the file that I get when I open it in a text editor.

and this is another shot of the file.

This is not what I understand to be a data file. I recommend that you open the file in a text editor and have a look at it. It seems to be some kind of a mix of an R header line, some text which looks like a questionnaire and,what I am guessing, is some html.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Thank you very much for your kind comment. I really appreciate that. I upload a clean data with one three subjects' data and upload the file data_prep.R. You can download them the link.

Using the clean data, I still encounter the same error message.

Error in vapply(as.character(key.urls), function(i) which(randomized.urls == :
values must be length 1,
but FUN(X[[1]]) result is length 8

Any comment on this error message will be greatly appreciate. Again, thank you so much for your time on this matter.!