# Category Archives: Data analysis

## Clustering in R

There is a nice post at https://stackoverflow.com/questions/15376075/cluster-analysis-in-r-determine-the-optimal-number-of-clusters that provide a number of examples to illustrate how to determine number of clusters. Below are two examples: # prepare data from a dataframe # var1 includes one group # var2 includes second group … Continue reading

## GET BLUE or BLUP from lmer in R

The following text is copied and pasted from https://stats.stackexchange.com/questions/122218/why-do-the-estimated-values-from-a-best-linear-unbiased-predictor-blup-differ. Q: Why do the estimated values from a Best Linear Unbiased Predictor (BLUP) differ from a Best Linear Unbiased Estimator (BLUE)? I understand that the difference between them is related to … Continue reading

## ggplot2 draw bar chart with error bars

Where I tried to generate a nice bar chart, I came across to the following post. It provides all the information I need. Very nice work! http://www.sthda.com/english/wiki/ggplot2-barplots-quick-start-guide-r-software-and-data-visualization R Graphics Cookbook also provides a lot of good examples. Some may be … Continue reading

## Dealing with Date in R language

In R there is a class called Date. If we want to get the components of a date variable or date string, we can use the following function to do it. toNumerics <- function(Date) { stopifnot(inherits(Date, c(“Date”, “POSIXt”))) day <- … Continue reading

## Search turning points in the trading history of a stock

Stock prices fluctuate everyday. It is impossible to pinpoint the bottom or peak of a stock. But by analyzing the trading history of a stock, we can figure a some unusual signals in the trading history of a stock. By … Continue reading