ar envPath = Environment.GetEnvironmentVariable("PATH");
var rBinPath = @"C:\R-4.0.2\bin\i386";
Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath);
REngine r = REngine.GetInstance();
r.Initialize();
r.Evaluate("library('ggplot2')");
r.Evaluate("set.seed(0)");
r.Evaluate("n_samples <- 30");
r.Evaluate("x <- runif(n_samples)");
r.Evaluate("x <- x[order(x)]");
r.Evaluate("y <- cos(1.5 * pi * x) + rnorm(n_samples) * 0.1");
r.Evaluate("df <- data.frame(x, y)");
r.Evaluate("model1 <- lm(y ~ x, data=df)");
r.Evaluate("print(summary(model1))");
result:

At the bottom of your aforementioned code, if you add the following piece of code then you get the result instead of the VS output, in a text file:
your output will be like this:
However, if you change your VS language settings, you might get the same. But, changing the language settings, is not always practical.