Is there a way to wrap a character array in a buffer object so it behaves like a file connection? For my particular use case, I happen to have an .RData file as a character array in memory (I know that sounds crazy), and would like to use the load()
function without writing it to disk first.
Asked
Active
Viewed 33 times
0

eric chiang
- 2,575
- 2
- 20
- 23
-
Maybe checkout `textConnection()`? I'm not sure I quite understand what you are doing. A [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) would really help here. – MrFlick Jul 03 '14 at 14:10
-
`I happen to have an .RData file as a character array in memory` can you please re-phrase that? I didn't understand. – Michele Jul 03 '14 at 14:38
1 Answers
1
You can use rawConnection
function e.g. :
# this in-memory ASCII .RData contains: a = 123 and b = 456
rDataInMem <-
"RDA2
A
2
134915
131840
1026
1
262153
1
a
14
1
123
1026
1
262153
1
b
14
1
456
254
"
# executing this line should appear a = 123 and b = 456 in the workspace
load(file=rawConnection(object=charToRaw( rDataInMem ),open='r'))

digEmAll
- 56,430
- 9
- 115
- 140