Skip to content

installed packages not found when setting some options in .Rprofile #2

Open

Description

@verajosemanuel

Double checked which .Rprofile is loading to be sure.
Using the example from documentation:

my_custom_params <- list(
  author = "Victor",
  project = list(
    folders = list(
      default = c("R", "inst", "man", "data-raw", "data", "tests"),
      selected = c("R", "man")
    ),
    packages = list(
      default = rownames(installed.packages()),
      selected = "shiny"
    )
  )
)
options("addinit" = my_custom_params)

an error is shown:

Error in installed.packages() : 
  "installed.packages" not found

Activity

  1. changed the title [-]new folder names not present after modified .Rprofile[/-] [+]installed packages not found when setting some options in .Rprofile[/+] on Aug 21, 2019
  2. pvictor commented on Aug 21, 2019

    @pvictor
    Member

    Hi Jose,

    Apparently you have to use the namespace of the function utils::installed.packages (although it is a function from base R).
    With your previous list of directories, the display may not be optimal, tell me if you want I look into that.

    Victor

  3. verajosemanuel commented on Aug 21, 2019

    @verajosemanuel
    Author

    thanks for your quick response.

    setting the commad to utils::installed.packages crashed Rstudio with a nasty message (mac OS):

    The R session had a fatal error.

    ERROR r error 4 (R code execution error) [errormsg=Error: option error has NULL value
    ]; OCCURRED AT: rstudio::core::Error rstudio::r::exec::executeSafely(boost::function<void ()>) /Users/vagrant/workspace/IDE/macos-v1.2/src/cpp/r/RExec.cpp:224

    Here my script:

    
    
    my_custom_params <- list(
      author = "jm",
      project = list(
        folders = list(
          default = c("src", "data", "output", "data/raw", "data/temp", "output/plots", "output/reports", "output/data"),
          selected = c("src", "data", "output", "data/raw", "data/temp", "output/plots", "output/reports", "output/data")
        ),
        packages = list(
          default = rownames(utils::installed.packages()),
          selected = "tidyverse"
        )
      )
    )
    options("addinit" = my_custom_params)
    
    
  4. verajosemanuel commented on Aug 21, 2019

    @verajosemanuel
    Author

    With your previous list of directories, the display may not be optimal, tell me if you want I look into that.

    Yes, that would be good to be aligned in two or more lines to better layout

  5. pvictor commented on Aug 21, 2019

    @pvictor
    Member

    This is a weird error!

    Not a real answer, but you can skip the line with default = rownames(utils::installed.packages()),, e.g. :

    my_custom_params <- list(
      author = "jm",
      project = list(
        folders = list(
          default = c("src", "data", "output", "data/raw", "data/temp", "output/plots", "output/reports", "output/data"),
          selected = c("src", "data", "output", "data/raw", "data/temp", "output/plots", "output/reports", "output/data")
        ),
        packages = list(
          selected = "tidyverse"
        )
      )
    )
    options("addinit" = my_custom_params)

    I'll think about how to better manage the display

  6. verajosemanuel commented on Aug 21, 2019

    @verajosemanuel
    Author

    I'll think about how to better manage the display

    Thanks a lot, I think this is a great addin to accelerate coding workflow!

  7. hseverac commented on Feb 4, 2023

    @hseverac

    Apparently you have to use the namespace of the function utils::installed.packages

    Mac OS here. Add same problem and this did solve it.
    Thanks for your great AddInn package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions