<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-12445049</id><updated>2012-01-14T10:31:41.272-08:00</updated><category term='clustering'/><category term='graphic'/><category term='data.frame extraction'/><category term='SOLiD'/><category term='Illumina'/><category term='data mining'/><category term='finance'/><category term='heatmap'/><category term='cluster'/><category term='heat calendar'/><category term='C'/><category term='k-mean'/><category term='SVG'/><category term='pretty-R'/><category term='dist'/><category term='scatterplot'/><category term='Mozaika'/><category term='normalization'/><category term='hclust'/><category term='partition clustering'/><category term='bioinformatics'/><category term='sed'/><category term='kmeans'/><category term='multiplex'/><category term='awk'/><category term='rev'/><category term='find'/><category term='smooth'/><category term='data visualization'/><category term='biology'/><category term='tee'/><category term='write.table'/><category term='grep'/><category term='DTW'/><category term='redirect'/><category term='photograph'/><category term='perl_command'/><category term='barcode'/><category term='linux'/><category term='Google Map API'/><category term='job_array'/><category term='meme'/><category term='histogram'/><category term='next-generation sequencing'/><category term='math'/><category term='Javascript'/><category term='ifelse'/><category term='barplot'/><category term='hierarchical clustering'/><category term='awk.system'/><category term='algorithm'/><category term='bash'/><category term='time series'/><category term='Mosaic'/><category term='text'/><category term='Aparche'/><category term='methylation'/><category term='HTS'/><category term='density curve'/><category term='sequencing'/><category term='bioC'/><category term='statistics'/><category term='machine learning'/><category term='egrep'/><category term='legend'/><category term='R'/><category term='dynamic time warping'/><title type='text'>One Tip Per Day</title><subtitle type='html'>Learning notes for Unix, Perl, R, HTML, Javascript, Google API and Bioinformatics</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>54</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-12445049.post-7879039913825878418</id><published>2012-01-05T08:12:00.000-08:00</published><updated>2012-01-05T08:12:17.808-08:00</updated><title type='text'>fgrep MAN Page</title><content type='html'>&lt;a href="http://ss64.com/bash/fgrep.html"&gt;fgrep MAN Page&lt;/a&gt;: "fgrep&lt;br /&gt;&lt;br /&gt;Search file(s) for lines that match a fixed string&lt;br /&gt;&lt;br /&gt;Syntax&lt;br /&gt;     fgrep  ...&lt;br /&gt;&lt;br /&gt;fgrep is the same as `grep -F'&lt;br /&gt;&lt;br /&gt;all other options are the same as grep&lt;br /&gt;It's a popular fallacy that fgrep stands for fast-grep, in fact fgrep means fixed-string grep.&lt;br /&gt;&lt;br /&gt;fgrep implements the Aho–Corasick string matching algorithm which is very fast at matching multiple strings in the input stream/file. So if fgrep is used like this:&lt;br /&gt;&lt;br /&gt;fgrep -f patternlist.txt largetextfile.txt&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span &gt;it is much faster than&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;grep -f patternlist.txt largetextfile.txt&lt;br /&gt;&lt;br /&gt;Matching a single pattern with fgrep is not significantly faster than grep.&lt;br /&gt;&lt;br /&gt;"The knowledge imposes a pattern, and falsifies, For the pattern is new in every moment..." - T. S. Eliot"&lt;br /&gt;&lt;br /&gt;&lt;a style="font-size:13px" href="https://chrome.google.com/webstore/detail/pengoopmcjnbflcjbmoeodbmoflcgjlk"&gt;'via Blog this'&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-7879039913825878418?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/7879039913825878418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=7879039913825878418' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/7879039913825878418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/7879039913825878418'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2012/01/fgrep-man-page.html' title='fgrep MAN Page'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-8933892666326018833</id><published>2011-11-16T08:13:00.001-08:00</published><updated>2011-11-16T08:16:01.896-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='write.table'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>an easy way to writing data.frame to Excel</title><content type='html'>&lt;br /&gt;&lt;div style="background-color: white;"&gt;you can write it as&lt;/div&gt;&lt;div style="background-color: white;"&gt;write.table(r.data.frame, "excel.file.xls", sep="\t", na="", row.names=F)&lt;/div&gt;&lt;div style="background-color: white;"&gt;which I can usually open in Excel just by clicking on it.&lt;/div&gt;&lt;div style="background-color: white;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="background-color: white;"&gt;Credit:&amp;nbsp;http://tolstoy.newcastle.edu.au/R/help/05/04/3388.html&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-8933892666326018833?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/8933892666326018833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=8933892666326018833' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/8933892666326018833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/8933892666326018833'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/11/easy-way-to-writing-dataframe-to-excel.html' title='an easy way to writing data.frame to Excel'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-5250733777691352036</id><published>2011-11-04T12:59:00.000-07:00</published><updated>2011-11-04T12:59:52.006-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>match vs. %in%</title><content type='html'>&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;match&lt;/span&gt;&lt;/b&gt; and &lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;%in%&lt;/span&gt;&lt;/b&gt; are two very commonly-used function in R. So, what's the difference of them?&lt;br /&gt;&lt;br /&gt;First, how to use them -- (copy from R manual)&lt;br /&gt;&lt;br /&gt;&lt;blockquote class="tr_bq"&gt;&lt;code&gt;match&lt;/code&gt;&amp;nbsp;returns a vector of the positions of (first) matches of its first argument in its second.&lt;br /&gt;&lt;code&gt;%in%&lt;/code&gt;&amp;nbsp;is a more intuitive interface as a binary operator, which returns a logical vector indicating if there is a match or not for its left operand.&amp;nbsp;&lt;/blockquote&gt;&lt;blockquote class="tr_bq"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;match(x, table, nomatch = NA_integer_, incomparables = NULL)&lt;/span&gt;x %in% table&lt;/blockquote&gt;&lt;div&gt;Examples:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;pre class="r geshifilter-R" style="background-color: #f8f8f8; color: #222222; font-size: 12px; line-height: 15px; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px; word-wrap: normal;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; a&lt;br /&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; b&lt;br /&gt; &lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;10&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;9&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;8&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;7&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;6&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/match" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;match&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;a&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;b&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;10&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;10&lt;/span&gt; &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;NA&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;10&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;6&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;10&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;9&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;7&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; a &lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;%in%&lt;/span&gt; b&lt;br /&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt;  &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;TRUE&lt;/span&gt;  &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;TRUE&lt;/span&gt; &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;FALSE&lt;/span&gt;  &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;TRUE&lt;/span&gt;  &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;TRUE&lt;/span&gt;  &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;TRUE&lt;/span&gt;  &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;TRUE&lt;/span&gt;  &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;TRUE&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, if two vectors are overlapped like&lt;/div&gt;&lt;div&gt;a ---------------&lt;/div&gt;&lt;div&gt;b &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -----------------------------&lt;/div&gt;&lt;div&gt;To get the overlapped part in order of a, use a[a %in% b], even though there are duplicates in the overlapped part. However, this does not work for match, since match() only returns the first match of a in b. For example,&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;pre class="r geshifilter-R" style="background-color: #f8f8f8; color: #222222; font-size: 12px; line-height: 15px; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px; word-wrap: normal;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/match" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;match&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;b&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;a&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt; &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;NA&lt;/span&gt; &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;NA&lt;/span&gt; &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;NA&lt;/span&gt; &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;NA&lt;/span&gt; &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;NA&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;8&lt;/span&gt; &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;NA&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;7&lt;/span&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/match" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;match&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;b&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;a&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; nomatch=&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;8&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;7&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; a&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/match" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;match&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;b&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;a&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; nomatch=&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;even using 'nomatch=0', the final command still returns 4 elements, not the overlapped ones.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-5250733777691352036?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/5250733777691352036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=5250733777691352036' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/5250733777691352036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/5250733777691352036'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/11/match-vs-in.html' title='match vs. %in%'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-1003354285839775954</id><published>2011-10-25T13:27:00.001-07:00</published><updated>2011-10-25T13:27:43.131-07:00</updated><title type='text'>用粤语数数</title><content type='html'>&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 小曦最近在中文学校教kindergarten的小朋友们中文。根据教材的设置，我们是从中文的数字开始学起的。学习一种新的语言，不是从吃喝拉撒衣住行这种最生活的东西开始，而是从数数开始，这确实让人说不出道理却又总习惯去做。我很小的时候就开始学习英语，老人见了我，问我英语学得怎么样，让我表演表演，我开口就是“汪，土，水，火……”。而到了挪威，想跟朋友学学挪威语，也是劈头就问人家怎么用挪威语数一到十。粤语也是一样，我看到很多人都说自己会一些粤语，让他们说说看的时候，他们就开始“呀，咦，三，噻……”。我自己也一样，认为把粤语里的一到十都说得很溜了，后来认真学习粤语拼音才发现，粤语的发音可是有玄机的。粤语不但声调比普通话多，而且还有很多带韵尾的字，而韵尾的概念是普通话里根本没有的。就拿数字一到十举例，除了“二”、“四”、“九”这三个字的发音跟普通话类似——也是“声母+韵母”的模式之外，其余几个都是很特别的。以下是我的一些心得，不一定完全准确。&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;“一”，拼作“jat1”，格式可以解读为声母“j”+韵母“a”+韵尾“t”，调号为“1”；因为有了韵尾t，所以收尾短促，并且以舌顶上齿、欲发“t”音但尚未发出的状态作结。因此，读“一”的时候，要短促而有力，而不是很多人读的“呀aaaaaa”；&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;“二”，拼作“ji6”，可以读得拖一些；&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;“三”，拼作“sam1”，收尾的时候要闭嘴，做出发“m”音的状态；&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;“四”，拼作“sei3”；&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;“五”，拼作“ng5”，这个音最有意思，因为发这个音的时候，嘴从始至终都没有张开过，而是从鼻子里哼出一个调子，类似于普通话里的“嗯”。粤语里常用“唔”取代“不”，这个“唔”也是和“五”类似的发音（拼作“ng4”）。比如“不用”在粤语里是“唔使”，我最喜欢和大黄说这个词，说的时候，就是鼻子里憋一口气先哼一声读出“唔”，再顺势张开嘴读出“使”；但大黄说的时候，就会说成“毛塞”，就是读“唔”的时候没有把嘴巴闭起来的原因。&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;“六”，拼作“luk6”，这个音带着韵尾“k”，和“一”一样，也是一个入声字。虽然“k”不真的发出来，但是已经有这个趋势了。如果这个字后面再跟上一个字一起读的话，有些时候就能听出韵尾“k”了。比如，英语“taxi”，粤语翻译成“的士”，这个音译就比普通话的音译“出租车”要更接近原来语言的发音，因为“的”（dik1），当它和“士”（si3）拼在一起的时候，就读作“diksi”，是可以听出“k”音的！&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;“七”，拼作“cat1”，参看“一”；&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;“八”，拼作“baat”，这个韵母“aa”比“a”的嘴型要大些，韵尾的读法同上；&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;“九”，拼作“gau”；&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;“十”，拼作“sap”，韵尾是“p”，收尾的时候又是要闭嘴的。我想起一部港片里，一个内地人甲跟香港人乙赔礼道歉后说了句，“这样的话，你接不接受啊？”结果那个香港人一听就火了，为什么呢？因为甲不懂韵尾，他把“接”按照普通话的习惯读成了“zi”，而不是“zip”！“zip sau”和“zi sau”，仅仅一“p”之差，前者是“接受”，后者听起来就像是“折寿”了。谁听了不生气！&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-1003354285839775954?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/1003354285839775954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=1003354285839775954' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1003354285839775954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1003354285839775954'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/10/blog-post_25.html' title='用粤语数数'/><author><name>小曦</name><uri>http://www.blogger.com/profile/02797103388947067641</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-6BAsm9zMhXU/TWHuXJNVLsI/AAAAAAAAAAM/x8KbsqBh6vw/s220/dddd.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-8799543562692827120</id><published>2011-10-24T12:46:00.000-07:00</published><updated>2011-10-24T12:46:58.367-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data visualization'/><title type='text'>Sites about info visualization</title><content type='html'>&amp;nbsp;It's not all, definitely. But these&amp;nbsp;are sites I found very interesting to read and helpful to learn:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;http://visualeconomics.creditloan.com/ (what I newly found today)&lt;/li&gt;&lt;li&gt;http://www.datavizchallenge.org/ &amp;nbsp;(a contest site for Vis)&lt;/li&gt;&lt;li&gt;http://vis.stanford.edu/ &amp;nbsp;(A pioneer group in this study)&lt;/li&gt;&lt;li&gt;http://mbostock.github.com/d3/ &amp;nbsp;(one of library from above group)&lt;/li&gt;&lt;li&gt;http://flowingdata.com/ &amp;nbsp;(Nathan's website)&lt;/li&gt;&lt;li&gt;http://www.google.com/publicdata/home &amp;nbsp;(Google Public Data)&lt;/li&gt;&lt;li&gt;http://www.gapminder.org/ &amp;nbsp;(where Prof. Rosling's original TED talk mentioned)&lt;/li&gt;&lt;li&gt;http://periscopic.com &amp;nbsp;(A company in this field)&lt;/li&gt;&lt;li&gt;adding...&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;let me know if you know any else.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-8799543562692827120?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/8799543562692827120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=8799543562692827120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/8799543562692827120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/8799543562692827120'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/10/sites-about-info-visualization.html' title='Sites about info visualization'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-7904945136193569712</id><published>2011-10-10T16:35:00.000-07:00</published><updated>2011-11-04T12:47:23.167-07:00</updated><title type='text'>如何把文字排版成异形</title><content type='html'>如何把一篇文字排版成喜欢的形状呢？PS的路径工具可以帮你！&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-UQ9OaAF2hcs/TpOEqRp1UJI/AAAAAAAAAG4/vpZcYiAX6gU/s1600/love.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="330" src="http://4.bp.blogspot.com/-UQ9OaAF2hcs/TpOEqRp1UJI/AAAAAAAAAG4/vpZcYiAX6gU/s400/love.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;a href="http://1.bp.blogspot.com/-zUeGlK368S0/TpOw4_xkVpI/AAAAAAAAAHA/5p_73laSdyw/s1600/since.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="640" src="http://1.bp.blogspot.com/-zUeGlK368S0/TpOw4_xkVpI/AAAAAAAAAHA/5p_73laSdyw/s640/since.png" width="96" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;是不是有点儿意思？其实做法很简单。以下是步骤：1、下载一个心形的图片；2、在ps里生成心形的路径（可以用路径铅笔手动勾勒出路径，也可以用魔术棒创建选区之后生成路径）；3、在生成的路径下使用文字工具T，写出预设的文字段落；4、调整字体类型、大小和颜色；搞定！&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;再做一个，这次用sin wave旋转之后来做，文字是最近喜欢的一首悲情林教头的歌——《自从你走后》&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-7904945136193569712?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/7904945136193569712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=7904945136193569712' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/7904945136193569712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/7904945136193569712'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/10/blog-post.html' title='如何把文字排版成异形'/><author><name>小曦</name><uri>http://www.blogger.com/profile/02797103388947067641</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-6BAsm9zMhXU/TWHuXJNVLsI/AAAAAAAAAAM/x8KbsqBh6vw/s220/dddd.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-UQ9OaAF2hcs/TpOEqRp1UJI/AAAAAAAAAG4/vpZcYiAX6gU/s72-c/love.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-718730240633091617</id><published>2011-10-10T12:03:00.000-07:00</published><updated>2011-10-10T12:04:21.171-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data.frame extraction'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>data frame extraction</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;This is a&amp;nbsp;trivial&amp;nbsp;but very useful tip:&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #f8f8f8; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px; white-space: pre;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace; font-size: 12px; line-height: 1.3; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px; white-space: pre; word-wrap: normal;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; x=&lt;a href="http://inside-r.org/r-doc/base/data.frame" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;data.frame&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;a=&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;:&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;c&lt;/span&gt;&lt;/a&gt;=&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; x&lt;br /&gt;  a &lt;a href="http://inside-r.org/r-doc/base/c" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; x&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;] &lt;/span&gt;&lt;br /&gt;  a &lt;a href="http://inside-r.org/r-doc/base/c" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; x&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; x&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/drop" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;drop&lt;/span&gt;&lt;/a&gt;=F&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt;&lt;br /&gt;  a&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4&lt;/span&gt;&lt;/pre&gt;where you can see that:&lt;br /&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;to avoid a[, i] become a vector, rather than a one-column data frame, we can use drop=F option.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Here is full&amp;nbsp;explanation&amp;nbsp;for that:&amp;nbsp;&lt;/div&gt;&lt;div&gt;http://stat.ethz.ch/R-manual/R-patched/library/base/html/Extract.data.frame.html&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-718730240633091617?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/718730240633091617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=718730240633091617' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/718730240633091617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/718730240633091617'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/10/data-frame-extraction.html' title='data frame extraction'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-130713389681837750</id><published>2011-10-10T11:07:00.000-07:00</published><updated>2011-10-10T15:34:30.175-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='heatmap'/><category scheme='http://www.blogger.com/atom/ns#' term='clustering'/><category scheme='http://www.blogger.com/atom/ns#' term='partition clustering'/><category scheme='http://www.blogger.com/atom/ns#' term='hierarchical clustering'/><category scheme='http://www.blogger.com/atom/ns#' term='dist'/><category scheme='http://www.blogger.com/atom/ns#' term='k-mean'/><category scheme='http://www.blogger.com/atom/ns#' term='hclust'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><category scheme='http://www.blogger.com/atom/ns#' term='kmeans'/><title type='text'>k-mean clustering + heatmap</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;Several R functions in this topic:&lt;br /&gt;&lt;br /&gt;1.&amp;nbsp;&lt;b&gt;dist&lt;/b&gt;(X) &amp;nbsp;-- calculate the distance of rows of data matrix X. The default distance method is euclidean. It can be maximal, manhattan, binary etc.&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #f8f8f8; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px; white-space: pre;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace; font-size: 12px; line-height: 1.3; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px; white-space: pre; word-wrap: normal;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; a=&lt;a href="http://inside-r.org/r-doc/base/matrix" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;matrix&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/sample" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;sample&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;9&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/nrow" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;nrow&lt;/span&gt;&lt;/a&gt;=&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; a&lt;br /&gt;     &lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt; &lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt; &lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt;    &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;5&lt;/span&gt;    &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;    &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;9&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt;    &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;8&lt;/span&gt;    &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;7&lt;/span&gt;    &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt;    &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;6&lt;/span&gt;    &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4&lt;/span&gt;    &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/stats/dist" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;dist&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;a&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/diag" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;diag&lt;/span&gt;&lt;/a&gt;=T&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; method=&lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;'max'&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt;    &lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;8&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt;  &lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;6&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;gt;&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/stats/dist" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;dist&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;a&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/diag" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;diag&lt;/span&gt;&lt;/a&gt;=T&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; method=&lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;'euc'&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;         &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;        &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;        &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0.000000&lt;/span&gt;                  &lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;9.899495&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0.000000&lt;/span&gt;         &lt;br /&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;3&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;6.403124&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;4.123106&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0.000000&lt;/span&gt;&lt;/pre&gt;&lt;div&gt;2.&amp;nbsp;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;b&gt;hclust&lt;/b&gt;(D) &amp;nbsp;-- hierarchical clustering of a distance/dissimilarity matrix (e.g output of dist function): join two most similar objects (based on similarity method)&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;each time&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;until there is one single cluster.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;hclust(D) can be displayed in a tree format, using plot(hclust(D)), or plclust(hclust(D))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;3.&amp;nbsp;&lt;b&gt;heat&lt;/b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;b&gt;map&lt;/b&gt;(X,&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;distfun = dist, hclustfun = hclust, ...) -- display matrix of X and cluster rows/columns by distance and clustering method. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="background-color: white; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="background-color: white; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;One enhanced version is &lt;a href="http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/gplots/html/heatmap.2.html"&gt;heatmap.2&lt;/a&gt;, which has more functions. For example&lt;/span&gt;&lt;/span&gt;, you can use&lt;/div&gt;&lt;div&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;key, symkey etc. for legend,&amp;nbsp;&lt;/li&gt;&lt;li&gt;"col=heat.colors(16)" or "col='greenred', breaks=16" to specify colors of image&lt;/li&gt;&lt;li&gt;cellnote (text matrix with same dim), notecex, notecol for text in grid&lt;/li&gt;&lt;li&gt;colsep/rowsep to define blocks of separation, e.g. colsep=c(1,3,6,8) will display a white separator at columns of 1, 3, 6, 8 etc.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Both have '&lt;span class="Apple-style-span" style="background-color: #eeeeee; color: #102040; font-family: monospace; font-size: 15px; line-height: 20px;"&gt;ColSideColors/RowSideColors&lt;/span&gt;', a color vector with length of cols/rows. Here is an example(http://chromium.liacs.nl/R_users/20060207/Renee_graphs_and_others.pdf).&lt;br /&gt;&lt;br /&gt;Another enhanced version is &lt;a href="http://www.oga-lab.net/RGM2/func.php?rd_id=pheatmap:pheatmap"&gt;pheatmap&lt;/a&gt;, which produced pretty heatmap with additional options:&lt;br /&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;cellwidth/cellheight to set the size of cell&lt;/li&gt;&lt;li&gt;treeheight_row/treeheight_col: height of tree&lt;/li&gt;&lt;li&gt;annotation: a data.frame, each column is an annotation of columns of X. So, nrow(annotation)==ncol(X)&amp;nbsp;&lt;/li&gt;&lt;li&gt;legend/annotation_legend: whether to show legend&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="background-color: #f9f9f9; line-height: 16px;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;filename: save to file&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;4.&amp;nbsp;&lt;b&gt;kmeans&lt;/b&gt;(X, centers=k) -- partition points (actually rows of X matrix) into k clusters . For example:&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #f8f8f8; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px; white-space: pre;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace; font-size: 12px; line-height: 1.3; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px; white-space: pre; word-wrap: normal;"&gt;&lt;span style="color: #666666; font-style: italic; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;# a 2-dimensional example&lt;/span&gt;&lt;br /&gt;x &lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/rbind" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;rbind&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/matrix" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;matrix&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/stats/rnorm" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;rnorm&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;100&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/stats/sd" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;sd&lt;/span&gt;&lt;/a&gt; = &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0.3&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/ncol" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;ncol&lt;/span&gt;&lt;/a&gt; = &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/base/matrix" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;matrix&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/stats/rnorm" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;rnorm&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;100&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/mean" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;mean&lt;/span&gt;&lt;/a&gt; = &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/stats/sd" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;sd&lt;/span&gt;&lt;/a&gt; = &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;0.3&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/ncol" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;ncol&lt;/span&gt;&lt;/a&gt; = &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/base/colnames" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;colnames&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;x&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt; &lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;"x"&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;"y"&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;cl &lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/stats/kmeans" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;kmeans&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;x&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/graphics/plot" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;plot&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;x&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/col" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;col&lt;/span&gt;&lt;/a&gt; = cl&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;$&lt;/span&gt;cluster&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/graphics/points" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;points&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;cl&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;$&lt;/span&gt;centers&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/col" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;col&lt;/span&gt;&lt;/a&gt; = &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;:&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; pch = &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;8&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; cex=&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;The number of cluster can be determined by plot of sum of squares, eg.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="background-color: #f8f8f8; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px; white-space: pre;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace; font-size: 12px; line-height: 1.3; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px; white-space: pre; word-wrap: normal;"&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span style="color: #666666; font-style: italic; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;# Determine number of clusters&lt;/span&gt;&lt;br /&gt;wss &lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;lt;-&lt;/span&gt; &lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/nrow" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;nrow&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;x&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;-&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;*&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/sum" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;sum&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/apply" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;apply&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;x&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/stats/var" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;var&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;for&lt;/span&gt; &lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;i &lt;span style="color: black; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;in&lt;/span&gt; &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;:&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;20&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt; wss&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;[&lt;/span&gt;i&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;]&lt;/span&gt; &lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/sum" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;sum&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/stats/kmeans" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;kmeans&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;x&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;centers=i&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;$&lt;/span&gt;withinss&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/graphics/plot" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;plot&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;1&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;:&lt;/span&gt;&lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;20&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; wss&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; type=&lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;"b"&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; xlab=&lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;"Number of Clusters"&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt;ylab=&lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;"Within groups sum of squares"&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Using hclust and cutree can also set the number of clusters:&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #f8f8f8; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 15px; white-space: pre;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace; font-size: 12px; line-height: 1.3; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px; white-space: pre; word-wrap: normal;"&gt;hc &lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/stats/hclust" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;hclust&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/stats/dist" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;dist&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;x&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; &lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;"ward"&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/graphics/plot" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;plot&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;hc&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt; &lt;span style="color: #666666; font-style: italic; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;# the plot can also help to decide the # of clusters&lt;/span&gt;&lt;br /&gt;memb &lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/stats/cutree" style="color: #0077df; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;&lt;span style="color: #003399; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;cutree&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;(&lt;/span&gt;hc&lt;span style="color: #339933; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;,&lt;/span&gt; k = &lt;span style="color: #cc66cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;2&lt;/span&gt;&lt;span style="color: #009900; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Note: kmean is using partition method to cluster, while hclust is to use hierarchical clustering method. Here is &lt;a href="http://alumni.media.mit.edu/~tpminka/courses/36-350.2001/lectures/day37/"&gt;a series of nice lectures&lt;/a&gt; for this. A more detail for cluster can be found here:&amp;nbsp;&lt;span class="Apple-style-span" style="background-color: white; color: #666666; font-family: monospace; font-size: medium; font-weight: bold;"&gt;&lt;a href="http://cran.cnr.berkeley.edu/web/views/Cluster.html"&gt;CRAN Task View: Cluster Analysis&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-130713389681837750?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/130713389681837750/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=130713389681837750' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/130713389681837750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/130713389681837750'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/10/k-mean-clustering-heatmap.html' title='k-mean clustering + heatmap'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-4828524536450250690</id><published>2011-09-27T13:43:00.000-07:00</published><updated>2011-09-27T13:43:48.031-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='biology'/><category scheme='http://www.blogger.com/atom/ns#' term='methylation'/><title type='text'>about methylation （甲基化）</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://upload.wikimedia.org/wikipedia/commons/thumb/2/20/Methyl_group.png/220px-Methyl_group.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="80" src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/20/Methyl_group.png/220px-Methyl_group.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;'Methylation' has been more and more widely used in the field of gene regulation. Here is what I cracked:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;a href="http://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/5-Methylcytosine.svg/200px-5-Methylcytosine.svg.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/5-Methylcytosine.svg/200px-5-Methylcytosine.svg.png" /&gt;&lt;/a&gt;&lt;li&gt;Methylation means addition of a methy- group to a subtract (see the right figure).&lt;/li&gt;&lt;li&gt;Methylation can mean DNA methylation or protein methylation.&amp;nbsp;&lt;/li&gt;&lt;li&gt;DNA methylation occurs in a CpG (C followed by G) site in DNA sequences, where cytosine (C) becomes 5-methylcytosine (see right figure, counting counterclockwise from the NH).&lt;/li&gt;&lt;li&gt;About 80-90% of CpG sites in human DNA are methylated.&lt;/li&gt;&lt;li&gt;Most CpG islands (i.e. CG% &amp;gt;65%) are un-methylated.&lt;/li&gt;&lt;li&gt;Around 56% of mammalian genes has (un-methylated) CpG island in their promoter, like most housekeeping genes.&lt;/li&gt;&lt;li&gt;In normal tissue, methylation of a gene is mainly localized to the&amp;nbsp;coding region, which is CpG-poor. In contrast, the promoter region of the gene is unmethylated, despite a high density of CpG islands in the region.&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="background-color: #fffee8; line-height: 15px;"&gt;Methyl-seq is a technique combining&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: #fffee8; line-height: 15px;"&gt;DNA digestion by a methyl-sensitive enzyme HpaII and its methyl-insensitive isoschizomer MspI with the Illumina DNA sequencing platform. &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: #fffee8; line-height: 15px;"&gt;Sequence tags present in MspI libraries but not in HpaII libraries are derived from methylated regions. Conversely, sequence tags that occur in HpaII libraries come from at least partially unmethylated regions.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;HpaII only digests 5'-CCGG-3' sites when the cytosine in the central CG dinucleotide is unmethylated, so the HpaII representation is enriched for the hypomethylated fraction of the genome.&amp;nbsp;The MspI representation is a control for copy number changes and PCR amplification difficulties. Refer to &lt;a href="http://en.wikipedia.org/wiki/HELP_assay"&gt;HELP assay&lt;/a&gt; wiki page.&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="background-color: #fffee8; line-height: 15px;"&gt;Reduced Representation Bisulfite Sequencing (RRBS) is another method for DNA methylation. It has base-pair resolution. More detail can be refer her:&amp;nbsp;http://genome-test.cse.ucsc.edu/cgi-bin/hgc?hgsid=3051149&amp;amp;o=181430182&amp;amp;t=181430183&amp;amp;g=wgEncodeHaibMethylRrbsK562HaibSitesRep1&amp;amp;i=K562_Rep3_RRBS&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-4828524536450250690?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/4828524536450250690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=4828524536450250690' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4828524536450250690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4828524536450250690'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/09/about-methylation.html' title='about methylation （甲基化）'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-4108657099614851039</id><published>2011-09-18T17:34:00.000-07:00</published><updated>2011-09-19T07:15:32.807-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dynamic time warping'/><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='time series'/><category scheme='http://www.blogger.com/atom/ns#' term='data mining'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='DTW'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>DTW: dynamic time warping 动态时间规整</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;Basically, DTW (dynamic time warping) is an algorithm to output&amp;nbsp;cumulative&amp;nbsp;distance of two time sequences,&amp;nbsp;&lt;/span&gt;which is widely used e.g. for classification and clustering.&lt;br /&gt;&lt;br /&gt;For example, when using k-mean for clustering, we can use DTW as distance function. Here is one of such nice instances (using R:&lt;a href="http://www.rdatamining.com/examples/ts-mining"&gt; http://www.rdatamining.com/examples/ts-mining&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;Relevant&amp;nbsp;information from Anshul's email. &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;blockquote style="font-family: arial, sans-serif; font-size: 13px;" type="cite"&gt;&lt;div&gt;A review of DTW&amp;nbsp;&lt;a href="http://csdl.ics.hawaii.edu/techreports/08-04/08-04.pdf" style="color: #0000cc;" target="_blank"&gt;http://csdl.ics.hawaii.&lt;wbr&gt;&lt;/wbr&gt;edu/techreports/08-04/08-04.&lt;wbr&gt;&lt;/wbr&gt;pdf&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Python code:&amp;nbsp;&lt;a href="https://mlpy.fbk.eu/" style="color: #0000cc;" target="_blank"&gt;https://mlpy.fbk.eu/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;R code:&amp;nbsp;&lt;a href="http://dtw.r-forge.r-project.org/" style="color: #0000cc;" target="_blank"&gt;http://dtw.r-forge.r-&lt;wbr&gt;&lt;/wbr&gt;project.org/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;JAVA code:&amp;nbsp;&lt;a href="http://java-ml.sourceforge.net/" style="color: #0000cc;" target="_blank"&gt;http://java-ml.&lt;wbr&gt;&lt;/wbr&gt;sourceforge.net/&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href="http://code.google.com/p/fastdtw/" style="color: #0000cc;" target="_blank"&gt;http://&lt;wbr&gt;&lt;/wbr&gt;code.google.com/p/fastdtw/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;MATLAB: the samplealign() function in the bioinformatics toolbox does DTW&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There is also the global alignment kernel that is faster and more accurate that DTW. It can be used to compute distance between time series to be used in clustering allowing for all possible global alignments. Here is code&amp;nbsp;&lt;a href="http://www.iip.ist.i.kyoto-u.ac.jp/member/cuturi/GA.html" style="color: #0000cc;" target="_blank"&gt;http://www.iip.ist.i.&lt;wbr&gt;&lt;/wbr&gt;kyoto-u.ac.jp/member/cuturi/&lt;wbr&gt;&lt;/wbr&gt;GA.html&lt;/a&gt;&lt;/div&gt;&lt;/blockquote&gt;Here is an example (in Chinese) from &lt;a href="http://blog.csdn.net/kingskyleader/article/details/6244011"&gt;Ckary's&lt;/a&gt; blog:&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: Arial; line-height: 26px;"&gt;&lt;span style="background-color: white; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;在日常的生活中我们最经常使用的距离毫无疑问应该是欧式距离，但是对于一些特殊情况，欧氏距离存在着其很明显的缺陷，比如说时间序列，举个比较简单的例子，序列A：1,1,1,10,2,3，序列B：1,1,1,2,10,3，如果用欧氏距离，也就是distance[i][j]=(b[j]-a[i])*(b[j]-a[i])来计算的话，总的距离和应该是128，应该说这个距离是非常大的，而实际上这个序列的图像是十分相似的，这种情况下就有人开始考虑寻找新的时间序列距离的计算方法，然后提出了DTW算法，这种方法在语音识别，机器学习方便有着很重要的作用。&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;u style="background-color: yellow;"&gt;这个算法是基于动态规划（DP）的思想，解决了发音长短不一的模板匹配问题，简单来说，就是通过构建一个邻接矩阵，寻找最短路径和。&lt;/u&gt;&lt;/span&gt;&lt;span style="background-color: white; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;还以上面的2个序列作为例子，A中的10和B中的2对应以及A中的2和B中的10对应的时候，distance[3]以及distance[4]肯定是非常大的，这就直接导致了最后距离和的膨胀，这种时候，我们需要来调整下时间序列，如果我们让A中的10和B中的10&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;对应&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;，A中的1和B中的2对应，那么最后的距离和就将大大缩短，这种方式可以看做是一种时间扭曲，看到这里的时候，我相信应该会有人提出来，为什么不能使用A中的2与B中的2对应的问题，那样的话距离和肯定是0了啊，距离应该是最小的吧，但这种情况是不允许的，因为A中的10是发生在2的前面，而B中的2则发生在10的前面，如果对应方式交叉的话会导致时间上的混乱，不符合因果关系。&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Arial; line-height: 26px;"&gt;接下来，以output[6][6](所有的记录下标从1开始，开始的时候全部置0)记录A，B之间的DTW距离，简单的介绍一下具体的算法，这个算法其实就是一个简单的DP，状态转移公式是output[i][j]=Min(Min(output[i-1][j],output[i][j-1]),output[i-1][j-1])+distance[i][j];最后得到的output[5][5]就是我们所需要的DTW距离.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;span class="Apple-style-span" style="font-family: Arial; line-height: 26px;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif;"&gt;&amp;nbsp;The C code there is also much helpful in understanding the algorithm.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-4108657099614851039?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/4108657099614851039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=4108657099614851039' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4108657099614851039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4108657099614851039'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/09/dtw-dynamic-time-warping.html' title='DTW: dynamic time warping 动态时间规整'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-7905400025607739983</id><published>2011-09-17T19:42:00.000-07:00</published><updated>2011-09-17T19:44:18.729-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mozaika'/><category scheme='http://www.blogger.com/atom/ns#' term='photograph'/><category scheme='http://www.blogger.com/atom/ns#' term='Mosaic'/><title type='text'>Mozaika: a nice tool to make mosaic</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;If you want to make a photographic mosaic, Mazaika would be one of the solutions (at least from what I knew). Here is the website for Mac version: http://www.mazaika.com/mac/&lt;br /&gt;&lt;br /&gt;Here is what I tested on a profile photo I took when travelling in Daocheng.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-BrRgEwn20g0/TnVZkxlLsCI/AAAAAAAAABA/CRPreOoKop4/s1600/daocheng.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="200" src="http://3.bp.blogspot.com/-BrRgEwn20g0/TnVZkxlLsCI/AAAAAAAAABA/CRPreOoKop4/s200/daocheng.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;(click to see the bigger photo)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-7905400025607739983?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/7905400025607739983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=7905400025607739983' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/7905400025607739983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/7905400025607739983'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/09/mozaika-nice-tool-to-make-mosaic.html' title='Mozaika: a nice tool to make mosaic'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-BrRgEwn20g0/TnVZkxlLsCI/AAAAAAAAABA/CRPreOoKop4/s72-c/daocheng.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-9057235607095819897</id><published>2011-09-16T14:50:00.000-07:00</published><updated>2011-09-20T07:35:29.283-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ifelse'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>ifelse function in R only returns the first element</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;If you also favor to use the function, be aware of the returned value. For example:&lt;br /&gt;&lt;br /&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&amp;gt; &lt;a href="http://inside-r.org/r-doc/base/ifelse"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;ifelse&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&amp;gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt; &lt;br /&gt;&lt;span style="color: #009900;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #009900;"&gt;]&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;br /&gt;&amp;gt; &lt;a href="http://inside-r.org/r-doc/base/ifelse"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;ifelse&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&amp;gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;3&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;5&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;   &lt;span style="color: #666666; font-style: italic;"&gt;# only the first element returned.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #009900;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #009900;"&gt;]&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;2&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;gt; &lt;a href="http://inside-r.org/r-doc/base/ifelse"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;ifelse&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/c"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;c&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;:&lt;span style="color: #cc66cc;"&gt;10&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&amp;gt;&lt;span style="color: #cc66cc;"&gt;5&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;'on'&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;'off'&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #009900;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #009900;"&gt;]&lt;/span&gt; &lt;span style="color: blue;"&gt;"off"&lt;/span&gt; &lt;span style="color: blue;"&gt;"off"&lt;/span&gt; &lt;span style="color: blue;"&gt;"off"&lt;/span&gt; &lt;span style="color: blue;"&gt;"off"&lt;/span&gt; &lt;span style="color: blue;"&gt;"off"&lt;/span&gt; &lt;span style="color: blue;"&gt;"on"&lt;/span&gt;  &lt;span style="color: blue;"&gt;"on"&lt;/span&gt;  &lt;span style="color: blue;"&gt;"on"&lt;/span&gt;  &lt;span style="color: blue;"&gt;"on"&lt;/span&gt;  &lt;span style="color: blue;"&gt;"on"&lt;/span&gt; &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Here is another nice example (from&amp;nbsp;http://rwiki.sciviews.org/doku.php?id=tips:programming:ifelse)&lt;br /&gt;&lt;br /&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&amp;gt; varD &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/log"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;log&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;:&lt;span style="color: #cc66cc;"&gt;9&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;  &lt;span style="color: #666666; font-style: italic;"&gt;# A vector like this one that contains -Inf could be troublesome in subsequent manipulations&lt;/span&gt;&lt;br /&gt;&amp;gt; varD&lt;br /&gt; &lt;span style="color: #009900;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #009900;"&gt;]&lt;/span&gt;      -&lt;span style="color: black; font-weight: bold;"&gt;Inf&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0.0000000&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0.6931472&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1.0986123&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1.3862944&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1.6094379&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1.7917595&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #009900;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;8&lt;/span&gt;&lt;span style="color: #009900;"&gt;]&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1.9459101&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;2.0794415&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;2.1972246&lt;/span&gt;&lt;br /&gt;&amp;gt; varD &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/ifelse"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;ifelse&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/is.finite"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;is.finite&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;varD&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; varD&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;   &lt;span style="color: #666666; font-style: italic;"&gt;# Remove the -Inf, replace with NA&lt;/span&gt;&lt;br /&gt;&amp;gt; varD&lt;br /&gt; &lt;span style="color: #009900;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #009900;"&gt;]&lt;/span&gt;        &lt;span style="color: black; font-weight: bold;"&gt;NA&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0.0000000&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0.6931472&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1.0986123&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1.3862944&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1.6094379&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1.7917595&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #009900;"&gt;[&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;8&lt;/span&gt;&lt;span style="color: #009900;"&gt;]&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1.9459101&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;2.0794415&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;2.1972246&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-9057235607095819897?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/9057235607095819897/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=9057235607095819897' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/9057235607095819897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/9057235607095819897'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/09/ifelse-function-in-r-only-returns-first.html' title='ifelse function in R only returns the first element'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-8061627971186228036</id><published>2011-09-16T13:17:00.000-07:00</published><updated>2011-09-16T13:17:41.924-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='normalization'/><title type='text'>normalization, normalization, normalization!</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: 'Lucida Grande', Verdana, Lucida, Helvetica, Arial, sans-serif; font-size: 12px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="line-height: 1.5em; margin-bottom: 1em; margin-left: 0em; margin-right: 0em; margin-top: 0.5em;"&gt;&lt;b&gt;Basic Microarray Analysis:&lt;/b&gt;&lt;/div&gt;&lt;ol style="line-height: 1.5em; margin-bottom: 0px; margin-left: 1.5em; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" type="1"&gt;&lt;li style="margin-bottom: 1em;"&gt;&lt;b&gt;Experiment (Raw Data)&lt;/b&gt;&lt;/li&gt;&lt;li style="margin-bottom: 1em;"&gt;&lt;b&gt;Image Analysis (Pick Spots)&lt;/b&gt;&lt;/li&gt;&lt;li style="margin-bottom: 1em;"&gt;&lt;b&gt;Pre-normalization analysis&lt;/b&gt;&lt;ol style="line-height: 1.5em; margin-bottom: 0px; margin-left: 1.5em; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" type="a"&gt;&lt;li style="margin-bottom: 1em;"&gt;Background subtraction&lt;/li&gt;&lt;li style="margin-bottom: 1em;"&gt;Spatial intensity&lt;/li&gt;&lt;li style="margin-bottom: 1em;"&gt;Chip to Chip variance&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li style="margin-bottom: 1em;"&gt;&lt;b&gt;Normalization and Filtering&lt;/b&gt;&lt;ol style="line-height: 1.5em; margin-bottom: 0px; margin-left: 1.5em; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" type="a"&gt;&lt;li style="margin-bottom: 1em;"&gt;Scale normalization&lt;/li&gt;&lt;li style="margin-bottom: 1em;"&gt;Intensity dependent location normalization&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li style="margin-bottom: 1em;"&gt;&lt;b&gt;Post-normalization analysis&lt;/b&gt;&lt;/li&gt;&lt;ol style="line-height: 1.5em; margin-bottom: 0px; margin-left: 1.5em; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" type="a"&gt;&lt;li style="margin-bottom: 1em;"&gt;Clustering&lt;/li&gt;&lt;li style="margin-bottom: 1em;"&gt;Hypothesis testing&lt;/li&gt;&lt;li style="margin-bottom: 1em;"&gt;Classification&lt;/li&gt;&lt;li style="margin-bottom: 1em;"&gt;More complicated statistical analysis&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;I found this list when I was searching the &lt;a href="http://en.wikipedia.org/wiki/Interquartile_range"&gt;interquartile range&lt;/a&gt; (IQR) normalization. Actually Microarray folks might have been done the whole bunch of analysis decades ago. But the question for me is still there: how to compare two samples?&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;Let's say, I have two vectors: X=[x1, x2, x3, ..., xn] and Y=[y1, y2, y3, ... yn]. Before I could say X is correlated with Y simply because cor(X, Y) is large, I should make sure that each Xi and Yi are sampled from the same distribution. Right? That's the point. If they are not, I should do normalization ahead to assure that.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;Maybe I should go thru the above list (esp. the normalization part) in some weekend.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-8061627971186228036?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/8061627971186228036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=8061627971186228036' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/8061627971186228036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/8061627971186228036'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/09/normalization-normalization.html' title='normalization, normalization, normalization!'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-2704535160615392120</id><published>2011-09-16T09:39:00.000-07:00</published><updated>2011-09-16T09:39:56.141-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='next-generation sequencing'/><category scheme='http://www.blogger.com/atom/ns#' term='HTS'/><title type='text'>Human Body Map, seq/chip</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span class="s1"&gt;Sequencing &lt;/span&gt;assays provide &lt;span class="s1"&gt;digital &lt;/span&gt;measures of sequence&lt;br /&gt;abundance, i.e., &lt;span class="s1"&gt;read counts&lt;/span&gt;. In contrast, &lt;span class="s1"&gt;microarrays &lt;/span&gt;provide&lt;br /&gt;&lt;span class="s1"&gt;analog &lt;/span&gt;measures of sequence abundance, i.e.,&amp;nbsp;intensities&lt;span class="s2"&gt;.&lt;/span&gt;&lt;/blockquote&gt;&lt;div class="p2"&gt;&lt;span class="s2"&gt;I read this in&amp;nbsp;&lt;/span&gt;Sandrine Dudoit's &lt;a href="http://www.stat.berkeley.edu/users/sandrine/presentations.html"&gt;presentation&lt;/a&gt;. Quite agree!&lt;/div&gt;&lt;div class="p2"&gt;-------&lt;/div&gt;&lt;div class="p2"&gt;Another piece of note for today might be old new, but still useful. -- Ensembl v62 has embeded all "Human Body Map 2.0" RNAseq data. Here is a nice blog for that.&amp;nbsp;&lt;/div&gt;&lt;div class="p2"&gt;http://www.ensembl.info/blog/2011/05/24/human-bodymap-2-0-data-from-illumina/&lt;/div&gt;&lt;div class="p2"&gt;&lt;span class="s2"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-2704535160615392120?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/2704535160615392120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=2704535160615392120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/2704535160615392120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/2704535160615392120'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/09/human-body-map-seqchip.html' title='Human Body Map, seq/chip'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-1476479794984208082</id><published>2011-09-11T21:41:00.000-07:00</published><updated>2011-09-16T09:55:14.174-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sequencing'/><category scheme='http://www.blogger.com/atom/ns#' term='barcode'/><category scheme='http://www.blogger.com/atom/ns#' term='SOLiD'/><category scheme='http://www.blogger.com/atom/ns#' term='Illumina'/><category scheme='http://www.blogger.com/atom/ns#' term='multiplex'/><title type='text'>about high-throughput sequencing</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;b&gt;multiplexing&lt;/b&gt;: This term refers to the ability of sequencing multiple samples at the same time. For example, for small genome like yeast, C.elegant and drosophila, the number of reads generated in a sequencing unit (e.g. one of the 8 lanes in Illumina Genome Analyzer) may be several times of reads needed to provide a sufficient coverage of the genome.&lt;br /&gt;&lt;b&gt;barcode/index&lt;/b&gt;:&amp;nbsp;To distinguish the different samples in same run/lane, a short sequence, call barcode/index, is added to the front of adaptor ligated together to different samples during sample preparation. "&lt;span class="Apple-style-span" style="color: indigo; font-family: Arial; font-size: 14px;"&gt;This is generally added to the 3' end of the upstream adapter so that this is the first 4-6 bases read during the sequencing run, then you sort the data by these first bases into your groups.&amp;nbsp;&lt;/span&gt;"(http://www.umassmed.edu/DeepSeq_FAQ.aspx).&lt;br /&gt;&lt;br /&gt;Here is the barcoding system for SOLiD:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.invitrogen.com/etc/medialib/en/images/ics_organized/applications/nucleic_acid_amplification/data_image/560_wide.Par.18698.Image.560.92.1..gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://www.invitrogen.com/etc/medialib/en/images/ics_organized/applications/nucleic_acid_amplification/data_image/560_wide.Par.18698.Image.560.92.1..gif" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;For Illumina, see the slides in presentation:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://privatewww.essex.ac.uk/~mastal/images/GA_workflow.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="608" src="http://privatewww.essex.ac.uk/~mastal/images/GA_workflow.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;https://www.illumina.com/documents/seminars/presentations/2010-06_sq_21_morris_multiplex_target_enrichment.pdf&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-F-TGxAmFtco/Tm2ScRQv5vI/AAAAAAAAAA0/1lpXg7jVetY/s1600/Screen+shot+2011-09-12+at+1.02.15+AM+1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-F-TGxAmFtco/Tm2ScRQv5vI/AAAAAAAAAA0/1lpXg7jVetY/s1600/Screen+shot+2011-09-12+at+1.02.15+AM+1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-6FYGve03GSA/Tm2SfvuBPjI/AAAAAAAAAA4/ZPPCt0jJvBw/s1600/Screen+shot+2011-09-12+at+1.02.24+AM.png" /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Two related papers:&amp;nbsp;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;http://www.nature.com/nrg/journal/v10/n10/abs/nrg2641.html&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;http://www.nature.com/nmeth/journal/v5/n10/full/nmeth.1251.html&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-1476479794984208082?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/1476479794984208082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=1476479794984208082' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1476479794984208082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1476479794984208082'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/09/about-high-throughput-sequencing.html' title='about high-throughput sequencing'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-F-TGxAmFtco/Tm2ScRQv5vI/AAAAAAAAAA0/1lpXg7jVetY/s72-c/Screen+shot+2011-09-12+at+1.02.15+AM+1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-3597849211255080627</id><published>2011-09-07T20:40:00.000-07:00</published><updated>2011-09-07T20:41:20.386-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='statistics'/><title type='text'>Several basic statistics terms</title><content type='html'>&lt;b&gt;Deviation&lt;/b&gt;: difference between observation and mean of the population, e.g Xi-E(X)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Residual&lt;/b&gt;: the difference between observed value and predicted/estimated value.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Error&lt;/b&gt;: the difference btw the observed value and the real value (which is usually unobservable)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;MSE&lt;/b&gt; (Mean square error): the E[(X-X')^2], where X' is the real value of X.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Standard deviation&lt;/b&gt;: square root of the mean squared deviation. eg. sqrt(E[(Xi-u)^2]). It's square root of variance (see below)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Variance&lt;/b&gt;: a measurement of the dispersion for a set of numbers/observations (e.g. how far they are spread out from each other). If they have a mean, then variance is defined as E[(Xi-u)^2], where u is E(X). It's square of standard deviation.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-3597849211255080627?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/3597849211255080627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=3597849211255080627' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3597849211255080627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3597849211255080627'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/09/several-basic-statistics-terms.html' title='Several basic statistics terms'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-2244278023805637554</id><published>2011-09-01T20:23:00.000-07:00</published><updated>2011-09-02T10:02:34.256-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='histogram'/><category scheme='http://www.blogger.com/atom/ns#' term='smooth'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><category scheme='http://www.blogger.com/atom/ns#' term='density curve'/><title type='text'>Density curve of histogram plot in R</title><content type='html'>&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://casoilresource.lawr.ucdavis.edu/drupal/files/images/4_region_slope_classes_0.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="451" src="http://casoilresource.lawr.ucdavis.edu/drupal/files/images/4_region_slope_classes_0.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;Ref: http://casoilresource.lawr.ucdavis.edu/drupal/book/export/html/23&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;To add density curve on a histogram, like the green curve above, use code below:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#plot the distribution&lt;br /&gt;hist(slope, breaks=1000, freq=F, main=main, xlab="Slope Value (percent)", xlim=c(0,150), ylim=c(0,.05) )&lt;br /&gt;lines(density(slope, bw=1), col="green")&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-2244278023805637554?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/2244278023805637554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=2244278023805637554' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/2244278023805637554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/2244278023805637554'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/09/density-curve-of-histogram-plot-in-r.html' title='Density curve of histogram plot in R'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-6485521207912167540</id><published>2011-09-01T12:45:00.000-07:00</published><updated>2011-09-01T20:28:09.947-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scatterplot'/><category scheme='http://www.blogger.com/atom/ns#' term='text'/><category scheme='http://www.blogger.com/atom/ns#' term='legend'/><category scheme='http://www.blogger.com/atom/ns#' term='barplot'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>Add text aligned to legend in R plot</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://zlab.umassmed.edu/~dongx/encode2011Aug3_classifier/figures/png/TSS-based.CAGE.PolyA+.K562.Cytosol.all.bestbin.lm.40.0.10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://zlab.umassmed.edu/~dongx/encode2011Aug3_classifier/figures/png/TSS-based.CAGE.PolyA+.K562.Cytosol.all.bestbin.lm.40.0.10.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;What I meant is to add text on a R plot when there is already legend on it. Like the left plot in above figure, another piece of text was put exactly below the legend "Pearson'r ...RMSE = 1.9". Here is the code for that:&amp;nbsp;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;l=legend("topleft", paste("Pearson's r =", R, "(p-value:", pvalue , ")\nRMSE =", RMSE), bty="n", cex=2) &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;text(x=l$text$x, y=l$text$y-l$rect$h/2, "text you want to put", adj=c(0,1))&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-6485521207912167540?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/6485521207912167540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=6485521207912167540' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/6485521207912167540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/6485521207912167540'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/09/add-text-aligned-to-legend-in-r-plot.html' title='Add text aligned to legend in R plot'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-8554305963364181454</id><published>2011-08-29T12:35:00.001-07:00</published><updated>2011-08-30T13:12:48.421-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='machine learning'/><title type='text'>Ensemble learning, bagging, boosting</title><content type='html'>&lt;a href="http://en.wikipedia.org/wiki/Ensemble_learning"&gt;Ensemble learning - Wikipedia, the free encyclopedia&lt;/a&gt;: &lt;div&gt;"an ensemble is a technique for combining many weak learners in an attempt to produce a strong learner"&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Bagging, abbreviation of 'bootstrap aggregating', trains each model in the ensemble using a randomly-drawn subset of the training set. So, each model is independent. Random forest algorithm, for instance, combines random decision tree with bagging to get a high classification accuracy. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Boosting, is to build the ensembl by incrementally including new model instances to emphasize the training instances that were mis-classified by previous models. Common implementation of Boosting is Adaboost.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Other understanding from the randomForest &lt;a href="http://www.webchem.science.ru.nl/PRiNS/rF.pdf"&gt;documentation&lt;/a&gt;:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;Recently there has been a lot of interest in “ensemble learning” — methods that generate many classiﬁers and aggregate their results. Two well-known methods are boosting (see, e.g., Shapire et al., 1998) and bagging (Breiman, 1996) of classiﬁcation trees. In boosting, successive trees give extra weight to points incorrectly predicted by earlier predictors. In the end, a weighted vote is taken for prediction. In bagging, successive trees do not depend on earlier trees— each is independently constructed using a bootstrap sample of the data set. In the end, a simple majority vote is taken for prediction.&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-8554305963364181454?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/8554305963364181454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=8554305963364181454' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/8554305963364181454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/8554305963364181454'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/08/ensemble-learning-bagging-boosting_29.html' title='Ensemble learning, bagging, boosting'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-9191025782104201553</id><published>2011-08-25T20:20:00.000-07:00</published><updated>2011-08-26T08:06:48.732-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Map API'/><title type='text'>Google Map API Exercise 1: display a static google map via URL</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;这是一张以俺家为中心的static map，center的经纬度是通过javascript:void(prompt('',gApplication.getMap().getCenter()));获取的。其代码如下：&lt;br /&gt;&lt;br /&gt;&amp;lt;img src=http://maps.googleapis.com/maps/api/staticmap?center=42.286959,-71.765538&amp;amp;zoom=17&amp;amp;size=512x512&amp;amp;maptype=satellite&amp;amp;markers=icon:http://bit.ly/pu5LFb|42.286959,-71.765538&amp;amp;sensor=true&amp;gt;&lt;br /&gt;&lt;br /&gt;其中被shorten的地址(http://bit.ly/pu5LFb)的原地址为：http://chart.apis.google.com/chart?chst=d_map_spin&amp;amp;chld=0.84|30|FFFF88|10|_|%E4%BF%BA%E5%AE%B6&lt;br /&gt;&lt;br /&gt;&lt;img src="http://maps.googleapis.com/maps/api/staticmap?center=42.286959,-71.765538&amp;amp;zoom=17&amp;amp;size=512x512&amp;amp;maptype=satellite&amp;amp;markers=icon:http://bit.ly/pTWHqS|42.286959,-71.765538&amp;amp;sensor=true" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-9191025782104201553?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/9191025782104201553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=9191025782104201553' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/9191025782104201553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/9191025782104201553'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/08/google-map-exercise-1-display-static.html' title='Google Map API Exercise 1: display a static google map via URL'/><author><name>小曦</name><uri>http://www.blogger.com/profile/02797103388947067641</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-6BAsm9zMhXU/TWHuXJNVLsI/AAAAAAAAAAM/x8KbsqBh6vw/s220/dddd.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-4737340479142904442</id><published>2011-08-25T19:24:00.000-07:00</published><updated>2011-08-25T20:10:59.407-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='biology'/><title type='text'>Estrogen receptor(ER) and hormone</title><content type='html'>&lt;ol&gt;&lt;li&gt;Sex hormone is one class of hormones, which includes estrogen, androgen, and progestogen. Hormone are important for inter-cell signaling. &lt;/li&gt;&lt;li&gt;Estradiol (E2) is one of estrogen, which can enter cell freely and bind to its receptor. &lt;/li&gt;&lt;li&gt;Estrogen receptor (ER) is a group of receptor that can be activated by estrogen. There are two types of ER, ERα and ERβ, both of which can form a dimer after activated by hormone. So, there are&lt;span&gt;&lt;span&gt; ERα (αα) or ERβ (ββ) homodimers or ERαβ (αβ) heterodimer. &lt;/span&gt;&lt;/span&gt;ER-alpha mostly occu&lt;span&gt;&lt;span&gt;rs in endometrium, breast cancer cells, ovarian stroma cells, and the hypothalamus, where ER-beta are found in  kidney, brain, bone, heart, lungs, intestinal mucosa, prostate, and endothelial cells.&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255); "&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Without sex hormone, ER are largely located in cytosol. When it's bound by hormone, a numer of events&lt;span&gt;&lt;span&gt; "starting with migration of the receptor from the cytosol into the nucleus, dimerization of the receptor, and subsequent binding of the receptor dimer to specific sequences of DNA (called hormone response elements)" are triggered. The receptor/DNA complex can then recruit other factor to initiate/activate the transcription of downstream genes. &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255); "&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-4737340479142904442?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/4737340479142904442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=4737340479142904442' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4737340479142904442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4737340479142904442'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/08/estrogen-receptorer-and-hormone.html' title='Estrogen receptor(ER) and hormone'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/16940344808359020274</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='23' src='http://2.bp.blogspot.com/-5nEQL6GJgQM/TrQ02ntljKI/AAAAAAAAAD0/c4WKSs3Ii7Q/s220/314669_505086718389_337800085_78915_302642893_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-1512735696484853913</id><published>2011-08-19T08:04:00.000-07:00</published><updated>2011-09-20T07:30:56.859-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SVG'/><category scheme='http://www.blogger.com/atom/ns#' term='pretty-R'/><category scheme='http://www.blogger.com/atom/ns#' term='heat calendar'/><category scheme='http://www.blogger.com/atom/ns#' term='finance'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>display time series data in R</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Thanks to the Revolutions &lt;a href="http://blog.revolutionanalytics.com/2011/07/r-svg-graphics.html"&gt;blog&lt;/a&gt;, several things learned here:&lt;br /&gt;1. R code for &lt;a href="http://blog.revolution-computing.com/downloads/calendarHeat.R"&gt;heat calendar&lt;/a&gt;&lt;br /&gt;2. generate &lt;a href="http://www.inside-r.org/r-doc/grDevices/cairo"&gt;SVG&lt;/a&gt; from R&lt;br /&gt;3. &lt;a href="http://www.inside-r.org/pretty-r/tool"&gt;pretty-R tool&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;OK. Let's explain it by plotting the fund WASCX (&lt;span class="Apple-style-span" style="background-color: white; font-family: arial; font-size: 17px; line-height: 20px;"&gt;IVY ASSET STRATEGY FUND CLASS C&lt;/span&gt;) from 2009-03-14:&lt;br /&gt;&lt;div style="overflow: auto;"&gt;&lt;div class="geshifilter"&gt;&lt;pre class="r geshifilter-R" style="font-family: monospace;"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;# source code of calendarHeat (by Paul Bleicher)&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/base/source"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;source&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;"http://blog.revolution-computing.com/downloads/calendarHeat.R"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style="color: #666666; font-style: italic;"&gt;# fetch stock time series data from Yahoo finance&lt;/span&gt;&lt;br /&gt;stock &amp;lt;- &lt;span style="color: blue;"&gt;"WASCX"&lt;/span&gt;&lt;br /&gt;start.date &amp;lt;- &lt;span style="color: blue;"&gt;"2009-03-14"&lt;/span&gt;&lt;br /&gt;end.date &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/Sys.Date"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;Sys.Date&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/base/quote"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;quote&lt;/span&gt;&lt;/a&gt; &amp;lt;- &lt;a href="http://inside-r.org/r-doc/base/paste"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;paste&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;"http://ichart.finance.yahoo.com/table.csv?s="&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;br /&gt;                stock&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: blue;"&gt;"&amp;amp;a="&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/substr"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;substr&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;start.date&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;6&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;7&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: blue;"&gt;"&amp;amp;b="&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/substr"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;substr&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;start.date&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;9&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;10&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: blue;"&gt;"&amp;amp;c="&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/substr"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;substr&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;start.date&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;br /&gt;                &lt;span style="color: blue;"&gt;"&amp;amp;d="&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/substr"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;substr&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;end.date&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;6&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;7&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: blue;"&gt;"&amp;amp;e="&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/substr"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;substr&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;end.date&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;9&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;10&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: blue;"&gt;"&amp;amp;f="&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;a href="http://inside-r.org/r-doc/base/substr"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;substr&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;end.date&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;4&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: blue;"&gt;"&amp;amp;g=d&amp;amp;ignore=.csv"&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; sep=&lt;span style="color: blue;"&gt;""&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;             &lt;br /&gt;stock.data &amp;lt;- &lt;a href="http://inside-r.org/r-doc/utils/read.csv"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;read.csv&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;a href="http://inside-r.org/r-doc/base/quote"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;quote&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt; as.is=&lt;span style="color: black; font-weight: bold;"&gt;TRUE&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style="color: #666666; font-style: italic;"&gt;# display in SVG format&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/grDevices/svg"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;svg&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;"WASCX.svg"&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;width=&lt;span style="color: #cc66cc;"&gt;14&lt;/span&gt;&lt;span style="color: #339933;"&gt;,&lt;/span&gt;height=&lt;span style="color: #cc66cc;"&gt;7&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;br /&gt;calendarHeat&lt;span style="color: #009900;"&gt;(&lt;/span&gt;stock.data$Date&lt;span style="color: #339933;"&gt;,&lt;/span&gt; stock.data$Adj.Close&lt;span style="color: #339933;"&gt;,&lt;/span&gt; &lt;br /&gt;  varname=&lt;span style="color: blue;"&gt;"WASCX Adjusted Close"&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;a href="http://inside-r.org/r-doc/grDevices/dev.off"&gt;&lt;span style="color: #003399; font-weight: bold;"&gt;dev.off&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #009900;"&gt;(&lt;/span&gt;&lt;span style="color: #009900;"&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href="http://www.inside-r.org/pretty-r" title="Created by Pretty R at inside-R.org"&gt;Created by Pretty R at inside-R.org&lt;/a&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://dl.dropbox.com/u/13229134/WASCX.svg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://dl.dropbox.com/u/13229134/WASCX.svg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-1512735696484853913?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/1512735696484853913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=1512735696484853913' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1512735696484853913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1512735696484853913'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/08/heat-calendar-for-time-series-data.html' title='display time series data in R'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-4547938574934699920</id><published>2011-08-17T11:22:00.000-07:00</published><updated>2011-08-18T07:08:38.792-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>One R Tip A Day: How to draw a plot with two Y axises and one X axis</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://onertipaday.blogspot.com/2007/05/how-to-draw-plot-with-two-y-axises-and.html"&gt;One R Tip A Day: How to draw a plot with two Y axises and one X axis&lt;/a&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;plot(1:10)&lt;br /&gt;par("usr")&lt;br /&gt;# [1] 0.64 10.36 0.64 10.36&lt;br /&gt;# Now resetting y axis' usr coordinates:&lt;br /&gt;par(usr=c(par("usr")[1:2], 101, 105))&lt;br /&gt;points(1:5, 105:101, col="red")&lt;br /&gt;axis(4)&lt;/span&gt;&lt;/blockquote&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5134844606014647282" src="http://4.bp.blogspot.com/_zct02J1FROM/R0Kh9q5Va_I/AAAAAAAAAFI/xYpEHLTQvVM/s400/usr.png" style="display: block; margin-bottom: 10px; margin-left: auto; margin-right: auto; margin-top: 0px; text-align: center;" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;par(mar=c(4, 5, 4, 5) + 0.1)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;plot(y1, type='b', col='gray', ylim=range(c(y1, y2)), ylab="y")&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;lines(y2, type='b', pch=19)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# draw the other Y axis&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;par(usr=c(par("usr")[1:2], range(Y)))&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;lines(Y, type='b', pch=20, col='blue')&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;axis(4, col.axis='blue')&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# manually label the other Y axis&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;mtext(side=4, line=1, 'Y', col='blue')&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;legend('topleft', c("y1", "y2", "Y"), pch=c(19, 1, 20), col=c('black', 'gray', 'blue'), lty=1)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;A very smart way, rather than transforming one Y axis range to the other Y axis range by math formula.&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#Y = (Y-min(Y))*(max(y1, y2) - min(y1, y2))/(max(Y)-min(Y)) + min(y1, y2)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-4547938574934699920?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/4547938574934699920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=4547938574934699920' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4547938574934699920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4547938574934699920'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/08/one-r-tip-day-how-to-draw-plot-with-two.html' title='One R Tip A Day: How to draw a plot with two Y axises and one X axis'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_zct02J1FROM/R0Kh9q5Va_I/AAAAAAAAAFI/xYpEHLTQvVM/s72-c/usr.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-3009185097034127335</id><published>2011-08-17T09:23:00.000-07:00</published><updated>2011-08-19T11:43:14.549-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='meme'/><category scheme='http://www.blogger.com/atom/ns#' term='bioinformatics'/><title type='text'>How to run Meme on cluster</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 14px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="heading" style="border-bottom-color: silver; border-bottom-style: solid; border-bottom-width: 1px; font-size: 22px; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="color: red; font-size: small; font-weight: normal;"&gt;The latest version of Meme, v4.6.1, was built with mpich, while the earlier versions were built with openmpi. You need to set the path correctly as in the examples below.&lt;/span&gt;&lt;/div&gt;Your input database should consist of a file containing sequences in fasta format. In the example below, the file is 'mini-drosoph.s'.&lt;br /&gt;&lt;b&gt;Maxsize parameter:&lt;/b&gt;&amp;nbsp;The maximum dataset size in characters. Determine the number of characters in your dataset by typing 'wc -c filename'. e.g.&lt;br /&gt;&lt;div class="term" style="background-color: #e6e9fa; border-bottom-color: silver; border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: silver; border-left-style: dashed; border-left-width: 1px; border-right-color: silver; border-right-style: dashed; border-right-width: 1px; border-top-color: silver; border-top-style: dashed; border-top-width: 1px; font-family: monospace; font-size: 12px; margin-left: 2em; margin-right: 2em; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"&gt;&lt;pre style="white-space: pre-wrap; word-wrap: break-word;"&gt;[user@biowulf mydir]$ wc -c mini-drosoph.s &lt;br /&gt;506016 mini-drosoph.s&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;For this dataset, the maxsize parameter has to be set to greater than 506,016, so we will use 600000.Set up a batch script along the lines of the ones below:&lt;br /&gt;&lt;h3&gt;Batch script for Meme 4.6.1&lt;/h3&gt;&lt;div class="term" style="background-color: #e6e9fa; border-bottom-color: silver; border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: silver; border-left-style: dashed; border-left-width: 1px; border-right-color: silver; border-right-style: dashed; border-right-width: 1px; border-top-color: silver; border-top-style: dashed; border-top-width: 1px; font-family: monospace; font-size: 12px; margin-left: 2em; margin-right: 2em; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"&gt;&lt;pre style="white-space: pre-wrap; word-wrap: break-word;"&gt;----  this file is called meme.batch ---------&lt;br /&gt;#!/bin/bash&lt;br /&gt;#This batch script can be used with Meme 4.6.1&lt;br /&gt;#PBS -N Meme&lt;br /&gt;#PBS -m be&lt;br /&gt;#PBS -j oe&lt;br /&gt;&lt;br /&gt;export PATH=/usr/local/mpich-1.2.7p1-gcc4_64/bin:$PATH&lt;br /&gt;cd /data/user/meme/&lt;br /&gt;time mpirun -machinefile $PBS_NODEFILE -np $np /usr/local/meme_4.6.1/bin/meme_p \&lt;br /&gt;     /data/user/meme/test.fa -oc /data/user/meme/meme_out \&lt;br /&gt;     -maxsize 10000000 -p $np&lt;br /&gt;&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;// The above tips are from&amp;nbsp;http://biowulf.nih.gov/apps/meme.html&lt;/div&gt;&lt;br /&gt;btw, the above script use PBS (Portable Batch System) submission system. Alternatively, there are other options, like LoadLeveler (Champion), LSF (Lonestar). There are syntax comparison &lt;a href="http://services.tacc.utexas.edu/index.php/batch-systems-comparison"&gt;here&lt;/a&gt;. Also, more detail for SGE and PBS &lt;a href="http://wiki.ibest.uidaho.edu/index.php/Tutorials:_SGE_PBS_Converting"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-3009185097034127335?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/3009185097034127335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=3009185097034127335' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3009185097034127335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3009185097034127335'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/08/how-to-run-meme-on-cluster.html' title='How to run Meme on cluster'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-8709111862229783668</id><published>2011-08-15T09:41:00.000-07:00</published><updated>2011-08-18T09:59:00.318-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='meme'/><category scheme='http://www.blogger.com/atom/ns#' term='bioinformatics'/><title type='text'>Difference between FIMO and MAST</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;FIMO and MAST are two applications in the MEME suites. &lt;br /&gt;&lt;br /&gt;FIMO is looking for the best individual matches to motifs. MAST is looking for sequences the have the best overall match to a collection of motifs.&lt;br /&gt;&lt;br /&gt;FIMO's task is simple: given a set of motifs and a database of sequences, compute the match score to each motif at each position in each sequence, and report all the motif matches that pass the p-value/q-value threshold. &lt;br /&gt;&lt;br /&gt;MAST's algorithm is more complex. For each sequence it carries out an initial scoring that is quite similar to FIMO's. MAST then picks the best match for each motif in the sequence. The p-values for these top matches are multiplied together to create an overall score for the full sequence. MAST reports the sequences that have the most significant overall scores. Typically MAST would be used to look for regulatory regions in DNA, or structures in proteins, where several motifs might occur near each other.&lt;br /&gt;&lt;br /&gt;-- Thanks to Charles for the explanation&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-8709111862229783668?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/8709111862229783668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=8709111862229783668' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/8709111862229783668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/8709111862229783668'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/08/difference-between-fimo-and-mast.html' title='Difference between FIMO and MAST'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-5183568373852852532</id><published>2011-08-09T19:40:00.000-07:00</published><updated>2011-08-09T19:40:29.248-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>Two ways of javascript function declaration</title><content type='html'>1. The first way uses a function name, like:&lt;br&gt;&lt;br /&gt;&lt;script class="brush: javascript" type="syntaxhighlighter"&gt;&lt;![CDATA[function add(a, b) {                       return a+b;}                     alert(add(1,2));        // produces 3]]&gt;&lt;/script&gt;&lt;br /&gt;2. The second way assigns a function without name to a variable, for example:&lt;br&gt;&lt;br /&gt;&lt;script class="brush: javascript" type="syntaxhighlighter"&gt;&lt;![CDATA[var add=function(a, b) {                       return a+b;}                     alert(add(1,2));        // produces 3]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Here are more details:&lt;br /&gt;http://stackoverflow.com/questions/336859/javascript-var-functionname-function-vs-function-functionname&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-5183568373852852532?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/5183568373852852532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=5183568373852852532' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/5183568373852852532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/5183568373852852532'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/08/two-ways-of-javascript-function.html' title='Two ways of javascript function declaration'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total><georss:featurename>Biotech Park Area, Worcester, MA, USA</georss:featurename><georss:point>42.28628445212348 -71.76654517675172</georss:point><georss:box>42.27684295212348 -71.78873367675172 42.29572595212348 -71.74435667675172</georss:box></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-4917335818789099968</id><published>2011-07-27T09:33:00.000-07:00</published><updated>2011-07-27T09:41:01.315-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>An efficient way to do dataset intersection</title><content type='html'>The main message is to use "match" to get index of needed rows and then get the rows by the index, instead of using the row names to select, which is much slower. Here is example:&lt;br /&gt;&lt;br /&gt;&lt;script class="brush: bash" type="syntaxhighlighter"&gt;&lt;![CDATA[histdata =unique(histdata[,c(-1, -3)]) # This step is slowhistdata=histdata[match(unique(histdata[,2]), histdata[,2]),c(-1, -3)]]]&gt;&lt;/script&gt;&lt;br /&gt;In example above, we know that the same values of column 2nd have same values of columns from 4th to the end. So, instead of doing unique on whole matrix, getting the unique of column 2nd and then getting the index of unique ones by match. Match(a,b) only return the index of first occurrence of a in b. For example&lt;br /&gt;&lt;script class="brush: bash" type="syntaxhighlighter"&gt;&lt;![CDATA[&gt; a=c(1,3,2,4)&gt; b=c(0:10)&gt; match(a,b)[1] 2 4 3 5&gt; a=c(1,3,2,4)&gt; b=rep(c(0:10), 2)&gt; match(a,b)[1] 2 4 3 5]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;This tips also help in intersecting two big dataframes. For example, &lt;br /&gt;&lt;script class="brush: bash" type="syntaxhighlighter"&gt;&lt;![CDATA[itsid=intersect(rownames(RNAseq1), rownames(histdata))# solution 1 -- very slowRNAseq0 = RNAseq1[itsid, ]histdata0 = histdata[itsid, ]# solution 2 -- much fasterRNAseq0 = RNAseq1[match(itsid, rownames(RNAseq1)),]histdata0 = histdata[match(itsid, rownames(histdata)), ]]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-4917335818789099968?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/4917335818789099968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=4917335818789099968' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4917335818789099968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4917335818789099968'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/07/efficient-way-to-do-dataset.html' title='An efficient way to do dataset intersection'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-1178677919157048415</id><published>2011-07-24T20:30:00.000-07:00</published><updated>2011-08-10T13:12:27.121-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Aparche'/><title type='text'>Linux Tutorial - Apache Web Login Authentication:</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.yolinux.com/TUTORIALS/LinuxTutorialApacheAddingLoginSiteProtection.html#ALTAUTH"&gt;Linux Tutorial - Apache Web Login Authentication:&lt;/a&gt;: &lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; font-family: helvetica, arial, sans-serif; font-size: medium;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;table border="0" cellpadding="2" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr bgcolor="#b0b0b0"&gt;&lt;td style="color: black; font-family: helvetica, arial, sans-serif;"&gt;&lt;b&gt;&lt;big&gt;Password protection by a single login:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;h3&gt;&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; font-family: helvetica, arial, sans-serif; font-size: medium;"&gt;Password files:&lt;/span&gt;&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; font-family: helvetica, arial, sans-serif; font-size: medium;"&gt;Create the directory you want to password protect (example: membersonly)&lt;/span&gt;&lt;/li&gt;&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; font-family: helvetica, arial, sans-serif; font-size: medium;"&gt;&lt;li&gt;Create a file &lt;tt&gt;/home/&lt;i&gt;domain&lt;/i&gt;/public_html/membersonly/.htaccess&lt;/tt&gt; in that director that looks something like this: &lt;br /&gt;&lt;dl&gt;&lt;dd&gt;&lt;table bgcolor="#000000" border="1" cellpadding="4" cellspacing="1"&gt;&lt;tbody&gt;&lt;tr bgcolor="#c0c0c0"&gt;&lt;td style="color: black; font-family: helvetica, arial, sans-serif;"&gt;&lt;pre&gt;AuthName "&lt;i&gt;Add your login message here.&lt;/i&gt;"     &amp;nbsp;&lt;/pre&gt;&lt;pre&gt;AuthType Basic     &amp;nbsp;&lt;/pre&gt;&lt;pre&gt;AuthUserFile /home/&lt;i&gt;domain&lt;/i&gt;/public_html/membersonly/.htpasswd     &amp;nbsp;&lt;/pre&gt;&lt;pre&gt;AuthGroupFile /dev/null     &amp;nbsp;&lt;/pre&gt;&lt;pre&gt;require user &lt;i&gt;name-of-user&lt;/i&gt;                     &lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/dd&gt;&lt;/dl&gt;In this case the "name-of-user" is the login name you wish to use for accessing the web site.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create (or clobber if it already exists) the password file /home/&lt;i&gt;domain&lt;/i&gt;/public_html/membersonly/.htpasswd using the program &lt;tt&gt;htpasswd&lt;/tt&gt;: &lt;br /&gt;&lt;pre&gt;htpasswd -c .htpasswd &lt;i&gt;name-of-user&lt;/i&gt;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-1178677919157048415?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/1178677919157048415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=1178677919157048415' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1178677919157048415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1178677919157048415'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/07/linux-tutorial-apache-web-login.html' title='Linux Tutorial - Apache Web Login Authentication:'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-1242846270366974287</id><published>2011-07-24T20:26:00.000-07:00</published><updated>2011-07-24T20:27:05.777-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='statistics'/><category scheme='http://www.blogger.com/atom/ns#' term='math'/><title type='text'>How to choose a statistical test?</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Verdana, Helvetica; font-size: 14px;"&gt;&lt;/span&gt;&lt;br /&gt;Nice table from&amp;nbsp;http://www.graphpad.com/www/book/choose.htm&lt;br /&gt;&lt;br /&gt;Table 37.1. Selecting a statistical test&lt;br /&gt;&lt;br /&gt;&lt;table border="2" cellpadding="3" cellspacing="0" style="width: 580px;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;/td&gt;&lt;td align="left" colspan="4" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=12445049&amp;amp;postID=1242846270366974287&amp;amp;from=pencil" name="UQHTML3"&gt;&lt;/a&gt;&lt;span class="sublft" style="color: #6633cc; font-family: Arial, Verdana, Helvetica; font-size: 14px; font-weight: 800; letter-spacing: normal; text-align: left;"&gt;Type of Data&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;span class="sublft" style="color: #6633cc; font-family: Arial, Verdana, Helvetica; font-size: 14px; font-weight: 800; letter-spacing: normal; text-align: left;"&gt;Goal&lt;/span&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Measurement (from Gaussian Population)&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Rank, Score, or Measurement (from Non- Gaussian Population)&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Binomial&lt;br /&gt;(Two Possible Outcomes)&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Survival Time&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Describe one group&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Mean, SD&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Median, interquartile range&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Proportion&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Kaplan Meier survival curve&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Compare one group to a hypothetical value&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;One-sample&amp;nbsp;&lt;i&gt;t&lt;/i&gt;test&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Wilcoxon test&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Chi-square&lt;br /&gt;or&lt;br /&gt;Binomial test **&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Compare two unpaired&lt;i&gt;&amp;nbsp;&lt;/i&gt;groups&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Unpaired&amp;nbsp;&lt;i&gt;t&lt;/i&gt;&amp;nbsp;test&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Mann-Whitney test&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Fisher's test&lt;br /&gt;(chi-square for large samples)&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Log-rank test or Mantel-Haenszel*&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Compare two paired groups&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Paired&amp;nbsp;&lt;i&gt;t&lt;/i&gt;&amp;nbsp;test&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Wilcoxon test&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;McNemar's test&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Conditional proportional hazards regression*&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Compare three or more unmatched groups&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;One-way ANOVA&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Kruskal-Wallis test&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Chi-square test&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Cox proportional hazard regression**&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Compare three or more matched groups&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Repeated-measures ANOVA&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Friedman test&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Cochrane Q**&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Conditional proportional hazards regression**&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Quantify association between two variables&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Pearson correlation&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Spearman correlation&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Contingency coefficients**&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Predict value from another measured variable&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Simple linear regression&lt;br /&gt;or&lt;br /&gt;Nonlinear regression&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Nonparametric regression**&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Simple logistic regression*&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Cox proportional hazard regression*&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;b&gt;Predict value from several measured or binomial variables&lt;/b&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Multiple linear regression*&lt;br /&gt;or&lt;br /&gt;Multiple nonlinear regression**&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Multiple logistic regression*&lt;/td&gt;&lt;td align="left" style="color: black; font-family: Arial, Verdana, Helvetica; font-size: 14px; vertical-align: top;" valign="top"&gt;Cox proportional hazard regression*&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-1242846270366974287?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/1242846270366974287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=1242846270366974287' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1242846270366974287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1242846270366974287'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2011/07/how-to-choose-statistical-test.html' title='How to choose a statistical test?'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-9144024907330570819</id><published>2010-11-20T19:38:00.000-08:00</published><updated>2010-11-20T19:39:29.981-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='find'/><title type='text'>Remove zero bytes files in folder</title><content type='html'>&lt;a href="http://www.unix.com/shell-programming-scripting/44271-remove-zero-bytes-files-folder.html"&gt;Remove zero bytes files in folder - The UNIX and Linux Forums&lt;/a&gt;: "&lt;br /&gt;&lt;br /&gt;find . -type f -size 0 | xargs rm&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;find . -type f -size 0 -exec rm {} \;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-9144024907330570819?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/9144024907330570819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=9144024907330570819' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/9144024907330570819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/9144024907330570819'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/11/remove-zero-bytes-files-in-folder-unix.html' title='Remove zero bytes files in folder'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-6775777654294902700</id><published>2010-11-20T15:47:00.000-08:00</published><updated>2010-11-20T19:40:32.872-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='awk'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='awk.system'/><title type='text'>awk.gsub, awk.system</title><content type='html'>&lt;a href="http://www.google.com/notebook/public/09328670786006596198/BDSdwQwoQ4bjM2t8i"&gt;Tips in Computer&lt;/a&gt;: "awk '{system('grep ' $4 ' file &amp;gt; result.txt'); getline result &amp;lt; 'result.txt'; close('result.txt'); print result;}' infile&lt;br /&gt;&lt;br /&gt;e.g File&lt;br /&gt;/scratch/dongx/jobid_2622600/18_2_62LPFAAXX_092810_MyersLab_4242.fastq.tophat.mm_1.unique.hg19.out/accepted_hits.bam&lt;br /&gt;/scratch/dongx/jobid_2622600/18_2_62LPFAAXX_092810_MyersLab_4242.fastq.tophat.mm_1.unique.hg19.out/junctions.bed&lt;br /&gt;/scratch/dongx/jobid_2622604/20_2_62MA2AAXX_101210_MyersLab_4430_4.fastq.tophat.mm_1.unique.hg19.out/accepted_hits.bam&lt;br /&gt;/scratch/dongx/jobid_2622604/20_2_62MA2AAXX_101210_MyersLab_4430_4.fastq.tophat.mm_1.unique.hg19.out/junctions.bed&lt;br /&gt;/scratch/dongx/jobid_2622606/20_5_62MA2AAXX_101210_PhiX.fastq.tophat.mm_1.unique.hg19.out/accepted_hits.bam&lt;br /&gt;&lt;br /&gt;You want to copy the .bam and .bed file to another folder...&lt;br /&gt;&lt;br /&gt;$ cat &amp;gt; tophat.log&lt;br /&gt;$ grep "s\.b" tophat.log | awk '{a=$1; gsub(".*[0-9]/","", a); sub("/",".", a); system("cp " $1 " " a);}'&lt;br /&gt;&lt;br /&gt;- Sent using Google Toolbar"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-6775777654294902700?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/6775777654294902700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=6775777654294902700' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/6775777654294902700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/6775777654294902700'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/11/awkgsub-awksystem.html' title='awk.gsub, awk.system'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-7088900914827617353</id><published>2010-11-08T18:28:00.000-08:00</published><updated>2010-11-20T19:42:10.002-08:00</updated><title type='text'>asparapee (芦笋尿)</title><content type='html'>&lt;a href="http://hi.baidu.com/toietmoi/blog/item/d670a7947d029d1fd31b7075.html"&gt;asparapee (芦笋尿)_我和你_百度空间&lt;/a&gt;: "今日看到一个很有趣的词——asparapee。这个俚语是asparagus+pee构成的一个复合词，直译就是“芦笋尿”。国外不少人喜欢吃芦笋，好吃而且对健康有好处。但是吃了芦笋之后，尿会有恶臭，臭到自己都受不了:) 科学上还没有一个确切的解释，大概是因为asparagus中含有硫化物或者某些氨基酸(amino acids)，可能和农民用硫来肥沃土壤有关。专家相信带有某种特殊基因的人能制造某种消化酶，这种酶可以把asparagus分解成某种有异味的氨基酸；而且带有某种基因的人，才能闻到这种气味。&lt;br /&gt;&lt;br /&gt;让我们看看Urban Dictionary的解释：&lt;br /&gt;&lt;br /&gt;http://www.urbandictionary.com/define.php?term=Asparapee&lt;br /&gt;&lt;br /&gt;The noxious smell in urine experienced by most people immediately after consuming asparagus. Studies have shown that while many can’t smell the pungent stench, most do extrude it. This phenomenon is most likely caused by farmers adding sulfur to fertilize their soil. The odor is sometimes accompanied by a neon yellow or green hue.&lt;br /&gt;&lt;br /&gt;Person A: Damn, your pee is freakin' reekin'! Did you have asparagus for dinner last night?&lt;br /&gt;&lt;br /&gt;Person B: Yes, I have asparapee.&lt;br /&gt;&lt;br /&gt;- Sent using Google Toolbar"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-7088900914827617353?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/7088900914827617353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=7088900914827617353' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/7088900914827617353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/7088900914827617353'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/11/asparapee.html' title='asparapee (芦笋尿)'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-4631990286516285549</id><published>2010-11-05T13:10:00.000-07:00</published><updated>2011-08-18T09:59:27.383-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>Parallel file downloading with wget | commandlinefu.com</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.commandlinefu.com/commands/view/3269/parallel-file-downloading-with-wget"&gt;Parallel file downloading with wget | commandlinefu.com&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;"Parallel file downloading with wget&lt;br /&gt;&lt;br /&gt;$ wget -nv http://en.wikipedia.org/wiki/Linux -O- | egrep -o "http://[^[:space:]]*.jpg" | xargs -P 10 -r -n 1 wget -nv&lt;br /&gt;&lt;br /&gt;xargs can be used in this manner to download multiple files at a time, and xargs will in this case run 10 processes at a time and initiate a new one when the number running falls below 10.&lt;br /&gt;&lt;br /&gt;- Sent using Google Toolbar"&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-4631990286516285549?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/4631990286516285549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=4631990286516285549' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4631990286516285549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4631990286516285549'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/11/parallel-file-downloading-with-wget.html' title='Parallel file downloading with wget | commandlinefu.com'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-1284793702490677005</id><published>2010-11-05T12:23:00.000-07:00</published><updated>2010-11-05T12:24:52.811-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='grep'/><title type='text'>Make grep stop after the first match - The macosxhints Forums</title><content type='html'>&lt;a href="http://hintsforums.macworld.com/showthread.php?t=93768"&gt;Make grep stop after the first match - The macosxhints Forums&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div class="smallfont"&gt;&lt;b&gt;Make grep stop after the first match&lt;/b&gt;    &lt;/div&gt;&lt;hr size="1" style="background-color: #d1d1e1; color: #d1d1e1;" /&gt;&lt;span style="font-weight: bold;"&gt;           Question: &lt;/span&gt;I'm trying to use grep to find all the href links in my asp files  (except in-page links that start with #).&lt;br /&gt;I want it to show me the &lt;b&gt;href="blahblah"&lt;/b&gt; part only - nothing  before href or after href's closing quote.&lt;br /&gt;Here's what I have so far. This: &lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family: courier;"&gt;grep  -i -r -o 'href="[^#].*"' rentals.asp&lt;/span&gt;&lt;/blockquote&gt;gives me this (&lt;span style="color: green;"&gt;green=good, &lt;/span&gt;&lt;span style="color: blue;"&gt;blue=bad&lt;/span&gt;):&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family: courier;"&gt;&lt;span style="color: green;"&gt;href="&amp;lt;%= webaddr  %&amp;gt;/rentalStyle.css"&lt;/span&gt; &lt;span style="color: blue;"&gt;type="text/css"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;href="&amp;lt;%= webaddr %&amp;gt;/rentals_s.asp"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;href="&amp;lt;%= webaddr %&amp;gt;/rentals_o.asp"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;rentals&lt;span style="font-size: 0.12em;"&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;href="&amp;lt;%= webaddr %&amp;gt;/search.asp"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;Search&lt;span style="font-size: 0.12em;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-weight: bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;"I think the question has to do with the 'greediness' of grep when multiple matches occur in the same line (in this case, the double-quote character). To match everything up to the first closing quotes, try:&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;grep -i -r -o 'href='[^#][^']*'' rentals.asp&lt;br /&gt;&lt;br /&gt;----------------&lt;br /&gt;Similar question to get URL links in html source code like:&lt;br /&gt;&lt;br /&gt;&amp;lt; href="ftp://encodeftp.cse.ucsc.edu:21/users/akundaje/rawdata/peaks/jul2010/idr0_02/narrowPeak_blacklistFiltered/wgEncodeBroadHistoneGm12878CtcfStdAlnRep0.bam_VS_wgEncodeBroadHistoneGm12878ControlStdAlnRep0.bam.regionPeak.gz"&amp;gt;wgEncodeBroadHistoneGm12878CtcfStdAlnRep0.bam_VS_wgEncodeBroadHistoneGm12878ControlStdAlnRep0.bam.regionPeak.gz&amp;lt; / a &amp;gt;&lt;br /&gt;&lt;br /&gt;hint code from &lt;a href="http://www.commandlinefu.com/commands/view/3269/parallel-file-downloading-with-wget"&gt;commandlinefu&lt;/a&gt; :&lt;br /&gt;egrep -o "ftp://[^[:space:]]*.gz"&lt;br /&gt;will get&lt;br /&gt;ftp://encodeftp.cse.ucsc.edu:21/users/akundaje/rawdata/peaks/jul2010/idr0_02/narrowPeak_blacklistFiltered/wgEncodeSydhTfbsK562bTr4UcdAlnRep0.bam_VS_wgEncodeSydhTfbsK562bInputUcdAlnRep1.bam.regionPeak.gz"&amp;gt;wgEncodeSydhTfbsK562bTr4UcdAlnRep0.bam_VS_wgEncodeSydhTfbsK562bInputUcdAlnRep1.bam.regionPeak.gz&lt;br /&gt;&lt;br /&gt;So, it should be corrected into :&lt;br /&gt;egrep -o "ftp://[^[:space:]^\"]*.gz"&lt;br /&gt;&lt;br /&gt;Smart, ha!&lt;br /&gt;- Sent using Google Toolbar"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-1284793702490677005?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/1284793702490677005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=1284793702490677005' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1284793702490677005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1284793702490677005'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/11/make-grep-stop-after-first-match.html' title='Make grep stop after the first match - The macosxhints Forums'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-3431973050154433364</id><published>2010-11-01T14:36:00.000-07:00</published><updated>2010-11-01T14:36:41.373-07:00</updated><title type='text'>One R Tip A Day: Sorting/ordering a data.frame according specific columns</title><content type='html'>&lt;a href="http://onertipaday.blogspot.com/2007/08/sortingordering-dataframe-according.html"&gt;One R Tip A Day: Sorting/ordering a data.frame according specific columns&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;x = rnorm(20)&lt;br /&gt;y = sample(rep(1:2, each = 10))&lt;br /&gt;z = sample(rep(1:4, 5))&lt;br /&gt;&lt;br /&gt;data.df &amp;lt;- data.frame(values = x, labels.1 = y, labels.2 = z)&lt;br /&gt;print(data.df)&lt;br /&gt;&lt;br /&gt;# data ordered according to 'labels.1' column&lt;br /&gt;# and then 'labels.2' column&lt;br /&gt;nams &amp;lt;- c('labels.1', 'labels.2')&lt;br /&gt;data.df.sorted = data.df[do.call(order, data.df[nams]), ]&lt;br /&gt;print(data.df.sorted)&lt;br /&gt;&lt;br /&gt;===================== OR ====================&lt;br /&gt;&lt;br /&gt;&lt;pre class="prettyprint"&gt;&lt;code&gt;&lt;span class="pln"&gt;dd &lt;/span&gt;&lt;span class="pun"&gt;&lt;-&lt;/span&gt;&lt;span class="pln"&gt; data&lt;/span&gt;&lt;span class="pun"&gt;.&lt;/span&gt;&lt;span class="pln"&gt;frame&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;b &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; factor&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;c&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="str"&gt;"Hi"&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="str"&gt;"Med"&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="str"&gt;"Hi"&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="str"&gt;"Low"&lt;/span&gt;&lt;span class="pun"&gt;),&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;      levels &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; c&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="str"&gt;"Low"&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="str"&gt;"Med"&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="str"&gt;"Hi"&lt;/span&gt;&lt;span class="pun"&gt;),&lt;/span&gt;&lt;span class="pln"&gt; ordered &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; TRUE&lt;/span&gt;&lt;span class="pun"&gt;),&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;      x &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; c&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="str"&gt;"A"&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="str"&gt;"D"&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="str"&gt;"A"&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="str"&gt;"C"&lt;/span&gt;&lt;span class="pun"&gt;),&lt;/span&gt;&lt;span class="pln"&gt; y &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; c&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="lit"&gt;8&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;3&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;9&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;9&lt;/span&gt;&lt;span class="pun"&gt;),&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;      z &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; c&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;2&lt;/span&gt;&lt;span class="pun"&gt;))&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;dd&lt;br /&gt;    b x y z&lt;br /&gt;&lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pln"&gt;  &lt;/span&gt;&lt;span class="typ"&gt;Hi&lt;/span&gt;&lt;span class="pln"&gt; A &lt;/span&gt;&lt;span class="lit"&gt;8&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="lit"&gt;2&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Med&lt;/span&gt;&lt;span class="pln"&gt; D &lt;/span&gt;&lt;span class="lit"&gt;3&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="lit"&gt;3&lt;/span&gt;&lt;span class="pln"&gt;  &lt;/span&gt;&lt;span class="typ"&gt;Hi&lt;/span&gt;&lt;span class="pln"&gt; A &lt;/span&gt;&lt;span class="lit"&gt;9&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="lit"&gt;4&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Low&lt;/span&gt;&lt;span class="pln"&gt; C &lt;/span&gt;&lt;span class="lit"&gt;9&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;2&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span class="pln"&gt;R&lt;/span&gt;&lt;span class="pun"&gt;&gt;&lt;/span&gt;&lt;span class="pln"&gt; dd&lt;/span&gt;&lt;span class="pun"&gt;[&lt;/span&gt;&lt;span class="kwd"&gt;with&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;dd&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; order&lt;/span&gt;&lt;span class="pun"&gt;(-&lt;/span&gt;&lt;span class="pln"&gt;z&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; b&lt;/span&gt;&lt;span class="pun"&gt;)),&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;]&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;    b x y z&lt;br /&gt;&lt;/span&gt;&lt;span class="lit"&gt;4&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Low&lt;/span&gt;&lt;span class="pln"&gt; C &lt;/span&gt;&lt;span class="lit"&gt;9&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;2&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="lit"&gt;2&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="typ"&gt;Med&lt;/span&gt;&lt;span class="pln"&gt; D &lt;/span&gt;&lt;span class="lit"&gt;3&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pln"&gt;  &lt;/span&gt;&lt;span class="typ"&gt;Hi&lt;/span&gt;&lt;span class="pln"&gt; A &lt;/span&gt;&lt;span class="lit"&gt;8&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="lit"&gt;3&lt;/span&gt;&lt;span class="pln"&gt;  &lt;/span&gt;&lt;span class="typ"&gt;Hi&lt;/span&gt;&lt;span class="pln"&gt; A &lt;/span&gt;&lt;span class="lit"&gt;9&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;1&lt;/span&gt;&lt;span class="pln"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;- Sent using Google Toolbar"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-3431973050154433364?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://onertipaday.blogspot.com/2007/08/sortingordering-dataframe-according.html' title='One R Tip A Day: Sorting/ordering a data.frame according specific columns'/><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/3431973050154433364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=3431973050154433364' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3431973050154433364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3431973050154433364'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/11/one-r-tip-day-sortingordering-dataframe.html' title='One R Tip A Day: Sorting/ordering a data.frame according specific columns'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-3027560925073877506</id><published>2010-11-01T10:10:00.000-07:00</published><updated>2010-11-01T11:10:54.378-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bioC'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>Interesting packages of new BioC2.7</title><content type='html'>&lt;p&gt;NuPoP&lt;/p&gt;  &lt;p&gt; Nucleosome positioning prediction&lt;/p&gt;&lt;p&gt;Mulcom&lt;/p&gt;  &lt;p&gt; Differential expression and false discovery rate calculation through  multiple comparison&lt;/p&gt;&lt;p&gt;ontoCAT&lt;/p&gt;  &lt;p&gt; Ontology parsing&lt;/p&gt;&lt;p&gt;BHC&lt;/p&gt;  &lt;p&gt; Bayesian Hierarchical Clustering&lt;/p&gt;&lt;p&gt;iSeq&lt;/p&gt;  &lt;p&gt; Bayesian Hierarchical Modeling of ChIP-seq Data Through Hidden Ising  Models&lt;br /&gt;&lt;/p&gt;URL: http://bioconductor.org/news/bioc_2_7_release/&lt;br /&gt;&lt;br /&gt;btw, other interesting ones in BioC 2.6:&lt;br /&gt;&lt;br /&gt;New sequence analysis tools address infrastructure (&lt;code&gt;GenomicRanges&lt;/code&gt;, &lt;code&gt;Rsamtools&lt;/code&gt;, &lt;code&gt;girafe&lt;/code&gt;); ChIP-seq (&lt;code&gt;BayesPeak&lt;/code&gt;,  &lt;code&gt;CSAR&lt;/code&gt;, &lt;code&gt;PICS&lt;/code&gt;); digital gene expression and RNA-seq (&lt;code&gt;DESeq&lt;/code&gt;, &lt;code&gt;goseq&lt;/code&gt;, &lt;code&gt;segmentSeq&lt;/code&gt;);  and motif discovery (&lt;code&gt;MotIV&lt;/code&gt;, &lt;code&gt;rGADEM&lt;/code&gt;).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-3027560925073877506?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/3027560925073877506/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=3027560925073877506' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3027560925073877506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3027560925073877506'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/11/interesting-packages-of-new-bioc27.html' title='Interesting packages of new BioC2.7'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-9134659812152844061</id><published>2010-10-28T16:09:00.000-07:00</published><updated>2010-10-28T16:33:54.830-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='job_array'/><category scheme='http://www.blogger.com/atom/ns#' term='cluster'/><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>Running R on cluster in a job_array way</title><content type='html'>&lt;a href="http://wiki.gridengine.info/wiki/index.php/Simple-Job-Array-Howto"&gt;Simple-Job-Array-Howto - GridWiki&lt;/a&gt;: "Example: R Scripts with Grid Engine Job Arrays&lt;br /&gt;&lt;br /&gt;All of the above applies to well-behaved, interactive programs. However, sometimes you need to use R to analyze your data. In order to do this, you have to hardcode file names into the R script, because these scripts are not interactive. This is a royal pain. However, there is a solution that makes use of HERE documents in bash. HERE documents also exist in perl, and an online tutorial for them in bash is at http://www.tldp.org/LDP/abs/html/here-docs.html. The short of it is that a HERE document can represent a skeleton document at the end of a shell script. Let’s concoct an example. You have 100 data files, labeled data.1 to data.10. Each file contains a single column of numbers, and you want to do some calculation for each of them, using R. Let’s use a HERE document:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;#!/bin/sh&lt;br /&gt;#$ -t 1-10&lt;br /&gt;WORKDIR=/Users/jl566/testing&lt;br /&gt;INFILE=$WORKDIR/data.$SGE_TASK_ID&lt;br /&gt;OUTFILE=$WORKDIR/data.$SGE_TASK_ID.out&lt;br /&gt;# See comment below about paths to R&lt;br /&gt;PATHTOR=/common/bin&lt;br /&gt;if [ -e $OUTFILE ]&lt;br /&gt;then&lt;br /&gt;rm -f $OUTFILE&lt;br /&gt;fi&lt;br /&gt;# Below, the phrase "EOF" marks the beginning and end of the HERE document.&lt;br /&gt;# Basically, what’s going on is that we’re running R, and suppressing all of&lt;br /&gt;# it’s output to STDOUT, and then redirecting whatever’s between the EOF words&lt;br /&gt;# as an R script, and using variable substitution to act on the desired files.&lt;br /&gt;$PATHTOR/R --quiet --no-save &gt; /dev/null &lt;&lt; EOF&lt;br /&gt;x&lt;-read.table("$INFILE")&lt;br /&gt;write(mean(x\$V1),"$OUTFILE")&lt;br /&gt;EOF&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;So now you can use the cluster to analyze your data – just write the R script within the HERE document, and go from there. As I’ve only just figured this out, some caveats are necessary. If anyone experiments and figures out something neat, let me know. Be aware of the following:&lt;br /&gt;&lt;br /&gt;1. In my limited experience, indenting is important for HERE documents. In particular, it seems that the beginning and end (i.e. both lines containing the term EOF in the above example), must be aligned with the left-hand edge of the buffer (i.e. not indented at all). So, if you use a HERE document in a conditional or control statement, be mindful of this.&lt;br /&gt;2. In the mean command, I escaped the dollar sign with a backslash. In my limited experiments, both mean(x\$V1) and mean(x$V1) seem to work. However, escaping the dollar sign for the read.table command prevents the variable substitution from occurring in the shell, causing R to fail, because the input file named $INFILE cannot be found. In other words, escaping in that context causes the HERE doc to pass $INFILE as a string literal to R, rather than the value stored in the shell variable.&lt;br /&gt;3. This is more useful than just array jobs on an SGE system. If you know bash well enough, you can write a shell script that takes a load of arguments, and processes them with a HERE document. This solves a major limitation with R scripts themselves. You can do the same in perl, too, on your workstation, but you must use a shell language on the cluster.&lt;br /&gt;&lt;br /&gt;- Sent using Google Toolbar"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-9134659812152844061?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/9134659812152844061/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=9134659812152844061' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/9134659812152844061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/9134659812152844061'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/10/simple-job-array-howto-gridwiki.html' title='Running R on cluster in a job_array way'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-6545577066419195213</id><published>2010-10-11T12:35:00.000-07:00</published><updated>2010-10-28T16:36:51.462-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><title type='text'>Linux tip: Bash parameters and parameter expansions</title><content type='html'>&lt;a href="http://www.ibm.com/developerworks/library/l-bash-parameters.html?ca=drs-"&gt;Linux tip: Bash parameters and parameter expansions&lt;/a&gt;: "Table 2. Shell expansion pattern matchingExpansion Purpose&lt;br /&gt;${PARAMETER#WORD} The shell expands WORD as in filename expansion and removes the shortest matching pattern, if any, from the beginning of the expanded value of PARAMETER. Using '@' or '$' results in the pattern removal for each parameter in the list.&lt;br /&gt;${PARAMETER##WORD} Results in removal of the longest matching pattern from the beginning rather than the shortest.&lt;br /&gt;${PARAMETER%WORD} The shell expands WORD as in filename expansion and removes the shortest matching pattern, if any, from the end of the expanded value of PARAMETER. Using '@' or '$' results in the pattern removal for each parameter in the list.&lt;br /&gt;${PARAMETER%%WORD} Results in removal of the longest matching pattern from the end rather than the shortest.&lt;br /&gt;${PARAMETER/PATTERN/STRING} The shell expands PATTERN as in filename expansion and replaces the longest matching pattern, if any, in the expanded value of PARAMETER. To match patterns at the beginning of the expanded value of PARAMETER, prefix PATTERN with # or prefix it with % if the match should be done at the end. If STRING is empty, the trailing / may be omitted and the matches are deleted. Using '@' or '$' results in the pattern substitution for each parameter in the list.&lt;br /&gt;${PARAMETER//PATTERN/STRING} Performs the substitution for all matches instead of just the first.&lt;br /&gt;&lt;br /&gt;Listing 11 shows some basic usage of the pattern matching expansions.&lt;br /&gt;&lt;br /&gt;Listing 11. Pattern matching examples&lt;br /&gt;&lt;br /&gt;[ian@pinguino ~]$ x='a1 b1 c2 d2'&lt;br /&gt;[ian@pinguino ~]$ echo ${x#*1}&lt;br /&gt;b1 c2 d2&lt;br /&gt;[ian@pinguino ~]$ echo ${x##*1}&lt;br /&gt;c2 d2&lt;br /&gt;[ian@pinguino ~]$ echo ${x%1*}&lt;br /&gt;a1 b&lt;br /&gt;[ian@pinguino ~]$ echo ${x%%1*}&lt;br /&gt;a&lt;br /&gt;[ian@pinguino ~]$ echo ${x/1/3}&lt;br /&gt;a3 b1 c2 d2&lt;br /&gt;[ian@pinguino ~]$ echo ${x//1/3}&lt;br /&gt;a3 b3 c2 d2&lt;br /&gt;[ian@pinguino ~]$ echo ${x//?1/z3}&lt;br /&gt;z3 z3 c2 d2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- Sent using Google Toolbar"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-6545577066419195213?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/6545577066419195213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=6545577066419195213' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/6545577066419195213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/6545577066419195213'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/10/linux-tip-bash-parameters-and-parameter.html' title='Linux tip: Bash parameters and parameter expansions'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-1342271078322236205</id><published>2010-10-11T11:16:00.000-07:00</published><updated>2010-10-28T16:40:20.291-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><title type='text'>parameters and options</title><content type='html'>In BASH shell script:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$0 : the program itself&lt;br /&gt;$1 : the first parameter&lt;br /&gt;$2 : the second parameter&lt;br /&gt;...&lt;br /&gt;&lt;/span&gt;A string enclosed in single or double             quotes will be passed as a single parameter, and the quotes  will be stripped.&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$# : the number of total parameters, not including the program itself&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$@ : the array of parameters. Double-quoted "$@" is equal to "$1", "$2", "$3".... This is the most common usage. But there are other variations, like $*, "$*", $@, or "$@". They can be explained distinctly. For more detail, see &lt;/span&gt;&lt;a style="font-family: courier new;" href="http://www.ibm.com/developerworks/library/l-bash-parameters.html?ca=drs-"&gt;examples here&lt;/a&gt;&lt;span style="font-family:courier new;"&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;For options, using&lt;br /&gt;getopt optstring optname&lt;br /&gt;&lt;br /&gt;where optstring is a double-quote string of option letters, like ":p:q". A colon (:) after an option letter indicates that the option&lt;br /&gt;requires a value; The leading colon tells getopts to be silent and suppress the&lt;br /&gt;normal error messages.&lt;br /&gt;&lt;pre class="displaycode"&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The second parameter, &lt;code&gt;optname&lt;/code&gt;, is the         name of a variable which will receive the name of the option  found. If an option         is expected to have a value, the value, if present, will be  placed in the variable         OPTARG. In silent mode, either of the following two error  conditions may occur. &lt;/p&gt;&lt;ol&gt;&lt;li&gt;If an unrecognized option is found,  then optname will contain a ? and OPTARG           will contain the unknown option. &lt;/li&gt;&lt;li&gt;If an options that  requires a value is found but the value is not, then           optname will contain a : and OPTARG will contain the name of  the option whose           argument is missing.&lt;/li&gt;&lt;/ol&gt;&lt;pre class="displaycode"&gt;For example, getopt ":p:q" optnames&lt;br /&gt;will require an option (-p) with value, and -q without having value.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Example: &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;echo "OPTIND starts at $OPTIND"&lt;br /&gt;while getopts ":pq:" optname&lt;br /&gt;do&lt;br /&gt;  case "$optname" in&lt;br /&gt;    "p")&lt;br /&gt;      echo "Option $optname is specified, with value"&lt;br /&gt;      ;;&lt;br /&gt;    "q")&lt;br /&gt;      echo "Option $optname has value $OPTARG"&lt;br /&gt;      ;;&lt;br /&gt;    "?")&lt;br /&gt;      echo "Unknown option $OPTARG"&lt;br /&gt;      ;;&lt;br /&gt;    ":")&lt;br /&gt;      echo "No argument value for option $OPTARG"&lt;br /&gt;      ;;&lt;br /&gt;    *)&lt;br /&gt;    # Should not occur&lt;br /&gt;      echo "Unknown error while processing options"&lt;br /&gt;      ;;&lt;br /&gt;  esac&lt;br /&gt;  echo "OPTIND is now $OPTIND"&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-1342271078322236205?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/1342271078322236205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=1342271078322236205' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1342271078322236205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/1342271078322236205'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/10/parameters-and-options.html' title='parameters and options'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-6193309342612657205</id><published>2010-10-11T10:52:00.000-07:00</published><updated>2010-10-11T11:00:20.632-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><title type='text'>file/folder existence</title><content type='html'>General syntax in BASH shell is: &lt;p&gt;&lt;strong&gt;[  parameter  FILE ]&lt;/strong&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;strong&gt;test  parameter  FILE&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Where parameter can be any one of the following:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;-e: Returns true value if file exists&lt;/li&gt;&lt;li&gt;-f: Return true value if file exists and regular file&lt;/li&gt;&lt;li&gt;-r: Return true value if file exists and is readable&lt;/li&gt;&lt;li&gt;-w: Return true value if file exists and is writable&lt;/li&gt;&lt;li&gt;-x: Return true value if file exists and is executable&lt;/li&gt;&lt;li&gt;-d:  Return true value if exists and is a &lt;span style="font-weight: bold;"&gt;directory&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;For example,&lt;br /&gt;&lt;br /&gt;Find out if file /etc/passwd file exists or not:&lt;br /&gt;&lt;code&gt;$ [ -f /etc/passwd ] &amp;amp;&amp;amp; echo "File exists" || echo "File  does not exists"&lt;br /&gt;&lt;br /&gt;# Make the directory for the job ID you are running if it does not exist&lt;br /&gt;[ -d $HOME/scratch/jobid_$JOB_ID ] || mkdir -p $HOME/scratch/jobid_$JOB_ID&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;You can use conditional expressions in a shell script: &lt;pre class="bash"&gt;&lt;span style="color: rgb(128, 128, 128); font-style: italic;"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 120, 0);"&gt;FILE=&lt;/span&gt;$&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(122, 8, 116); font-weight: bold;"&gt;[&lt;/span&gt; -f &lt;span style="color: rgb(0, 120, 0);"&gt;$FILE&lt;/span&gt; &lt;span style="color: rgb(122, 8, 116); font-weight: bold;"&gt;]&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;then&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(122, 8, 116); font-weight: bold;"&gt;echo&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;"File $FILE exists"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;else&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(122, 8, 116); font-weight: bold;"&gt;echo&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;"File $FILE does not exists"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;fi&lt;/span&gt;&lt;br /&gt; &lt;/pre&gt;See if a directory exists or not with NOT operator:&lt;br /&gt;&lt;strong&gt;[ ! -d directory ]&lt;/strong&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;strong&gt;! test directory&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-6193309342612657205?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/6193309342612657205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=6193309342612657205' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/6193309342612657205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/6193309342612657205'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/10/filefolder-existence.html' title='file/folder existence'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-724738774910024137</id><published>2010-09-28T20:26:00.000-07:00</published><updated>2011-08-18T09:59:43.538-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>Reorder one data.frame using two columns from another data.frame in R - Stack Overflow</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://stackoverflow.com/questions/3549593/reorder-one-data-frame-using-two-columns-from-another-data-frame-in-r"&gt;Reorder one data.frame using two columns from another data.frame in R - Stack Overflow&lt;/a&gt;: "b[match(a$id,b$id),]&lt;br /&gt;&lt;br /&gt;Unfortunately, I'm not sure how to accomplish the same thing when I need to order by two columns.&lt;br /&gt;&lt;br /&gt;a:&lt;br /&gt;&lt;br /&gt;id lob&lt;br /&gt;1 1+   X&lt;br /&gt;2  3   X&lt;br /&gt;3  2   X&lt;br /&gt;4  1   X&lt;br /&gt;5  1   Y&lt;br /&gt;6 1+   Y&lt;br /&gt;7 1+   X&lt;br /&gt;8  3   X&lt;br /&gt;9  3   X&lt;br /&gt;&lt;br /&gt;b:&lt;br /&gt;&lt;br /&gt;id lob val&lt;br /&gt;1 1+   X   1&lt;br /&gt;2 1+   Y   9&lt;br /&gt;3 1+   X   1&lt;br /&gt;4  3   X   5&lt;br /&gt;5  3   X   5&lt;br /&gt;6  3   X   5&lt;br /&gt;7  2   X   4&lt;br /&gt;8  1   X   3&lt;br /&gt;9  1   Y   2&lt;br /&gt;&lt;br /&gt;I want to get this:&lt;br /&gt;&lt;br /&gt;id lob val&lt;br /&gt;1 1+   X   1&lt;br /&gt;2  3   X   5&lt;br /&gt;3  2   X   4&lt;br /&gt;4  1   X   3&lt;br /&gt;5  1   Y   2&lt;br /&gt;6 1+   Y   9&lt;br /&gt;7 1+   X   1&lt;br /&gt;8  3   X   5&lt;br /&gt;9  3   X   5&lt;br /&gt;&lt;br /&gt;- Sent using Google Toolbar"&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-724738774910024137?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/724738774910024137/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=724738774910024137' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/724738774910024137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/724738774910024137'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/09/reorder-one-dataframe-using-two-columns.html' title='Reorder one data.frame using two columns from another data.frame in R - Stack Overflow'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-3069940738238312928</id><published>2010-09-28T13:11:00.000-07:00</published><updated>2011-08-18T10:00:05.813-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>How to replace space using sed in shell script</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.linuxquestions.org/questions/linux-newbie-8/how-to-replace-space-using-sed-in-shell-script-668353/"&gt;How to replace space using sed in shell script&lt;/a&gt;: "Use the + modifer to match one or more occurences of the previous regular expression. &lt;span style="color: red; font-weight: bold;"&gt;It needs to be escaped&lt;/span&gt;:&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;$ echo '12:Mit     23627   83763   tty message' | sed 's/ \+/:/g'&lt;br /&gt;12:Mit:23627:83763:tty:message&lt;br /&gt;&lt;br /&gt;$echo '12:Mit 23627   83763 tty    message' | sed 's/ /:/g'| cat -A&lt;br /&gt;12:Mit:23627:::83763:tty::::message$&lt;br /&gt;&lt;br /&gt;$ echo '12:Mit 23627   83763 tty    message' | sed 's/ +/:/g'&lt;br /&gt;12:Mit 23627   83763 tty    message&lt;br /&gt;&lt;br /&gt;- Sent using Google Toolbar"&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-3069940738238312928?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/3069940738238312928/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=3069940738238312928' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3069940738238312928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3069940738238312928'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/09/how-to-replace-space-using-sed-in-shell.html' title='How to replace space using sed in shell script'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-198395170318709116</id><published>2010-09-25T12:42:00.000-07:00</published><updated>2011-08-18T10:00:21.524-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='awk'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>PASS parameter to AWK - The UNIX and Linux Forums</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.unix.com/unix-dummies-questions-answers/13955-pass-parameter-awk.html"&gt;PASS parameter to AWK - The UNIX and Linux Forums&lt;/a&gt;: "You can also assign variables on the command line, e.g....&lt;br /&gt;&lt;br /&gt;awk -v a=1 -v b=2 -v c=3 -f test.awk&lt;br /&gt;&lt;br /&gt;The -v option means that the variables are assigned before the BEGIN section.&lt;br /&gt;&lt;br /&gt;- Sent using Google Toolbar"&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-198395170318709116?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/198395170318709116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=198395170318709116' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/198395170318709116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/198395170318709116'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/09/pass-parameter-to-awk-unix-and-linux.html' title='PASS parameter to AWK - The UNIX and Linux Forums'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-2652278995203733230</id><published>2010-09-25T10:15:00.000-07:00</published><updated>2010-09-25T10:15:53.041-07:00</updated><title type='text'>if you..., I would like to pay cold hard cash?</title><content type='html'>&lt;a href="http://wiki.answers.com/Q/What_does_the_phrase_%27cold_hard_cash%27_mean"&gt;Answers.com - What does the phrase 'cold hard cash' mean&lt;/a&gt;: "Back when coinage used to be made from precious metals like gold and silver, the value of the metal itself was used to guarantee the worth of the coin; some people didn't trust paper money, as inflation or war could quickly make it worthless.&lt;br /&gt;&lt;br /&gt;These days, the idea has evolved into the idea of using money, including paper money, rather than a check or a credit card -- both of which have a higher risk of being fraudulent, or which can be more easily canceled after the sale. Money, once handed over, can't be taken back so easily.&lt;br /&gt;&lt;br /&gt;- Sent using Google Toolbar"&lt;br /&gt;&lt;br /&gt;说白了，就是中国话的“真金白银”&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-2652278995203733230?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://wiki.answers.com/Q/What_does_the_phrase_%27cold_hard_cash%27_mean' title='if you..., I would like to pay cold hard cash?'/><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/2652278995203733230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=2652278995203733230' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/2652278995203733230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/2652278995203733230'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2010/09/if-you-i-would-like-to-pay-cold-hard.html' title='if you..., I would like to pay cold hard cash?'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-512915306829243455</id><published>2009-06-10T06:43:00.000-07:00</published><updated>2009-06-10T06:43:04.915-07:00</updated><title type='text'>firefox add on blogspot - Google Search</title><content type='html'>&lt;a href="http://www.google.com/search?ie=UTF-8&amp;amp;oe=UTF-8&amp;amp;sourceid=navclient&amp;amp;gfns=1&amp;amp;q=firefox+add+on+blogspot"&gt;firefox add on blogspot - Google Search&lt;/a&gt;: "#&lt;br /&gt;Url Shortening Firefox Addon with Google Analytics Support ~ Web Upd8&lt;br /&gt;25 Apr 2009 ... Snip-n-Tag is a Firefox addon to easily shorten URLs, plus add Google ... on Post Author for a Wordpress / Blogger (blogspot.com) Blog ...&lt;br /&gt;webupd8.blogspot.com/2009/04/url-shortening-firefox-addon-with.html - Cached - Similar pages -&lt;br /&gt;#&lt;br /&gt;JDownloader 0.5.859 - New Interface, Firefox Addon and Many other ...&lt;br /&gt;JDownloader 0.5.859 - New Interface, Firefox Addon and Many other Changes. ... The new version also comes with a Firefox plugin which can automatically handle .... Depening on Post Author for a Wordpress / Blogger (blogspot.com) Blog ...&lt;br /&gt;webupd8.blogspot.com/2009/05/jdownloader-05859-new-interface-firefox.html -"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-512915306829243455?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.google.com/search?ie=UTF-8&amp;oe=UTF-8&amp;sourceid=navclient&amp;gfns=1&amp;q=firefox+add+on+blogspot' title='firefox add on blogspot - Google Search'/><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/512915306829243455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=512915306829243455' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/512915306829243455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/512915306829243455'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2009/06/firefox-add-on-blogspot-google-search.html' title='firefox add on blogspot - Google Search'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-2989751249467308651</id><published>2008-09-23T04:46:00.000-07:00</published><updated>2011-08-18T10:03:00.113-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>Illustration of linux command</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-rvy45dg4itM/Tk1FtVBVXUI/AAAAAAAAHaw/wghzblivcZg/s1600/linuxcommand.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="377" src="http://1.bp.blogspot.com/-rvy45dg4itM/Tk1FtVBVXUI/AAAAAAAAHaw/wghzblivcZg/s640/linuxcommand.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-2989751249467308651?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/2989751249467308651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=2989751249467308651' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/2989751249467308651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/2989751249467308651'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2008/09/illustration-of-linux-command.html' title='Illustration of linux command'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-rvy45dg4itM/Tk1FtVBVXUI/AAAAAAAAHaw/wghzblivcZg/s72-c/linuxcommand.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-3899265028627730123</id><published>2008-09-10T02:17:00.000-07:00</published><updated>2008-09-10T02:18:55.660-07:00</updated><title type='text'>AWK learning note</title><content type='html'>&lt;b&gt; 1.  first update the internal variables when reading one line:&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt; 當 AWK 從資料檔中讀取一筆資料列時, AWK 會使用內建變數$0 予以記錄.&lt;/li&gt;&lt;li&gt; AWK 會立刻重新分析 $0 的欄位情況, 並將 $0 上各欄位的資料用 $1, $2, ..予以記錄.&lt;/li&gt;&lt;/ol&gt;&lt;pre&gt;&lt;br /&gt;例如 : AWK 從資料檔 emp.dat 中讀入第一筆資料列&lt;br /&gt;"A125 Jenny 100 210" 之後, 程式中:&lt;br /&gt;$0 之值將是 "A125 Jenny 100 210"&lt;br /&gt;$1 之值為 "A125" $2 之值為 "Jenny"&lt;br /&gt;$3 之值為 100 $4 之值為 210&lt;br /&gt;NF 之值為 4 $NF 之值為 210&lt;br /&gt;NR 之值為 1 FILENAME 之值為 ``emp.dat''&lt;br /&gt;&lt;pre&gt;where NF: Number of Fields in current $0&lt;br /&gt;NR: Number of Records of currently having been read.&lt;br /&gt;FILENAMEAWK: filename of current proceeding&lt;br /&gt;&lt;br /&gt;2. &lt;b&gt;&lt;b&gt;'PATTERN{ACTION}' or -f script.awk&lt;br /&gt;&lt;/b&gt;&lt;/b&gt;the following two ways are same&lt;b&gt;&lt;b&gt;:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;&lt;/b&gt;&lt;span style="font-family: verdana,sans-serif;"&gt;$awk -f pay1.awk emp.dat&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana,sans-serif;"&gt;$awk ' { print $2, $3 * $4 } ' emp.dat&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;if you save the script into a file named pay1.awk.&lt;br /&gt;讀者可使用``-f''參數,讓AWK主程式使用其它僅含 AWK函數 的&lt;br /&gt;檔案中的函數&lt;br /&gt;其語法如下:&lt;br /&gt;awk -f AWK主程式檔名 -f AWK函數檔名 資料檔檔名&lt;b&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/b&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;pre&gt;&lt;pre&gt;&lt;b&gt;3. BEGIN/END and array in AWK&lt;/b&gt;&lt;br /&gt;for example, we have a data file like:&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt; Mary O.S. Arch. Discrete&lt;br /&gt;Steve D.S. Algorithm Arch.&lt;br /&gt;Wang Discrete Graphics O.S.&lt;br /&gt;Lisa Graphics A.I. Lily Discrete Algorithm &lt;pre&gt;&lt;pre&gt;---------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;span style="font-family: courier new,monospace;"&gt;{for( i=2; i&lt;&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;END{&lt;br /&gt;&lt;span&gt;    &lt;/span&gt;for(coursein Number)&lt;br /&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;    &lt;/span&gt;printf("\%-10s %d\n", course, Number[course] )&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre&gt;---------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt;comment:&lt;br /&gt;a. NF=4 in this case, line number&lt;br /&gt;b. END is a AWK之保留字, 為{ Pattern}之一種, like BEGIN. The only difference is END only run after all lines are proceeded, while BEGIN works initially before the script, and only one time (both BEGIN and END).&lt;br /&gt;c. $i represents the ith elements in the line array, which is different from Perl program (in which, the $i is a variable name, in AWK, variable name cannot begin with $.)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4. Shell command and awk command&lt;/b&gt;&lt;br /&gt;for example:&lt;br /&gt;&lt;pre&gt;&lt;pre&gt;---------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt; &lt;span style="font-family: courier new,monospace;"&gt;BEGIN { &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt; while ( "who" | getline ) n++ &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt; print n &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt; }&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre&gt;---------------------------------------&lt;br /&gt;where the who is a system command used in shell, and the getline is an awk command for input;&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;5. Filename in the script should be quoted by "", &lt;/b&gt;&lt;br /&gt;for example,&lt;br /&gt;&lt;pre&gt;&lt;pre&gt;---------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;span style="font-family: courier new,monospace;"&gt;BEGIN { &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;    print `` ID Number Arrival Time'' &gt; ``today_rpt1''&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;    print ``==========================='' &gt; ``today_rpt1''&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt; } &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt; { printf(" %s %s\n", $1,$2 ) &gt; "today_rpt1" } &lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre&gt;---------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt; $awk -f reformat1.awk arr.dat&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;&lt;b&gt;a. &lt;/b&gt;if today_rpt1 is not quoted by "", then it will be taken as a variable (which default value is 0, or Null String in AWK.)&lt;br /&gt;&lt;b&gt;b.&lt;/b&gt; the redirection mark is '&gt;', not '&gt;&gt;‘, even you want to append to the end of the file. The only difference between them is, for '&gt;&gt;', it will append to the end of the file if it's open first time and the file exists. For '&gt;', AWK will create a new file when it occurs first time, then append to the end (like '&gt;&gt;'). This is little bit different from Unix.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;6. Input and output command in Awk&lt;/b&gt;&lt;br /&gt;AWK input command: getline&lt;br /&gt;AWK output command: print, printf&lt;br /&gt;&lt;br /&gt;&lt;b&gt;7. three ways to run awk&lt;/b&gt;&lt;br /&gt;a. &lt;span style="font-family: courier new,monospace;"&gt;$awk '{print}' file1.txt file2.txt&lt;/span&gt;&lt;br /&gt;b. &lt;span style="font-family: courier new,monospace;"&gt;$awk -f myscript.awk file1.txt file2.txt&lt;/span&gt;&lt;br /&gt;save &lt;u&gt;&lt;i&gt;{print}&lt;/i&gt;&lt;/u&gt; into a file(myscript.awk) first&lt;br /&gt;c. &lt;span style="font-family: courier new,monospace;"&gt;$myshell file1.txt file2.txt&lt;/span&gt;&lt;br /&gt;save &lt;u&gt;&lt;i&gt;awk '{print}' $*&lt;/i&gt; &lt;/u&gt;into a shell file(named myshell. Here $* means all parameters after the shell command. You also can use $1 represents the first parameter, and $2 the second one.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;8. FS(Field Separator) and RS(Record Separator)&lt;/b&gt;&lt;br /&gt;By default, the FS is any empty character (space, \t, ), RS is newline '\n'. But they can be changed, like&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre&gt;--------------------------------------- make_report.awk -------------------------&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;span style="font-family: courier new,monospace;"&gt;BEGIN {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;        FS = "\n"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;        RS = ""&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;        split( "一. 二. 三. 四. 五. 六. 七. 八. 九.", C_Number, " " )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;        printf("\n%s 報告人 : %s \n",C_Number[NR],$1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;        for( i=2; i&lt;= NF; i++)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;        printf(" %d. %s\n", i-1, $i)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new,monospace;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre&gt;--------------------------------------- week.rpt ------------------------------&lt;br /&gt;&lt;br /&gt;張長弓&lt;br /&gt;&lt;br /&gt;GNUPLOT 入門&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;吳國強&lt;br /&gt;&lt;br /&gt;Latex 簡介&lt;br /&gt;&lt;br /&gt;VAST-2 使用手冊&lt;br /&gt;&lt;br /&gt;mathematica 入門&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;李小華&lt;br /&gt;&lt;br /&gt;AWK Tutorial Guide Regular Expression&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;pre&gt;--------------------------------------- Output ------------------------&lt;/pre&gt;[xianjund@douglasgran data]$ awk -f make_report week.rpt&lt;br /&gt;&lt;br /&gt;一. 報告人 : 張長弓&lt;br /&gt;1. GNUPLOT    入門&lt;br /&gt;&lt;br /&gt;二. 報告人 : 吳國強&lt;br /&gt;1. Latex 簡介&lt;br /&gt;2. VAST-2 使用手冊&lt;br /&gt;3. mathematica 入門&lt;br /&gt;&lt;br /&gt;三. 報告人 : 李小華&lt;br /&gt;1. AWK Tutorial Guide Regular Expression&lt;br /&gt;&lt;pre&gt;&lt;pre&gt;---------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-weight: bold; font-family: times new roman;"&gt;9. ARGC and ARGV[]&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;like C, but&lt;br /&gt;a. ARGC does not include the -v, -f and their options. for example, in &lt;br /&gt;$awk -vx=36 -f program1 data1 data2&lt;br /&gt;or&lt;br /&gt;$awk '{ print $1 ,$2 }' data1 data2&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt;ARGC=3&lt;br /&gt;ARGV[0]= "awk"&lt;br /&gt;ARGV[1]="data1"&lt;br /&gt;ARGV[2]="data2"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-3899265028627730123?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/3899265028627730123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=3899265028627730123' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3899265028627730123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3899265028627730123'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2008/09/awk-learning-note.html' title='AWK learning note'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-3733006848328893213</id><published>2008-09-09T16:10:00.000-07:00</published><updated>2008-09-09T16:17:32.710-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='graphic'/><title type='text'>png to ico</title><content type='html'>How to convert PNG to ICO icon file?&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. download the png2ico source code&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.winterdrache.de/freeware/png2ico/"&gt;http://www.winterdrache.de/freeware/png2ico/&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2. install&lt;/div&gt;&lt;div&gt;tar, cd, then make&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3. prepare resized png, for example&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;convert image.png -resize 32x32 image.icon.png&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4. png2ico&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;png2ico favicon.ico image.icon.png&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You also can make an icon with multiple solution images, use&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;png2ico favicon.ico image.16x16.icon.png image.32x32.icon.png&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-3733006848328893213?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/3733006848328893213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=3733006848328893213' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3733006848328893213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3733006848328893213'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2008/09/png-to-ico.html' title='png to ico'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-5785039288278573423</id><published>2008-09-09T16:06:00.000-07:00</published><updated>2008-09-09T16:09:18.275-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='rev'/><title type='text'>reverse lines of file</title><content type='html'>use &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;rev filename&lt;/span&gt;&lt;/span&gt;. For example,&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;[xianjund@douglasgran hypotest]$ head test11.data &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;ENSG00000007372 ENSG00000109911 ENSG00000121690&lt;/div&gt;&lt;div&gt;ENSG00000007372 ENSG00000149100 ENSG00000170959&lt;/div&gt;&lt;div&gt;ENSG00000043355 ENSG00000175198 ENSG00000102452&lt;/div&gt;&lt;div&gt;ENSG00000172845 ENSG00000115840 ENSG00000091428&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;[xianjund@douglasgran hypotest]$ rev test11.data&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;09612100000GSNE 11990100000GSNE 27370000000GSNE&lt;/div&gt;&lt;div&gt;95907100000GSNE 00194100000GSNE 27370000000GSNE&lt;/div&gt;&lt;div&gt;25420100000GSNE 89157100000GSNE 55334000000GSNE&lt;/div&gt;&lt;div&gt;82419000000GSNE 04851100000GSNE 54827100000GSNE&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It's cool, hmm?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-5785039288278573423?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/5785039288278573423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=5785039288278573423' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/5785039288278573423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/5785039288278573423'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2008/09/reverse-lines-of-file.html' title='reverse lines of file'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-7870153446033699411</id><published>2008-09-09T15:37:00.000-07:00</published><updated>2008-09-09T15:44:22.070-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='grep'/><title type='text'>to show multi line around grep result</title><content type='html'>You can grep multiple lines before or after matching the keywords. Here is a simple tips, that what I discover grep capable of. A is after, B is before.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For example, test.data is like this:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;ENSG00000007372 ENSG00000109911 ENSG00000121690&lt;/div&gt;&lt;div&gt;ENSG00000007372 ENSG00000149100 ENSG00000170959&lt;/div&gt;&lt;div&gt;ENSG00000043355 ENSG00000175198 ENSG00000102452&lt;/div&gt;&lt;div&gt;ENSG00000172845 ENSG00000115840 ENSG00000091428&lt;/div&gt;&lt;div&gt;ENSG00000172845 ENSG00000138430 ENSG00000128708&lt;/div&gt;&lt;div&gt;ENSG00000103449 ENSG00000103494 ENSG00000121274&lt;/div&gt;&lt;div&gt;ENSG00000104313 ENSG00000182674 ENSG00000140396&lt;/div&gt;&lt;div&gt;ENSG00000117707 ENSG00000136643 ENSG00000143499&lt;/div&gt;&lt;div&gt;ENSG00000121297 ENSG00000105176 ENSG00000178904&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&gt;grep ENSG00000138430  test.data &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;ENSG00000172845 ENSG00000115840 ENSG00000091428&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;while,&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&gt;grep ENSG00000138430  test.data -B1 -A3&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;ENSG00000172845 ENSG00000115840 ENSG00000091428&lt;/div&gt;&lt;div&gt;ENSG00000172845 ENSG00000138430 ENSG00000128708&lt;/div&gt;&lt;div&gt;ENSG00000103449 ENSG00000103494 ENSG00000121274&lt;/div&gt;&lt;div&gt;ENSG00000104313 ENSG00000182674 ENSG00000140396&lt;/div&gt;&lt;div&gt;ENSG00000117707 ENSG00000136643 ENSG00000143499&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-7870153446033699411?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/7870153446033699411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=7870153446033699411' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/7870153446033699411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/7870153446033699411'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2008/09/to-show-multi-line-around-grep-result.html' title='to show multi line around grep result'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-3956553186795134250</id><published>2008-09-09T15:18:00.000-07:00</published><updated>2008-09-09T15:45:02.636-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='grep'/><category scheme='http://www.blogger.com/atom/ns#' term='egrep'/><title type='text'>grep based on multiple words</title><content type='html'>For example, grep "you" and "me" in the file,&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;grep "you\|me" filename&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 16px; font-family:Arial;font-size:13px;"&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;You need to put ESCAPE STRING ( \ ) for OR ( | ), else it will treat it as a simbol you want to search instead of regular expression symbol.&lt;/span&gt;&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;or&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;grep -E "you|me" filename&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;or&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;egrep "you|me" filename&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" font-weight: bold;font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;But, to get line with both "you" and "me", you can use&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;grep "you" filename | grep "me"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;or, &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;egrep "you.*me" filename&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;but this will include those lines like "your lovely meebo", which is not what we want sometime. So, to get the exact words matched, use&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;egrep "\&lt;you\&gt;&lt;/you\&gt;&lt;/span&gt;&lt;/span&gt;&lt;you\&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;.*\&lt;me\&gt;&lt;/me\&gt;&lt;/span&gt;&lt;/span&gt;&lt;me\&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;" filename&lt;/span&gt;&lt;/span&gt;&lt;/me\&gt;&lt;/you\&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For more info about egrep, use "man egrep"&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;The caret ^ and the dollar sign $ are metacharacters that respectively match the  empty  string  at  the beginning and end of a line.  The symbols \&lt;&gt; respectively match the empty string at the beginning  and end of a word.  The symbol \b matches the empty string at the edge of a word,  and  \B  matches  the  empty string provided it not at the edge of a word.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-3956553186795134250?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/3956553186795134250/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=3956553186795134250' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3956553186795134250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/3956553186795134250'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2008/09/grep-based-on-multiple-words.html' title='grep based on multiple words'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-5581608934818539772</id><published>2008-09-09T15:11:00.000-07:00</published><updated>2008-09-09T15:45:33.390-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='perl_command'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='sed'/><title type='text'>replace word in a file</title><content type='html'>&lt;span class="Apple-style-span"   style="  ;font-family:Arial;font-size:12px;"&gt;&lt;p   style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;   line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; font-family:Arial, Helvetica, sans-serif;font-size:13px;"&gt;To replace a word in a file, use&lt;/p&gt;&lt;p face="Arial, Helvetica, sans-serif" size="13px" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;   line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;&lt;span class="Apple-style-span"  style=" line-height: normal; font-size:12px;"&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt;perl -pi -e 's/abc/def/;' xyz&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;p face="Arial, Helvetica, sans-serif" size="13px" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;   line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;or&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;&lt;span class="Apple-style-span"  style=" line-height: normal; font-size:12px;"&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt;sed -e 's/abc/def/;' xyz &gt; xyz_new&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;To make the replacement in place, use sed -i filename. then the file will be replaced after the command.&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;&lt;span class="Apple-style-span"  style=" line-height: normal; font-size:12px;"&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt;sed -e 's/abc/def/;' -i xyz&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-5581608934818539772?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/5581608934818539772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=5581608934818539772' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/5581608934818539772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/5581608934818539772'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2008/09/replace-word-in-file.html' title='replace word in a file'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-6038665054745107338</id><published>2008-09-09T14:45:00.000-07:00</published><updated>2008-09-09T15:46:25.597-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='tee'/><category scheme='http://www.blogger.com/atom/ns#' term='redirect'/><title type='text'>HOW TO REDIRECT OUTPUT TO A FILE AS WELL AS DISPLAY IT OUT</title><content type='html'>&lt;span class="Apple-style-span"   style="  ;font-family:Arial;font-size:12px;"&gt;&lt;p face="Arial, Helvetica, sans-serif" size="13px" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;   line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;To redirect standard output to a file is easy, you just need to use the redirection symbol, for example:&lt;/p&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt;echo "hello world" &gt; test.txt&lt;/code&gt;&lt;/pre&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;But what if I want to display it out as well as store into a file?&lt;br /&gt;Answer: tee&lt;/p&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt;echo "hello world" | tee test.txt&lt;/code&gt;&lt;/pre&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;Okay it seems very easy, how about append?&lt;br /&gt;&lt;span id="more-349" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;To append the standard output to a file, you do this:&lt;/p&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt;echo"hello world" &gt;&gt; test.txt&lt;/code&gt;&lt;/pre&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;Append to file and display it out as well?&lt;/p&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt;echo"hello world" | tee -a test.txt&lt;/code&gt;&lt;/pre&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;Okay, how about dealing with standard output(stdout) and standard error(stderr)?&lt;br /&gt;There are two different output stream, one is stdout and another one is stderr. Normal print usually goes to stdout and error related message will goes to stderr. Lets make a simple python script to print 1 line to stdout and 1 line to stderr.&lt;/p&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt;#!/usr/bin/env python  import sys  sys.stdout.write("I am stdout\n") sys.stderr.write("I am stderr\n") &lt;/code&gt;&lt;/pre&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;Ok, lets save the python script as sout.py and try to redirect the output to a file.&lt;/p&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt;$ ./sout.py &gt; test.txt I am stderr &lt;/code&gt;&lt;/pre&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;Standard output is redirect to test.txt but stderr is print out.&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;What if I want stderr to be redirect and display the stdout?&lt;/p&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt; ./sout.py 2&gt; test.txt&lt;/code&gt;&lt;/pre&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;I want both stored into the file.&lt;/p&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt; ./sout.py 2&amp;amp;&gt; test.txt&lt;/code&gt;&lt;/pre&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;At last, I want both display and redirect to a file:&lt;/p&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; display: block; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(170, 170, 170); border-right-color: rgb(170, 170, 170); border-bottom-color: rgb(170, 170, 170); border-left-color: rgb(170, 170, 170); width: 95%; overflow-x: auto; overflow-y: auto; background-position: initial initial; "&gt;&lt;code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'courier new', courier, monospace; font-size: 13px; "&gt; ./sout.py 2&gt;&amp;amp;1 | tee test.txt&lt;/code&gt;&lt;/pre&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: rgb(0, 0, 0); padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 15px; "&gt;Interesting isn’t it?&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-6038665054745107338?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/6038665054745107338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=6038665054745107338' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/6038665054745107338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/6038665054745107338'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2008/09/how-to-redirect-output-to-file-as-well.html' title='HOW TO REDIRECT OUTPUT TO A FILE AS WELL AS DISPLAY IT OUT'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12445049.post-4696865903942118516</id><published>2008-09-09T14:34:00.000-07:00</published><updated>2008-09-09T14:36:17.810-07:00</updated><title type='text'>Openning test</title><content type='html'>Hope I can insist on sharing my learning points with all, in HTML, Perl, Unix/Linux and Bioinformatics :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12445049-4696865903942118516?l=onetipperday.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onetipperday.blogspot.com/feeds/4696865903942118516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12445049&amp;postID=4696865903942118516' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4696865903942118516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12445049/posts/default/4696865903942118516'/><link rel='alternate' type='text/html' href='http://onetipperday.blogspot.com/2008/09/openning-test.html' title='Openning test'/><author><name>Xianjun</name><uri>http://www.blogger.com/profile/15082286110724457588</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/-yWokk0e61wM/TWSA51BcvMI/AAAAAAAAHUQ/zYztCEDgXaY/s220/xianjun_small2.jpg'/></author><thr:total>0</thr:total></entry></feed>
