How to view saved Rdata file in windows?

R ProgrammingServer Side ProgrammingProgramming

We save our data files created in R to use them in the future and these files have an extension .Rdata. To view these files, we can make use of load function that will read the path of the file on your system. Suppose you save the file in Documents folder as I do then you will have to provide the path of the Documents folder and that’s it.

Example

Suppose that you created a data frame df and saved it as df.Rdata file in your system −

> set.seed(99)
> x1<-rpois(20,2)
> x2<-rnorm(20,1.5)
> x3<-rnorm(20,2)
> df<-data.frame(x1,x2,x3)
> df
x1 x2 x3
1 2 0.7542310 3.3730539
2 0 2.4215504 2.4502566
3 3 2.2500544 1.8537061
4 6 -1.0085540 2.1280972
5 2 -1.5409341 -0.2947209
6 5 1.5002658 0.6334311
7 2 1.1059810 1.8025204
8 1 -0.2450277 2.0680858
9 1 1.9986315 2.0905034
10 1 1.7709538 2.3227600
11 2 2.5989215 2.1329786
12 2 2.2525135 0.3207357
13 1 1.4405833 1.7215204
14 2 1.1554312 0.4475890
15 3 1.7226683 0.6203007
16 2 2.0517863 0.6429434
17 1 2.1836428 1.0788628
18 0 0.9541206 1.1331823
19 0 0.1325638 3.6566444
20 1 2.9000518 1.8449203
> save(df,file="df.Rdata")

Now to read df, we can use load function with the full path where the Rdata file was saved, this path might be different for your system so just make sure you provide the right path −

> load("C:/Users/Nizam/Documents/df.Rdata")
> df
x1 x2 x3
1 2 0.7542310 3.3730539
2 0 2.4215504 2.4502566
3 3 2.2500544 1.8537061
4 6 -1.0085540 2.1280972
5 2 -1.5409341 -0.2947209
6 5 1.5002658 0.6334311
7 2 1.1059810 1.8025204
8 1 -0.2450277 2.0680858
9 1 1.9986315 2.0905034
10 1 1.7709538 2.3227600
11 2 2.5989215 2.1329786
12 2 2.2525135 0.3207357
13 1 1.4405833 1.7215204
14 2 1.1554312 0.4475890
15 3 1.7226683 0.6203007
16 2 2.0517863 0.6429434
17 1 2.1836428 1.0788628
18 0 0.9541206 1.1331823
19 0 0.1325638 3.6566444
20 1 2.9000518 1.8449203
Published on 12-Aug-2020 11:49:53