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/knime_r_environment.yml"# conda env create -f="C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\knime_r_environment.yml"# conda env remove --name knime_r_environment# conda activate knime_r_environment# conda update -n knime_r_environment --all# conda env update --name knime_r_environment --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_r_basic_knime_in_out_flow_variable/data/knime_r_environment.yml" --prune# conda env update --name knime_r_environment --file "C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\knime_r_environment.yml" --prune# conda env update --name knime_r_environment --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_r_basic_knime_in_out_flow_variable/data/knime_r_environment.yml"# conda env update --name knime_r_environment --file "C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\knime_r_environment.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: knime_r_environment.yml with some modifications# THX Carsten Haubold (https://hub.knime.com/carstenhaubold) for hintsname: knime_r_environment # 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# Essential R packages for data science- r-essentials # A collection of essential R packages including dplyr, ggplot2, tidyr, readr, etc.# Graphical display and visualization- r-cairo # A graphics device that uses the Cairo library, used for creating high-quality plots- r-ggplot2 # A widely used data visualization package based on the Grammar of Graphics# Session and environment management- r-sessioninfo # Provides detailed information about the R session, useful for debugging and reproducibility# Data import and export- r-foreign # Functions to read and write data files in various formats (e.g., SPSS, Stata, Systat)- r-readr # Fast and friendly functions for reading rectangular data (like CSV files)- r-readxl # Functions to read Excel files into R# Additional packages- r-dplyr # A grammar of data manipulation, providing a consistent set of verbs to solve data problems- r-fbasics # Basic functions for financial engineering and computational finance- r-mlmetrics # A set of metrics for evaluating machine learning models- r-xml # Tools for reading and creating XML documents# Duplicated packages (should ideally be listed once)- r-dplyr # A grammar of data manipulation (duplicate)- r-fbasics # Financial data analysis (duplicate)- r-mlmetrics # Machine learning evaluation metrics (duplicate)# Reporting and interactive graphics- r-knitr # Dynamic report generation in R using Literate Programming- r-plotly # An interface to the Plotly.js library for creating interactive graphs and plots- r-lattice # Data visualization system similar to ggplot2, but with different syntax and capabilities- r-pastecs # Functions for analyzing time series and descriptive statistics- r-rsqlite # R interface to SQLite databases, used for data storage and management# Machine Learning packages (MLR3 and others)# install the MLR3 family package# - r-mlr3verse # The MLR3 ecosystem for machine learning in R (commented out here)# Additional machine learning packages- r-xgboost # Extreme Gradient Boosting, a powerful ensemble method for regression and classification- r-h2o # A platform for distributed, scalable machine learning- r-gbm # Generalized Boosted Regression Models- r-caret # A set of functions to streamline the process for creating predictive models- r-cubist # Rule-based ensemble regression modeling- r-pls # Partial Least Squares and Principal Component Regression- r-randomforest # An implementation of Breiman's random forest algorithm for classification and regression- r-mgcv # Mixed GAM computation vehicle with GCV/AIC/REML smoothness estimation- r-nlme # Fit and compare Gaussian linear and nonlinear mixed-effects models- r-pmml # Generate Predictive Model Markup Language (PMML) for sharing models# Support Vector Machines (SVM) (commented out here)# - r-e1071 # Provides functions for Support Vector Machines, clustering, and more# Lasso and Ridge Regressions- r-glmnet # Lasso and Elastic-Net Regularized Generalized Linear Models- r-foreach # Support for parallel computing using foreach loops- r-lars # Least Angle Regression, Lasso, and Stagewise regression methods# Dimensionality reduction techniques (T-SNE)- r-rtsne # An R wrapper around the Barnes-Hut implementation of T-SNE for large datasets- r-tsne # A package to perform T-distributed Stochastic Neighbor Embedding# Additional dependencies- pip # Python package manager, used to install and manage Python dependencies- pip: #- vtreat # https://medium.com/low-code-for-advanced-data-science/data-preparation-for-machine-learning-with-knime-and-the-python-vtreat-package-efcaf58fa783 Medium: KNIME and R — installation across operating systems — some remarkshttps://medium.com/p/6494a2a498ccvery basic R nodes in KNIME - knime.in, knime.out and handle Flow Variableshttps://hub.knime.com/-/spaces/-/~119aEydIH0oCdht8/current-state/ 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)"conda.environment" variablePropagate Python and R environmentfor KNIME on MacOSX (Apple Scilicon)OR Windowswith Miniforge / Minicondaconfigure how to handle the environmentdefault = just check the namesCollect 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) conda_r_knime # 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/knime_r_environment.yml"# conda env create -f="C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\knime_r_environment.yml"# conda env remove --name knime_r_environment# conda activate knime_r_environment# conda update -n knime_r_environment --all# conda env update --name knime_r_environment --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_r_basic_knime_in_out_flow_variable/data/knime_r_environment.yml" --prune# conda env update --name knime_r_environment --file "C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\knime_r_environment.yml" --prune# conda env update --name knime_r_environment --file "/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_r_basic_knime_in_out_flow_variable/data/knime_r_environment.yml"# conda env update --name knime_r_environment --file "C:\\Users\\x123456\\knime-workspace\\hub\\kn_example_r_basic_knime_in_out_flow_variable\\data\\knime_r_environment.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: knime_r_environment.yml with some modifications# THX Carsten Haubold (https://hub.knime.com/carstenhaubold) for hintsname: knime_r_environment # 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# Essential R packages for data science- r-essentials # A collection of essential R packages including dplyr, ggplot2, tidyr, readr, etc.# Graphical display and visualization- r-cairo # A graphics device that uses the Cairo library, used for creating high-quality plots- r-ggplot2 # A widely used data visualization package based on the Grammar of Graphics# Session and environment management- r-sessioninfo # Provides detailed information about the R session, useful for debugging and reproducibility# Data import and export- r-foreign # Functions to read and write data files in various formats (e.g., SPSS, Stata, Systat)- r-readr # Fast and friendly functions for reading rectangular data (like CSV files)- r-readxl # Functions to read Excel files into R# Additional packages- r-dplyr # A grammar of data manipulation, providing a consistent set of verbs to solve data problems- r-fbasics # Basic functions for financial engineering and computational finance- r-mlmetrics # A set of metrics for evaluating machine learning models- r-xml # Tools for reading and creating XML documents# Duplicated packages (should ideally be listed once)- r-dplyr # A grammar of data manipulation (duplicate)- r-fbasics # Financial data analysis (duplicate)- r-mlmetrics # Machine learning evaluation metrics (duplicate)# Reporting and interactive graphics- r-knitr # Dynamic report generation in R using Literate Programming- r-plotly # An interface to the Plotly.js library for creating interactive graphs and plots- r-lattice # Data visualization system similar to ggplot2, but with different syntax and capabilities- r-pastecs # Functions for analyzing time series and descriptive statistics- r-rsqlite # R interface to SQLite databases, used for data storage and management# Machine Learning packages (MLR3 and others)# install the MLR3 family package# - r-mlr3verse # The MLR3 ecosystem for machine learning in R (commented out here)# Additional machine learning packages- r-xgboost # Extreme Gradient Boosting, a powerful ensemble method for regression and classification- r-h2o # A platform for distributed, scalable machine learning- r-gbm # Generalized Boosted Regression Models- r-caret # A set of functions to streamline the process for creating predictive models- r-cubist # Rule-based ensemble regression modeling- r-pls # Partial Least Squares and Principal Component Regression- r-randomforest # An implementation of Breiman's random forest algorithm for classification and regression- r-mgcv # Mixed GAM computation vehicle with GCV/AIC/REML smoothness estimation- r-nlme # Fit and compare Gaussian linear and nonlinear mixed-effects models- r-pmml # Generate Predictive Model Markup Language (PMML) for sharing models# Support Vector Machines (SVM) (commented out here)# - r-e1071 # Provides functions for Support Vector Machines, clustering, and more# Lasso and Ridge Regressions- r-glmnet # Lasso and Elastic-Net Regularized Generalized Linear Models- r-foreach # Support for parallel computing using foreach loops- r-lars # Least Angle Regression, Lasso, and Stagewise regression methods# Dimensionality reduction techniques (T-SNE)- r-rtsne # An R wrapper around the Barnes-Hut implementation of T-SNE for large datasets- r-tsne # A package to perform T-distributed Stochastic Neighbor Embedding# Additional dependencies- pip # Python package manager, used to install and manage Python dependencies- pip: #- vtreat # https://medium.com/low-code-for-advanced-data-science/data-preparation-for-machine-learning-with-knime-and-the-python-vtreat-package-efcaf58fa783 Medium: KNIME and R — installation across operating systems — some remarkshttps://medium.com/p/6494a2a498ccvery basic R nodes in KNIME - knime.in, knime.out and handle Flow Variableshttps://hub.knime.com/-/spaces/-/~119aEydIH0oCdht8/current-state/ 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)"conda.environment" variablePropagate Python and R environmentfor KNIME on MacOSX (Apple Scilicon)OR Windowswith Miniforge / Minicondaconfigure how to handle the environmentdefault = just check the namesCollect 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) conda_r_knime

Nodes

Extensions

Links