data_attach


See also: data_custom

As we know from previous chapters, Stagraph works as a GUI on the top of the R programming language, which runs as a background terminal. This allows you to use also features that are not directly supported through the visual interface. An example can be sample datasets that are part of the R Environment. It is also possible (using the data_attach function) to load the dataset that you created instantly via the integrated R Console.

To load a dataset that exists in running R Terminal, press the Rterm button in the ribbon toolbar and click on the Attach menu item.

A help dialog appears in which you set two parameters. In the Dataset Name text-box, you define the name of the dataset that will be used inside the Stagraph. Then, into the Dataset from Console text-box write the name of the dataset from R Terminal you want to link.

If you have both parameters defined, click on the Apply button. If the defined dataset in R Runtime is found, it is imported into the Stagraph interface under defined name (Dataset Name).The condition is that the dataset must be in the form of the data.frame object. The following figure shows an example of sample dataset import - iris.

As has been said, in addition to sample datasets, you can also import the datasets you created instantly in the integrated R Console. The following figure is an example of a dataset (named Data2) that was manually created using the data.frame function. R script was successfully executed in the background R Terminal.

Ather its execution, you can load it into the Stagraph GUI, as in the case of sample datasets - via the data_attach function. In displayed dialog you link the dataset from Terminal (Data2) with a new name for Stagraph interface (df2).

After pressing the Apply button, defined dataset will be listed in the Project Panel. Subsequently, you can continue at work with the dataset.

With the described data_attach function, you need to be aware of one fact. If you use it on a dataset that you created instantly through the R Console, your custom script will not be saved into the project file. In this case, you will need to manually re-execute it through the R Console. To save the R script into the project file, use the data_custom function instead the data_attach. The data_custom function allows you to save a user-defined R script to the project.

After the dataset import, you can later edit it in the Properties Panel. Since it is a simple function, its setting options are “relatively" limited. Basically, you can only change the name of the dataset (in R Terminal) that you link. In the text-box contextual menu you find only a choice of three commonly used sample datasets - diamonds, iris and mtcars.