I am new to R and have a background in python. I am trying to do similar tasks that I know to do in python within R to help me learn. I have been playing around with the docopt library to create executable programs that can be run from the command-line. I plan to create scripts that I can reuse and allow other people in my team to use and have them input their own parameters. The docopt library allows parameters to be used in the command-line.
The issue I am having is with the left_join function from dplyr where I am using two parameters to be input to represent the column names from the left table and right table.
joined_df <- left_join(input_df, countries, by = c(opts$l = opts$r))
the "opts$" syntax is what is used to allow the script to input the arguments that the user defines when running the script in the terminal. So when I run the script in the terminal it looks like this:
./add_continent.R -i ~/Desktop/codes.csv -l "code" -r "country_code"
where "code" will replace "opts$l" and "country_code" will replace "opts$r" in the script. This follows the syntax that left_join has when the joining columns have different names. Yet I get the following error:
Error: unexpected '=' in "joined_df <- left_join(input_df, countries, by = c(opts$l =" Execution halted
I believe this must be somehow an issue with my implementation of the opts arguments in the left_join but I can't find much documentation about it out there. Any help here would be great