First, as a former Stata user, let me recommend R for Stata users . There is also an article about macros in the R . I think @Nick Cox is right that you need to learn how to do things differently. But, like you (at least in this case), I often start a new task with my prior knowledge of how to do this in Stata and from there. Sometimes I find approaches similar. Sometimes I can get R to act like Stata when another approach is better (e.g. loops versus vectorization ).
I'm not sure if I will take your question with the following, but let me try.
In Stata, it would usually write:
global mydata "path to my data directory/"
To import the data, I would simply type:
insheet using "${mydata}myfile.csv"
As a former Stata user, I want to do something similar in R. Here's what I do:
mydata <- "path to my data directory/"
csv, , myfile, :
myfile <- read.csv(paste(mydata, "myfile.csv", sep=""))
...
myfile <- read.csv(paste0(mydata, "myfile.csv"))
R, , , .