R - Dput

> Procedural Languages > R

1 - About

Write an Object to a file or Recreate it

3 - Snippet

df=data.frame(a=1:2,b=4:5)
df
  a b
1 1 4
2 2 5
dput(df)
structure(list(a = 1:2, b = 4:5), .Names = c("a", "b"), row.names = c(NA, 
-2L), class = "data.frame")
dput(df, file="df.R")

You wil get this OS file:

structure(list(a = 1:2, b = 4:5), .Names = c("a", "b"), row.names = c(NA,
-2L), class = "data.frame")

To make an new data frame from the created file use dget

dfFromFile = dget("df.R")
dfFromFile
  a b
1 1 4
2 2 5
Advertising
lang/r/dput.txt · Last modified: 2017/02/12 21:48 by 66.249.69.140