Wednesday, 1 July 2015

R : dget : Recreates object from a file.

Syntax
dget(file, keep.source = FALSE)

Parameter
Description
file
Object to read from a file.
keep.source
Logical variable: should the source formatting be retained when parsing functions, if possible?

Let’s say “out.R” contains following data.
structure(list(id = 1:4, firstName = structure(1:4, .Label = c("Hari Krishna",
"Joel", "Rama Krishna", "Sudheer"), class = "factor")), .Names = c("id","firstName"), row.names = c(NA, -4L), class = "data.frame")

> system("cat out.R")
structure(list(id = 1:4, firstName = structure(1:4, .Label = c("Hari Krishna", 
"Joel", "Rama Krishna", "Sudheer"), class = "factor")), .Names = c("id", 
"firstName"), row.names = c(NA, -4L), class = "data.frame")
> 
> table2 <- dget("out.R", keep.source=TRUE)
> 
> table2
  id    firstName
1  1 Hari Krishna
2  2         Joel
3  3 Rama Krishna
4  4      Sudheer



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment