-1

I am trying to run a function in r starting with the following command:

read.tchain<-function("AL1"){

and I keep getting the following error:

Error: unexpected string constant in "read.tchain<-function("AL1""

I have tried multiple variations and no luck. Any help would be greatly appreciated!

zx8754
  • 52,746
  • 12
  • 114
  • 209
Kestrel Kunz
  • 1
  • 1
  • 1

1 Answers1

0

When declaring a function, the arguments should not be strings, so read.tchain<-function("AL1"){ gives an error. You should instead write read.tchain<-function(var1){ and feed in "AL1" when you are calling the function like this read.tchain("AL1")

acylam
  • 18,231
  • 5
  • 36
  • 45
  • Follow up question - should I run the whole function with the var1 replacement, and then "call the function". Thanks so much for your help! I am very new to this.. – Kestrel Kunz Mar 02 '17 at 05:57
  • @KestrelKunz Yes you should, if your function actually takes a string as an argument. "var1" is just to tell R that your function takes one argument. You should then replace whatever uses "AL1" with var1 inside your function. Again, you should make your question reproducible by providing sample code and data. – acylam Mar 02 '17 at 06:01