system.file Function in R (2 Examples)

 

In this R post you’ll learn how to find the names of system files using the system.file function.

Table of contents:

Here’s how to do it.

 

Example 1: Find System Files of Base R Using system.file() Function

This section shows how to apply the system.file function to return the root of the base R package.

For this, we simply have to execute the system.file command without any additional specifications:

system.file()            # Apply system.files function
# [1] "C:/PROGRA~1/R/R-41~1.0/library/base"

As you can see based on the previous output of the RStudio console, we have returned the path to the base R package on my computer.

 

Example 2: Find System Files of Certain Package Using system.file() Function

The following R programming code illustrates how to return the path to a particular add-on package.

In this example, we’ll return the root of the dplyr package:

system.file( = "dplyr")  # Apply system.files function
# [1] "C:/Users/Joach/Documents/R/win-library/4.1/dplyr"

 

Video, Further Resources & Summary

Have a look at the following video on my YouTube channel. In the video, I’m explaining the R codes of this page in R.

 

The YouTube video will be added soon.

 

Furthermore, you may want to read some of the other R posts on this website. A selection of posts that are related to the application of the system.file function is shown below:

 

You have learned in this tutorial how to find the root of packages and files using the system.file function in R. In case you have any further questions, let me know in the comments below. Furthermore, don’t forget to subscribe to my email newsletter for updates on new tutorials.

 

Subscribe to the Statistics Globe Newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.


Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Top