Archive for category Tips

Ubuntu 16.04 TLS Development Environment

Ubuntu 16.04 TLS is a good, stable OS. After install the Ubuntu Desktop system, a set of applications should be installed to get a nice programming environment.

1 Web development applications
A while ago I wrote an article “Web Development Tools for Ubuntu OS“. It introduced Geany for editing, Workbench for SQL, Meld for file comparison, and Google Chrome for web testing. These applications are still hold true for Ubuntu 16.04 TLS.

2. R programming environment
First, install R base. Execute the following command in a terminal window (CTL + ALT + T) to add the source url to the APT source list.

sudo echo “deb xenial/” | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install r-base r-base-dev

Then, install RStudio. Use the “Ubuntu Software” to search for R Studio and install it. It is pretty straight forward.

After install R Studio, you can open it and check if it works.

3. Python programming environment

Install Spyder. Use the “Ubuntu Software” to search for “Spyder” and install it. It is pretty straight forward.


Tags: , , ,

PyCharm – The Python IDE crossing multiple platforms

Here is the declaration on the PyCharm site about it.

PyCharm is a dedicated Python and Django IDE providing a wide range of essential tools for Python developers, tightly integrated together to create a convenient environment for productive Python development and Web development.

It is available for Windows, macOS, and Linux. It can be downloaded from

I just start using it. I read some good comments about it from the internet.


Tags: , ,

Using rsqlserver package in R

In R programming environment, you can conveniently connect to SQL Server through RSQLServer package. However, it is little bit tricky. Not like to way you connect MySQL server through RMySQL package. I searched RSQLServer on Google and tried to find a good example to connect to the SQL server. At the beginning, nothing worked. One time I read a post and used the method in the post. I was able to connect to the SQL Server. However, the connection opened a system database instead of the database I wanted to connect. Eventually I use R help command to learn how to use dbConnect function. That helps figuring out the correct method to connect to the right database on the SQL server.

1) Install the package: RSQLServer. Run command in R:


2) To use the package, you only need to use the following R command:


3) To connect to a specific database on a given SQL Server:

con < - dbConnect( RSQLServer::SQLServer(), server="localhost", database = "yourdatabasename", properties=list(user="yourusername", password="yourpassword") )

That should work well for you. You have to provide your SQL Server IP address, database name, your login information to the function.

One get get connected, to query the database table and manipulate data in the database, you can use all the functions available in DBI package. There is no more tricks.


Tags: , , ,

Generate a Windows command file and execute it in R

R is a powerful language. It can be used to process data and communicate with database and so on. The following functions are used to automatically download historical data of a list of stocks. The argument of the generateCMD function (stocklist) is a vector of stock symbols. The function can generate CMD command strings and store them into a CMD file and then execute the CMD file. To do this, you have to install “curl” on your windows system. You can download an appropriate lastest version of the CURL application from

toNumerics {
stopifnot(inherits(Date, c(“Date”, “POSIXt”)))
day month year list(year = year, month = month, day = day)

generateCMD {
cmdtext for (i in 1:length(stocklist))
stocksymbol # get today’s day, month, year information
today mydatecom day month year # download the data from the internet
cmdstr cmdtext }
cmdtext write(cmdtext, file=”dlcmd.cmd”)
system(“dlcmd.cmd”, wait=T)


Data Analysis of Field Experiments in Agriculture with R

I wrote a series of lectures about analyzing data from agricultural experiments with Minitab long time ago. Since then I learned using SAS and R to analyzing experimental data. In order to share my experiences in data management and analysis in the three software environments I started to put together data analysis, experimental design, and advanced data analysis in SAS, Minitab and R. Since the original series of lectures were written in Chinese, I will put all thing in Chinese first and then in English.


Tags: , , , , ,