1

I am trying to run this command in R in order to run a function:

 xlsxToR <- function("C:\\Users\\Nabila\\Dropbox\\IsolutionsProject\\ServiceRequestTickets.zip", keep_sheets = "TicketDetails", header = FALSE)

However, I tend to get this error when I run it:

Error: unexpected string constant in "xlsxToR <- function("C:\\Users\\Nabila\\Dropbox\\IsolutionsProject\\ServiceRequestTickets.zip""

I have tried looking for a mistake in my file path. Tried using forward slashes but to no avail. Can anyone help please?

Simon O'Hanlon
  • 58,647
  • 14
  • 142
  • 184
NarT
  • 33
  • 1
  • 1
  • 4
  • Not sure what you are trying to achieve here, but this SO question has information on opening zip files in R: http://stackoverflow.com/questions/3053833/using-r-to-download-zipped-data-file-extract-and-import-data – r.bot Jun 24 '14 at 10:44
  • 2
    try giving the string constant a name, like `function(file = "C:\\Users\\Nabila\\Dropbox\\IsolutionsProject\\ServiceRequestTickets.zip", ...)`. – lukeA Jun 24 '14 at 10:48

1 Answers1

2

Functions in R

When you are using function in R you are defining a function (You can use ?function to see the documentation). Inside the parentheses after function you set the arguments of the function. You can also set default values for those arguments using =. After that the body of the function should follow, i.e. an R expression containing the code of the function.

Your case

This line of code does not run a function. It defines a function with name xlsxToR. The first thing in the parenthesis is a string, not an argument name, which causes the error. Also your function is just a definition of some argumnents without a body, which probably is not what you are trying to do.

alko989
  • 7,688
  • 5
  • 39
  • 62
  • Thank you for your comment. Indeed, the code for the function follows after this line, but I did not copy it here. – NarT Jun 24 '14 at 11:18
  • No problem. It was unclear from your question, because you said "run" a function and not showing the body of the function. – alko989 Jun 24 '14 at 11:21