0

I have R object which is to be shared with another analyst. I write:

dput(objectname,"filename.R")

and then the object can be reconstructed by sharing the .R file and using the dget(filename.R) function. Now what I want to do is just share the object structure and not the file. Is it possible? I tried the following:

a <- dput(b)
structure(1:50, .Dim = c(10L, 5L))

But cannot reconstruct this object. All I get is :

dget(a)
?
lmo
  • 37,904
  • 9
  • 56
  • 69
Aman Mathur
  • 709
  • 2
  • 15
  • 27
  • This doesn't make sense to me. You want to "reconstruct", which usually means *from file*, but without writing to file?? What is the purpose, what are you trying to do? Reconstruct object from *which* format or state or...? – Tomas Jan 08 '14 at 17:38
  • Sorry, I should have clarified. I wanted to know this because when I want to share an object's structure on this website while asking doubts how will it be possible to reconstruct the object in question? – Aman Mathur Jan 08 '14 at 18:04

1 Answers1

1
> a <- dput(b)
structure(1:50, .Dim = c(10L, 5L))
> a  # 'reconstructing' b
      [,1] [,2] [,3] [,4] [,5]
 [1,]    1   11   21   31   41
 [2,]    2   12   22   32   42
 [3,]    3   13   23   33   43
 [4,]    4   14   24   34   44
 [5,]    5   15   25   35   45
 [6,]    6   16   26   36   46
 [7,]    7   17   27   37   47
 [8,]    8   18   28   38   48
 [9,]    9   19   29   39   49
[10,]   10   20   30   40   50

Note that after dputting b and assigning it to a a message is displayed, to recover b, just print a.

Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138