Я не уверен, что понял ваш вопрос. Вы имеете в виду что-то вроде
[email protected]:~$ which r
/usr/local/bin/r
[email protected]:~$
Вы можете сравнить результат which
с пустой строкой в качестве ничего не возвращается, когда вы просите несуществующей программы.
[email protected]:~$ which s # we know we don't have this
[email protected]:~$
Вы можете использовать результат which r
для проверки, скажем, версия:
[email protected]:~$ `which r` --version
r ('littler') version 0.2.2
git revision 8df31e5 as of Thu Jan 29 17:43:21 2015 -0800
built at 19:48:17 on Jan 29 2015
using GNU R Version 3.1.2 (2014-10-31)
Copyright (C) 2006 - 2014 Jeffrey Horner and Dirk Eddelbuettel
r is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License. For more information about
these matters, see http://www.gnu.org/copyleft/gpl.html.
[email protected]:~$
Edit: Как вы, кажется, путают о interactive()
истинным или ложным, считают r --help
:
[email protected]:~$ r --help
Usage: r [options] [-|file]
Launch GNU R to execute the R commands supplied in the specified file, or
from stdin if '-' is used. Suitable for so-called shebang '#!/'-line scripts.
Options:
-h, --help Give this help list
--usage Give a short usage message
-V, --version Show the version number
-v, --vanilla Pass the '--vanilla' option to R
-t, --rtemp Use per-session temporary directory as R does
-i, --interactive Let interactive() return 'true' rather than 'false'
-q, --quick Skip autoload/delayed assign of default libraries
-p, --verbose Print the value of expressions to the console
-l, --packages list Load the R packages from the comma-separated 'list'
-d, --datastdin Prepend command to load 'X' as csv from stdin
-e, --eval expr Let R evaluate 'expr'
[email protected]:~$
и
[email protected]:~$ r -e'print(interactive())'
[1] FALSE
[email protected]:~$ r -i -e'print(interactive())'
[1] TRUE
[email protected]:~$
но это установка это, в отличие от запроса.
Я ожидаю, что 'interactive' делает то, что мне нужно. Мне нужно некоторое время, чтобы посмотреть на ваши «модули». – Diego
@ Diego Да, этого может быть достаточно. Проблема, с которой 'interactive()' имеет и какие модули решает, заключается в том, что она также будет «TRUE» для кода библиотеки, который вы загружаете в своем интерактивном сеансе. Это раздражает, когда вы хотите повторно использовать части своего кода, но * также * иметь этот код независимо от исполняемого файла. Это довольно распространенный шаблон в пакетах Python, который я нашел полезным и в R. –