Creating Graphics in R Command Prompt using the Database

Using the database we can perform different calculations on the column of the tables present in the database. For doing that first we have to connect to the database which is shown in the previous post. Then we have to sync the ORE objects with our schema using the ore.sync() function. After we sync with the database we can then see our database tables in the console by using the command

Step 1: Connect to the database from the R instance. Please refer Database Connection.

Step 2: Sync to the database tables using the command ore.sync(“schema_name”). See the database tables by using the command.


Here you can see the tables that are loaded into the database. We have loaded the data from the excel files.

Step 3: Then we can also check the data from the database by the command head(table_name). For example, we can see the first few rows of the table.




Step 4: Now you can type the command x11() and then there will be a graphics window opened and then you can perform all the graphical visualizations. You can see in the image below the is a graphics device active named RGrahics.



Step 5: You can prepare any kind of graphs using any data for example:

Here we have assigned some values to x and y then used the plot() function to plot the randomly generated numbers from rnorm() functon.



Step 6: For plotting a simple bar graph, you can use the function barplot().
Here we have assigned a collection of values to a variable dig, passed it inside the barplot function and used the bar=rainbow() function for coloring the bars.



Step 7: On using the Plot() function it creates a graph that is most suitable for analyzing data.
Inside the function you pass the argument table_name$column_name.

plot function

Leave A Reply

Your email address will not be published. Required fields are marked *