Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
reference_book:r_coupling [2023/05/12 20:31] chrystian Removed references to 'DinamicaEGO 4' |
reference_book:r_coupling [2023/10/11 20:35] (current) chrystian Updated recommended Ubuntu version. |
||
|---|---|---|---|
| Line 11: | Line 11: | ||
| For Linux O.S. users, we provide a detailed step-by-step tutorial on integrating DinamicaEGO with the R environment. | For Linux O.S. users, we provide a detailed step-by-step tutorial on integrating DinamicaEGO with the R environment. | ||
| - | It is recommended to use Ubuntu LTS 20.04 (preferably) or 22.04 for this tutorial. Please follow the steps below: | + | It is recommended to use Ubuntu LTS 22.04 for this tutorial. Please follow the steps below: |
| **1. Download DinamicaEGO:** Make sure that the downloaded file has permission to execute on your computer. | **1. Download DinamicaEGO:** Make sure that the downloaded file has permission to execute on your computer. | ||
| Line 28: | Line 28: | ||
| sudo apt install r-base | sudo apt install r-base | ||
| </code> | </code> | ||
| - | Make sure that the installed version is **4.3 or higher**. For specific instructions on installing R, please refer to the following link [https://cran.r-project.org/bin/linux/ubuntu]. | + | Make sure that the installed version is **4.3 or higher**. For specific instructions on installing R, please refer to the following link [ https://cran.r-project.org/bin/linux/ubuntu ]. |
| **4. Configure R in DinamicaEGO:** Now, let's configure DinamicaEGO to use the R installation you just performed. | **4. Configure R in DinamicaEGO:** Now, let's configure DinamicaEGO to use the R installation you just performed. | ||
| Line 40: | Line 40: | ||
| Once the procedure above is complete, the R scripts can be used by Calculate R Expression | Once the procedure above is complete, the R scripts can be used by Calculate R Expression | ||
| + | |||
| + | ===== Example: Calculate R Expression ===== | ||
| + | You can use the Calculate R expression function using the following example: | ||
| + | |||
| + | <code> | ||
| + | # Install and load the required packages | ||
| + | dinamicaPackage("dplyr") | ||
| + | |||
| + | # Read the table. | ||
| + | input <- read.csv(s1) | ||
| + | |||
| + | # Print the table | ||
| + | print(input) | ||
| + | |||
| + | # Use the table connected to the Calculate Expression. | ||
| + | input2 = t1 | ||
| + | |||
| + | # Print the table | ||
| + | print(input2) | ||
| + | |||
| + | # Create a new table | ||
| + | data <- data.frame( | ||
| + | name = c("John", "Jane", "Mike"), | ||
| + | age = c(25, 30, 35), | ||
| + | city = c("New York", "London", "Paris"), | ||
| + | stringsAsFactors = FALSE | ||
| + | ) | ||
| + | |||
| + | # Print the table | ||
| + | print(data) | ||
| + | |||
| + | # Calculate the arithmetic mean of column1 using dplyr | ||
| + | mean_column1 <- data %>% summarise(mean_column1 = mean(age)) | ||
| + | | ||
| + | # Print the arithmetic mean of column1 | ||
| + | print(mean_column1$mean_column1) | ||
| + | </code> | ||
| ===== Exchanging Data between R and Dinamica ===== | ===== Exchanging Data between R and Dinamica ===== | ||