问题
I just tried out Roxygen package. Within R, I can run through the example in the Roxygen Vignette. But In command line, R CMD roxygen
is not recognized as a valid command. When I run R CMD --help
, I can see all INSTALL, check, ...sweave..., config...
command items but not roxygen. can anyone help me out of this? is there addtional installation steps required other than install.packages("roxygen")
? I use windows 32 with R 2.12.0 and working Rtools environments. Thanks.
回答1:
If I recall, you have to install packages from source in order for them to be able to provide additional commands for R CMD
. This is because installing new R CMD
commands is a bit of a hack---it requires hijacking the configure script or Makefile and having them copy files to the R bin folder. Installing a package from binary simply unpacks an archive, configure
and make
are never run.
So try install.packages('roxygen', type='source')
. On Windows you will need to install the RTools before this will work.
回答2:
I just ran into this the other day. I installed as administrator and that fixed it. Just run R as Administrator then do install.packages as normal, then restart R since you don't really want to run it as administrator.
回答3:
This is a workaround that I have found to be useful working with roxygen2
from the command line (DOS) in Windows. Much of the material is borrowed from here.
Create file roxy.R
with contents:
library(methods)
library(utils)
require(roxygen2)
roxygenize("myPackage")
(Or whatever arguments you're using with roxygen
).
Then create batch file f.bat
with contents:
Rscript roxy.R
Then run f
from the command line:
> f
Notes:
Make sure Rscript.exe
is in your path. It's usually found somewhere like c:\r:\bin\
(To edit the path in Windows, right click 'My Computer', then select 'Properties' then 'Advanced system settings' (on left menu) then 'Advanced' tab, 'Environment Variables' button, 'System variables', 'Path'.)
回答4:
I tested on windows. R CMD %R_home%\bin\roxygen.sh
works.
but neither R CMD roxygen.sh
nor R CMD roxygen
works under DOS command. Although .sh
has been associated to sh.exe
and %R_home%\bin\
is on system path.
Same for installing by source with R CMD INSTALL
or install.packages(type='source')
.
来源:https://stackoverflow.com/questions/4389070/r-cmd-roxygen-not-recognized