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/16 21:01] chrystian Fixed invalid link. |
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 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 ===== |