Friday, March 11, 2016

R library path

Resultado de imagen para turn it off and on again meme



I'll begin this post with something about me...

I'm a big fan of defaults. I love stuff that's ready to work "out of the box".

Well, having said that... my today's post is about preventing some weird stuff that happened yesterday to me for using the default R library as a shared library.
  • First things first. Enviroment
    I was using R 3.1.1 from Rstudio on Windows 8 ( yeah, I know... kindo nasty)
  • Second. What I did wrong
    I have to say in my defense, that I still don't think this is wrong, I guess It has more to do with some bad luck with the way I'd setup my consoles shortcuts. Well, to the point I had a script witch connects to a DB using RODBC and It takes some time. You know that RStudio is single threaded and I wanted to test it while continue working on something else. So I decided I would run it from a windows console ( I should've used an R terminal. But bear with me for arguments sake ).
And so It began..
Resultado de imagen para shouldn't have done that meme

  • It couldn't load any of the script libraries, eventhough they were physically in the default library
  • I tried to "install.package" to test one, and the process couldn't write in the directory... well I thought, "I guess I can't have Rstudio and this console accessing to the library". So I shutted down the console and returned to Rstudio.
  • Opened the script and... surprise. It couldn't find the library... WTF
  • Tried the infamous IT Crowd Algorithm "have you tried to turning it off and on again".. "Some temporal files have to be locked", I thought.. It's windows after all...
  • Tried again and still nothing happened.... well time to fix this stuff
The default library was unusable. The console I had used was configured to open with Admin Rights.....and I still don't know why It had locked all the stuff in the library dir...

  1. Change permitions didn't work
  2. Install packages within R as admin user didn't work either
  3. So I listed and configured another directory as user library
    R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
    Copyright (C) 2015 The R Foundation for Statistical Computing
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.
    
      Natural language support but running in an English locale
    
    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.
    
    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.
    
    During startup - Warning message:
    Setting LC_CTYPE=en_US.UTF-8 failed
    > .libPaths()
    .libPaths()
    [1] "C:/Program Files/R/R-3.2.3/library"
    
    >.libPaths("xxxxx")
    
    .libPaths()
    [1] "C:/Users/xxx/R/win-library/3.2" "C:/Program Files/R/R-3.2.3/library"   
  4. And so it began working..... I installed a new R version after I learned I had to install most of my libs again

What did I learned


  • First: I don't have any shortcut with admin rights now.
  • Second: After some internet reading I learned that having a user library is a good practice
  • Third: I understand windows less every time
  • Fourth: The only useful thing I wrote was
    .libPaths()
Anyways, I hope this is useful to someone....I'll quit the rambling now....

No comments: