python in RStudio
R에서 miniconda설치 후(https://onesixx.com/reticulate/),
R스크립트에서 관련 Library 불러오고, 특정 conda 가상환경및 python 위치를 지정하여 준비한다.
이후, OOO.py 로 파일을 만들면, RStudio에서 python코드를 실행할 수 있다.
> reticulate::repl_python() Python 3.6.10 (/home/onesixx/.local/share/r-miniconda/envs/sixxDL/bin/python) Reticulate 1.16 REPL -- A Python interpreter in R. >>> from pandas import read_csv >>> from matplotlib import pyplot >>> dataset = read_csv('pollution.csv', header=0, index_col=0) >>> dataset No pollution dew temp ... wnd_spd snow rain daytime 1 25 129 -16 -4.0 ... 1.79 0 0 2010-01-02 00:00:00 2 26 148 -15 -4.0 ... 2.68 0 0 2010-01-02 01:00:00 3 27 159 -11 -5.0 ... 3.57 0 0 2010-01-02 02:00:00 4 28 181 -7 -5.0 ... 5.36 1 0 2010-01-02 03:00:00 5 29 138 -7 -5.0 ... 6.25 2 0 2010-01-02 04:00:00 ... ... ... ... ... ... ... ... ... ... 43796 43820 8 -23 -2.0 ... 231.97 0 0 2014-12-31 19:00:00 43797 43821 10 -22 -3.0 ... 237.78 0 0 2014-12-31 20:00:00 43798 43822 10 -22 -3.0 ... 242.70 0 0 2014-12-31 21:00:00 43799 43823 8 -22 -4.0 ... 246.72 0 0 2014-12-31 22:00:00 43800 43824 12 -21 -3.0 ... 249.85 0 0 2014-12-31 23:00:00
특정 가상환경에 추가적인 패키지를 설치하려고 할때,
RStudio내에 Terminal이 안되는 경우가 있으며, 기존의 사용하던 Terminal을 이용하면 문제없이 설치된다.