Invalid (NULL) left side of Assignment in R

I was trying to compile a function in R and came across this error

loadchar() <- function( path, filename){ …

}

Error in loadchar() <- function(path, filename) { :
invalid (NULL) left side of assignment

I couldn’t find much on the internet but the answer (in my case at least)  was simple…

The issue is the brackets in the function name ie it should be

loadchar <- function( path, filename){ …

}

an easy mistake to make … especially if you are jumping between languages regularly

One thought on “Invalid (NULL) left side of Assignment in R”

  1. It also happens if you accidentally use a reserved word for the name of the function. Today I tried naming a function “next”… no dice. (But “nxt” worked fine.) Found your post as I tried to solve it; figured I’d add to your notes for the next pilgrim!

Leave a Reply

Your email address will not be published. Required fields are marked *