To save and load RDA files in R, yo can use save() and load() functions respectively.

The following methods show how you can do it with syntax.

Method 1: Use save() Function

save(object,"file.Rda")

Method 2: Use load() Function

load(file.Rda)

# Create object
print(object)

The following examples show how to save and load rda files in R.

Using save() Function

Let’s see how we can use save() function in R:

# Create data frame
df <- data.frame(Machine_name=c("A","B","C","D","E","F"),
                 Pressure=c(78.2, 71.7, 80.21, 83.12, 82.56, 79.50),
                 Temperature=c(31, 35, 36, 36, 38, 32),
                 Status=c(TRUE,TRUE,FALSE,FALSE,FALSE,TRUE))

# Save dataframe to RDA file
save(df,"sample.Rda")

Here in the above code we save dataframe to RDA file using save() function.

Using load() Function

Let’s see how we can use load() function in R:

# Load object from file
load("sample.Rda")

# Use object
print(df)

Output:

  Machine_name Pressure Temperature Status
1            A    78.20          31   TRUE
2            B    71.70          35   TRUE
3            C    80.21          36  FALSE
4            D    83.12          36  FALSE
5            E    82.56          38  FALSE
6            F    79.50          32   TRUE

Here the output shows data from sample.Rda which loaded using load() function.