[R] How to automatically set R to read the files from a specific location

Eric Berger er|cjberger @end|ng |rom gm@||@com
Thu Mar 3 07:50:58 CET 2022


YAA (Yet Another Approach)
If the data is part of the assignment then the instructor presumably has a
copy of the data file(s).
Your script could get the location of these files via an environment
variable using Sys.getenv().
The instructor would need to set the environment variable prior to running
your script.
Your script should issue an error if the environment variable has not been
set.


On Thu, Mar 3, 2022 at 3:12 AM Avi Gross via R-help <r-help using r-project.org>
wrote:

>
> Just a silly  thought, Paul. If this is really for a class and the file(s)
> being used are small enough, you can play a game where the data is already
> in the R program and is simply written into a file at the start in the
> current directory or a designated area. If that succeeds, you can then have
> the program start as if from scratch and read it back in and continue.
> An alternative if the file is not local but in a known place that can be
> reached, is code that copies it here ...
> Of course in real life with existing huge files, not so much a good idea.
> But many programming assignments to students use smaller data sets. Some
> require having loaded a package and then have an access method to make the
> data visible and loaded. As long as the professor and others all have the
> same package, ...
>
> -----Original Message-----
> From: Paul Bernal <paulbernal07 using gmail.com>
> To: R <r-help using r-project.org>
> Sent: Wed, Mar 2, 2022 5:54 pm
> Subject: [R] How to automatically set R to read the files from a specific
> location
>
> Dear friends,
>
> I am working on an assignment using R, and I would like to set my R code so
> that R automatically recognizes where the files that need to be read are
> without having to use the absolute path?
> The idea is that when I send my .R script and my professor receives it, he
> can just execute the code without running into any issues.
>
> Thanks, beforehand, for your valuable feedback.
>
> Cheers,
> Paul
>
>     [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list