Skip to content

Incorrect comment character in R code #8641

Closed

Description

@garciamikep

Describe the bug

The R script CH.r appears to use % as a comment character rather than #. This invalid R code is problematic when also using renv (an R virtual environment tool, similar to venv for Python) for dependency detection.

Changing the comment character to # should fix the issue – happy to open a simple PR addressing this if it makes things easier.

Code Sample

Steps to reproduce (assuming R is installed)

# Create venv and install statsmodels
mkdir renv-issue && cd renv-issue
python3 -m venv venv/
source venv/bin/activate
pip install statsmodels

# Install renv R package
R -e "install.packages('remotes', repos='http://cran.us.r-project.org')"
R -e "remotes::install_github('rstudio/[email protected]')"

# initialize renv library (and discover dependencies)
R -e "renv::init()"

That last line gives the following error, with unexpected input at the % character:

WARNING: One or more problems were discovered while enumerating dependencies.

/Users/mike.garcia/renv-issue/venv/lib/python3.9/site-packages/statsmodels/stats/libqsturng/CH.r
------------------------------------------------------------------------------------------------

ERROR 1: /Users/mike.garcia/renv-issue/venv/lib/python3.9/site-packages/statsmodels/stats/libqsturng/CH.r:1:1: unexpected input
1: % Copyright (c) 2011, Roger Lew BSD [see LICENSE.txt]
    ^
Details

This is not directly an issue for using statsmodels (as far as I can tell), but is creating some issues when using renv in a multi-lingual project that also contains a Python virtual environment containing statsmodels. The renv package automatically discovers R dependencies in the project directory: when it encounters the invalid R code in CH.r it throws an unexpected input warning requiring user y/n prompt to proceed.

I realize that renv provides a option to use a .renvignore file analogous to .gitignore to which the virtual environment could (should?) be added. But thought I'd raise the flag on the R syntax here anyway.

  • ✅ I did not find any issue referencing CH.r in current issues.
  • ✅ Issue is present in current version of main branch.

Expected Output

R -e renv::init() in the above reprex should not display the error in

Output of import statsmodels.api as sm; sm.show_versions()

Details

INSTALLED VERSIONS
------------------
Python: 3.9.5.final.0
OS: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64 x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

statsmodels
===========

Installed: 0.13.5 (/Users/mike.garcia/renv-issue/venv/lib/python3.9/site-packages/statsmodels)

Required Dependencies
=====================

cython: Not installed
numpy: 1.24.1 (/Users/mike.garcia/renv-issue/venv/lib/python3.9/site-packages/numpy)
scipy: 1.10.0 (/Users/mike.garcia/renv-issue/venv/lib/python3.9/site-packages/scipy)
pandas: 1.5.3 (/Users/mike.garcia/renv-issue/venv/lib/python3.9/site-packages/pandas)
    dateutil: 2.8.2 (/Users/mike.garcia/renv-issue/venv/lib/python3.9/site-packages/dateutil)
patsy: 0.5.3 (/Users/mike.garcia/renv-issue/venv/lib/python3.9/site-packages/patsy)

Optional Dependencies
=====================

matplotlib: Not installed
cvxopt: Not installed
joblib: Not installed

Developer Tools
================

IPython: Not installed
    jinja2: Not installed
sphinx: Not installed
    pygments: Not installed
pytest: Not installed
virtualenv: Not installed

Activity

  1. added a commit that references this issue on Feb 3, 2023
    b219d4c
  2. added this to the 0.14 milestone on Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions