简体   繁体   中英

Creating files within R code

I am writing an R code which uses command line tools.

These tools create temporary files which are required for the code to progress, this code will be given to other users to use.

My question is what is the most appropriate way to deal with these files through R specially that other users will be using this code and I don't want to be overwriting user existing files.

Should I create a specific directory to save these files in? And is it a good idea to implement command line tools in an R code?

I am using kentUtils bedToPsl so a psl file is being created, and then I am using pslMap so the output of pslMap mapInfo is also stored in another file.

I am only interested in the results of mapInfo and not of in the other files created.

If it were me, I would create two directories workspace/temp and workspace/output with these commands:

    dir.create("./temp")
    dir.create("./output")

(You can do this more elegantly, but I don't see the point for two lines.)

From R, you can access files with commands like file.exists("./output/foo.msl") . Here is the documentation . If you use this relative addressing, you can move the code around and it will still work.

The implication of temp is that after a session, all of the contents can be deleted. You can deliver the mapInfo in the output directory.

Depending on who is using your code and data, you might want to change the privileges on various directories. Your mileage will vary, depending on whether you are working in Windows, Mac, or UNIX-like environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM