How to install the R package rattle on Ubuntu

To install the R package rattle for Data Mining on Ubuntu, firstly you must install the wajig ubuntu package which is a simplified wrapper to the package management system dpkg/apt, running the following command in the ubuntu terminal:

sudo apt-get install wajig

After that, we must install the graphical libraries libgtk2.0-dev and libxml2-dev with the following command in the ubuntu terminal:

sudo wajig install libgtk2.0-dev libxml2-dev

Next, the packages RGtk2 and rattle must be installed with the following commands in the R console:

install.packages("RGtk2")
install.packages("rattle")

Finally, to start rattle the following R code must be executed:

library(rattle)
rattle()

If you made all the steps required to install rattle, the following screen will be appear.

rattle2

Posted in DataScience, R | Leave a comment

How to know the disk size of a PostgreSQL table

The easiest way to know the disk size of a Postgresql table is run the following command:

\d+ 
Posted in PostgreSQL | Leave a comment

How to send the result of a sql query into a csv file in PostgreSQL

If you want to send the result of a sql query into a csv file in PostgreSQL you must use the \COPY command. For example, suppose you have the table example with a field and you need to send the query:

SELECT * FROM example ORDER BY id ASC

To the file example.csv, you must run the following command in the PostgreSQL terminal:

\COPY (SELECT * FROM example ORDER BY id ASC) to example.csv csv header
Posted in PostgreSQL | Leave a comment

How to know the size of ram memory

To know the size of ram memory, you must run the following command:

grep MemTotal /proc/meminfo

You can get more information with the following command:

cat /proc/meminfo
Posted in linux | Leave a comment

How to know the size of a Postgres database

If you want to know the size of a Postgres database on disk, we must run the following sql command:

SELECT pg_database.datname,  
       pg_size_pretty(pg_database_size(pg_database.datname)) AS size  
  FROM pg_database;
Posted in linux | Leave a comment

Export Postgres table to csv file with headers

To export a Postgres table to a csv file with headers you must log into the shell of Postgres and execute something like this:

\COPY my_table to 'filename.csv' csv header 

Where my_table is the table I want to export and filename.csv is the exported file.

Posted in R | Leave a comment

How to install SQLite on Ubuntu

To install SQLite on Ubuntu, you must run the following command in a terminal:

sudo apt-get install sqlite3 libsqlite3-dev
Posted in linux | Leave a comment

How to execute R file in batch mode

To execute an R file in batch mode, you must open a terminal and run the following code:

R CMD BATCH infile & 

Where infile is a text file with R code.

Posted in linux, R | Leave a comment

How to show the toolbox in gimp

When I use gimp in some occasions the main toolbox (the one with painting tools) has disappeared. There are two solutions:

1) Go to the menu Windows -> Recently Closed Docks

2) Go to Edit -> Preferences in the Window Management section, and press the Reset Saved Window Positions to Default Values button as it is shown in the below image.

gimp

Posted in linux | Leave a comment

How to create a shutdown user

To create a shutdown user, first of all we create the user with the following command:

adduser shutdown

When the command is run, the password must be provided along with other information. After that the following lines must be added to the file /etc/sudoers

## user shutdown is allowed to execute shutdown command
shutdown ALL=NOPASSWD: /sbin/shutdown
Posted in linux | Leave a comment