Icon

kn_​example_​r_​basic_​knime_​in_​out_​flow_​variable

very basic R nodes in KNIME - knime.in, knime.out and handle Flow Variables

very basic R nodes in KNIME - knime.in, knime.out and handle Flow Variables
The Component will provide you with a curated R version in a conda environment "knime_r_environment"
You will need a working Miniforge (https://github.com/conda-forge/miniforge) or Miniconda (https://docs.conda.io/en/latest/miniconda.html) or Anaconda environment. As an alternative you could install your own R/RStudio and point KNIME to it without propagation.
In the /data/ folder there will be an Excel File my_r_packages_.xlsx that would contain a list of R packages from the installation.
---------------------------------
# you will need a working Anaconda oder Miniconda installation
# please note - the popular Anaconda package has changed its licensing recently.
# So make sure you comply with that. Or use Miniconda with conda-forge for the time being
# https://docs.conda.io/en/latest/miniconda.html

# following: https://hub.knime.com/marcelw/spaces/Public/latest/Conda_Environment_Propagation_for_R~WqCc-xp5owF0HC4p

conda create -n knime_r_environment -c defaults -c conda-forge r-base r-rserve r-essentials

# you might have to install a special version of RServe > 1.8.6
conda install -c conda-forge r-rserve=1.8_7

#
# To activate this environment, use
#

conda activate knime_r_environment

#
# To deactivate an active environment, use
#
# $ conda deactivate

# install in one step
conda install -c conda-forge r-ggplot2 r-sessioninfo r-foreign r-readr r-readxl r-cairo


# install in individual steps
conda install -c conda-forge r-sessioninfo
conda install -c conda-forge r-foreign
conda install -c conda-forge r-readr
conda install -c conda-forge r-cairo

# if you want to use h2o from within KNIME
conda install -c conda-forge r-h2o

# check the conda environments
conda info --envs






# transfer a flow variable from KNIME into Rv_path_data_in_r <- knime.flow.in[["v_data_path"]]# export a variable from R to KNIME Flow Variableknime.flow.out <- list(var_from_r = "my small text for KNIME from R")# knime.in is the data.frame that comes in from KNIME# knime.out is the data.frame that get back to KNIMEknime.out <- knime.in very basic R nodes in KNIME - knime.in, knime.out and handle Flow VariablesThe Component will provide you with a curated R version in a conda environment "knime_r_environment"You will need a working Miniforge (https://github.com/conda-forge/miniforge) or Miniconda (https://docs.conda.io/en/latest/miniconda.html) or Anaconda environment. As an alternative you could install your own R/RStudio and point KNIME to it without propagation.In the /data/ folder there will be an Excel File my_r_packages_<YYYY-MM-DD_HH-mm-ss>.xlsx that would contain a list of R packages from the installation. # you will need a working Anaconda / Miniconda or Miniforge installation# please note - the popular Anaconda package has changed its licensing recently. # So make sure you comply with that. Or use Miniforge with conda-forge for the time being# https://docs.conda.io/en/latest/miniconda.html# https://github.com/conda-forge/miniforge# following: https://hub.knime.com/marcelw/spaces/Public/latest/Conda_Environment_Propagation_for_R~WqCc-xp5owF0HC4pconda create -n knime_r_environment -c defaults -c conda-forge r-base r-rserve r-essentials# you might have to install a special version of RServe > 1.8.6conda install -c conda-forge r-rserve=1.8_7## To activate this environment, use#conda activate knime_r_environment## To deactivate an active environment, use## $ conda deactivate# install in one stepconda install -c conda-forge r-ggplot2 r-sessioninfo r-foreign r-readr r-readxl r-cairo# install in individual stepsconda install -c conda-forge r-sessioninfoconda install -c conda-forge r-foreignconda install -c conda-forge r-readrconda install -c conda-forge r-cairo# if you want to use h2o from within KNIMEconda install -c conda-forge r-h2o# check the conda environmentsconda info --envs # conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_r_basic_knime_in_out_flow_variable/data/py39_knime_r.yml"# conda env create -f="C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\py39_knime_r.yml"# conda env remove --name py39_knime_r# conda activate py39_knime_r# conda update -n py39_knime_r --all# conda env update --name py39_knime_r --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_r_basic_knime_in_out_flow_variable/data/py39_knime_r_windows.yml" --prune# conda env update --name py39_knime_r --file "C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\py39_knime_r_windows.yml" --prune# conda env update --name py39_knime_r --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_r_basic_knime_in_out_flow_variable/data/py39_knime_r_windows.yml"# conda env update --name py39_knime_r --file "C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\py39_knime_r_windows.yml"# conda update -n base conda# KNIME official Python integration guide# https://docs.knime.com/latest/python_installation_guide/index.html#_introduction# KNIME and Python — Setting up and managing Conda environments# https://medium.com/low-code-for-advanced-data-science/knime-and-python-setting-up-and-managing-conda-environments-2ac217792539# file: py39_knime_r.yml with some modifications# THX Carsten Haubold (https://hub.knime.com/carstenhaubold) for hintsname: py39_knime_r # Name of the created environmentchannels: # Repositories to search for packages - conda-forge# https://anaconda.org/knime - knime # conda search knime-python-base -c knime --info # to see what is in the packagedependencies: # List of packages that should be installed- python=3.9 # Python- knime-python-base # dependencies of KNIME - Python integration# - knime-python-scripting # everything you need to also build Python packages for KNIME- cairo # SVG support- pillow # Image inputs/outputs- matplotlib # Plotting- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- jpype1# Jupyter Notebook support- jupyter # Jupyter Notebook# ---- R packages via conda- r-base>=4.1.3- r-rserve>=1.8_7 # RServe to communicate between R and KNIME- r-essentials- r-cairo- r-ggplot2- r-sessioninfo- r-foreign- r-readr- r-readxl# additional packages- r-dplyr- r-fbasics- r-mlmetrics# ---------------- r-dplyr- r-fbasics - r-mlmetrics- r-knitr- r-plotly- r-lattice- r-pastecs- r-rsqlite# install the MLR3 family package# - r-mlr3verse# more machine learning packages- r-xgboost- r-gbm- r-caret- r-cubist- r-pls- r-randomforest- r-mgcv- r-nlme# SVM and R# - r-e1071 # Lasso and Ridge Regressions- r-glmnet- r-foreach- r-lars# T-SNE- r-rtsne- r-tsne- pip- pip: #- vtreat # https://medium.com/low-code-for-advanced-data-science/data-preparation-for-machine-learning-with-knime-and-the-python-vtreat-package-efcaf58fa783 locate and create/data/ folderwith absolute pathscurrent timeknime.out <- as.data.frame(installed.packages())=> list all packages installed on Rv_search_packageknime.out <- as.data.frame(.libPaths())knime.out <- as.data.frame(v_path_file_3)install_r_packagesv_data_pathmy_r_packages_<YYYY-MM-DD_HH-mm-ss>.xlsx=> export an overview over all yourpackages and store an informationto install them again in R codedummy dataR Code windowsingle window=> under advaced settings you can configure the conda environmentrframe <- knime.in=> under advaced settings you can configure the conda environmentrframe2 <- knime.inflow variable content back from Rknime.out <- rframe2 2.560x1.440PNG file/data/r_graphic.pngCluster_Membershipplot(knime.in)Propagate R environmentfor KNIME on Windows withMinicondaconfigure how to handle the environmentdefault = just check the namesPropagate R environmentfor KNIME on MacOS withMinicondaconfigure how to handle the environmentdefault = just check the namesPropagate R environmentfor KNIME on MacOS with(Apple Scilicon)Miniforge / Minicondaconfigure how to handle the environmentdefault = just check the namesfor Apple silicon you might have to manuallyinstall "RServe" currentlyCollect LocalMetadata Create Date&TimeRange R Source (Table) String Input(legacy) R Source (Table) R Source (Table) String Manipulation construct filename Java EditVariable (simple) Excel Writer Data Generator R Snippet Table to R Add Table To R ConstantValue Column Merge Variables R to Table Extract Date&TimeFields Image To Table Renderer to Image Table To Image Image Writer (Port) Column Rename R View (Table) knime_r_environment_windows knime_r_environment knime_r_environment_apple_silicon # transfer a flow variable from KNIME into Rv_path_data_in_r <- knime.flow.in[["v_data_path"]]# export a variable from R to KNIME Flow Variableknime.flow.out <- list(var_from_r = "my small text for KNIME from R")# knime.in is the data.frame that comes in from KNIME# knime.out is the data.frame that get back to KNIMEknime.out <- knime.in very basic R nodes in KNIME - knime.in, knime.out and handle Flow VariablesThe Component will provide you with a curated R version in a conda environment "knime_r_environment"You will need a working Miniforge (https://github.com/conda-forge/miniforge) or Miniconda (https://docs.conda.io/en/latest/miniconda.html) or Anaconda environment. As an alternative you could install your own R/RStudio and point KNIME to it without propagation.In the /data/ folder there will be an Excel File my_r_packages_<YYYY-MM-DD_HH-mm-ss>.xlsx that would contain a list of R packages from the installation. # you will need a working Anaconda / Miniconda or Miniforge installation# please note - the popular Anaconda package has changed its licensing recently. # So make sure you comply with that. Or use Miniforge with conda-forge for the time being# https://docs.conda.io/en/latest/miniconda.html# https://github.com/conda-forge/miniforge# following: https://hub.knime.com/marcelw/spaces/Public/latest/Conda_Environment_Propagation_for_R~WqCc-xp5owF0HC4pconda create -n knime_r_environment -c defaults -c conda-forge r-base r-rserve r-essentials# you might have to install a special version of RServe > 1.8.6conda install -c conda-forge r-rserve=1.8_7## To activate this environment, use#conda activate knime_r_environment## To deactivate an active environment, use## $ conda deactivate# install in one stepconda install -c conda-forge r-ggplot2 r-sessioninfo r-foreign r-readr r-readxl r-cairo# install in individual stepsconda install -c conda-forge r-sessioninfoconda install -c conda-forge r-foreignconda install -c conda-forge r-readrconda install -c conda-forge r-cairo# if you want to use h2o from within KNIMEconda install -c conda-forge r-h2o# check the conda environmentsconda info --envs # conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_r_basic_knime_in_out_flow_variable/data/py39_knime_r.yml"# conda env create -f="C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\py39_knime_r.yml"# conda env remove --name py39_knime_r# conda activate py39_knime_r# conda update -n py39_knime_r --all# conda env update --name py39_knime_r --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_r_basic_knime_in_out_flow_variable/data/py39_knime_r_windows.yml" --prune# conda env update --name py39_knime_r --file "C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\py39_knime_r_windows.yml" --prune# conda env update --name py39_knime_r --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_r_basic_knime_in_out_flow_variable/data/py39_knime_r_windows.yml"# conda env update --name py39_knime_r --file "C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\py39_knime_r_windows.yml"# conda update -n base conda# KNIME official Python integration guide# https://docs.knime.com/latest/python_installation_guide/index.html#_introduction# KNIME and Python — Setting up and managing Conda environments# https://medium.com/low-code-for-advanced-data-science/knime-and-python-setting-up-and-managing-conda-environments-2ac217792539# file: py39_knime_r.yml with some modifications# THX Carsten Haubold (https://hub.knime.com/carstenhaubold) for hintsname: py39_knime_r # Name of the created environmentchannels: # Repositories to search for packages - conda-forge# https://anaconda.org/knime - knime # conda search knime-python-base -c knime --info # to see what is in the packagedependencies: # List of packages that should be installed- python=3.9 # Python- knime-python-base # dependencies of KNIME - Python integration# - knime-python-scripting # everything you need to also build Python packages for KNIME- cairo # SVG support- pillow # Image inputs/outputs- matplotlib # Plotting- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- jpype1# Jupyter Notebook support- jupyter # Jupyter Notebook# ---- R packages via conda- r-base>=4.1.3- r-rserve>=1.8_7 # RServe to communicate between R and KNIME- r-essentials- r-cairo- r-ggplot2- r-sessioninfo- r-foreign- r-readr- r-readxl# additional packages- r-dplyr- r-fbasics- r-mlmetrics# ---------------- r-dplyr- r-fbasics - r-mlmetrics- r-knitr- r-plotly- r-lattice- r-pastecs- r-rsqlite# install the MLR3 family package# - r-mlr3verse# more machine learning packages- r-xgboost- r-gbm- r-caret- r-cubist- r-pls- r-randomforest- r-mgcv- r-nlme# SVM and R# - r-e1071 # Lasso and Ridge Regressions- r-glmnet- r-foreach- r-lars# T-SNE- r-rtsne- r-tsne- pip- pip: #- vtreat # https://medium.com/low-code-for-advanced-data-science/data-preparation-for-machine-learning-with-knime-and-the-python-vtreat-package-efcaf58fa783 locate and create/data/ folderwith absolute pathscurrent timeknime.out <- as.data.frame(installed.packages())=> list all packages installed on Rv_search_packageknime.out <- as.data.frame(.libPaths())knime.out <- as.data.frame(v_path_file_3)install_r_packagesv_data_pathmy_r_packages_<YYYY-MM-DD_HH-mm-ss>.xlsx=> export an overview over all yourpackages and store an informationto install them again in R codedummy dataR Code windowsingle window=> under advaced settings you can configure the conda environmentrframe <- knime.in=> under advaced settings you can configure the conda environmentrframe2 <- knime.inflow variable content back from Rknime.out <- rframe2 2.560x1.440PNG file/data/r_graphic.pngCluster_Membershipplot(knime.in)Propagate R environmentfor KNIME on Windows withMinicondaconfigure how to handle the environmentdefault = just check the namesPropagate R environmentfor KNIME on MacOS withMinicondaconfigure how to handle the environmentdefault = just check the namesPropagate R environmentfor KNIME on MacOS with(Apple Scilicon)Miniforge / Minicondaconfigure how to handle the environmentdefault = just check the namesfor Apple silicon you might have to manuallyinstall "RServe" currentlyCollect LocalMetadata Create Date&TimeRange R Source (Table) String Input(legacy) R Source (Table) R Source (Table) String Manipulation construct filename Java EditVariable (simple) Excel Writer Data Generator R Snippet Table to R Add Table To R ConstantValue Column Merge Variables R to Table Extract Date&TimeFields Image To Table Renderer to Image Table To Image Image Writer (Port) Column Rename R View (Table) knime_r_environment_windows knime_r_environment knime_r_environment_apple_silicon

Nodes

Extensions

Links