NarT
NarT

Reputation: 33

Error: unexpected string constant in file path in R

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?

Upvotes: 1

Views: 10642

Answers (1)

alko989
alko989

Reputation: 7918

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.

Upvotes: 2

Related Questions