Is there a way to read a simple text key-value file in R ...
Key1=Value1
Key2=Value2
Key3=Value3
Ideally I want to access the data like this:
myfile$Key1 should return Value1 , myfile@Key2 should return Value2
and so on
Cheers! MadSeb
P.S I looked into the stashR and the filehash packages and while these packages implement nice key value databases, they don't store the database in simple/readable text format.
What about something like this:
dframe <- read.table(file='yourfile.txt',header=FALSE,
                     sep='=',col.names=c('Key','Value'))
then, if you want a faster access by key, you can use data.table e.g. :
library(data.table)
dframe <- read.table(file='yourfile.txt',header=FALSE,
                     sep='=',col.names=c('Key','Value'))
dtable <- data.table(dtfrm,key='Key')
dtable['Key1']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With