[R] Real Basic Question
ru|pb@rr@d@@ @end|ng |rom @@po@pt
Fri Sep 27 13:45:42 CEST 2019
1. Try path.expand().
flname <- path.expand("~/Baseball/RetroSheetDocumentation/ari18.test2.rda")
2. To load in the global environment
load(flname, envir = .GlobalEnv)
3. But read the docs. From ?load:
load(<file>) replaces all existing objects with the same names in the
current environment (typically your workspace, .GlobalEnv) and hence
potentially overwrites important data. It is considerably safer to use
envir = to load into a different environment, or to attach(file) which
load()s into a new entry in the search path.
So Duncan's suggestion to create a new environment and load the data
there might be sound advice. Check if your data set exists in the
.GlobalEnv first, then load() it.
ls(pattern = "^ari", envir = .GlobalEnv)
Hope this helps,
Às 18:06 de 26/09/19, Duncan Murdoch escreveu:
> On 26/09/2019 12:55 p.m., Phillip Heinrich wrote:
>> Just when I think I’m starting to get the hang of R I run into
>> something that sends me back to Go without collecting $200.
>> The working directory seems to be correct when I load an .rda file but
>> it is not there and it is not in the Global Environment in the upper
>> right hand window in RStudio.
>>  "C:/Users/Owner/Documents/Baseball/RetroSheetDocumentation"
>> Error: object 'ari18.test2' not found
>>  "ari18.test3" "array1" "array2"
>> "BaseballArticles" "BaseballArticles2"
>>  "BaseballArticles3" "BBCorpus" "BBtdm"
>> "firstfunction" "folder"
>>  "h" "matrix" "matrix2"
>> "matrix3" "n"
>>  "seq" "testvector" "u"
>> "vec" "x"
>>  "y" "yourname"
>> Somehow ari18.test3 loaded but ari18.test2 will not.
>> What am I missing here?
> The filename (~/Baseball/RetroSheetDocumentation/ari18.test2.rda) has no
> connection to the variables that would be created when you load it.
> Finding out what's in that file isn't obvious: you need to load it into
> an empty location (either your global environment in a clean new
> session, or one created specially for the purpose). E.g.
> env <- new.env()
> load("~/Baseball/RetroSheetDocumentation/ari18.test2.rda", envir = env)
> ls(envir = env)
> This will load the object(s) from that file into the environment env.
> You could copy them from there to somewhere else, use them from there,
> or just load again into the global environment, now you know what you're
> Duncan Murdoch
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help