tag:blogger.com,1999:blog-76146303762984506912024-03-18T21:19:25.380-07:00Information Nuggets for Referencepsaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.comBlogger62125tag:blogger.com,1999:blog-7614630376298450691.post-3620330887222537262016-04-28T16:48:00.000-07:002016-05-04T14:56:10.269-07:00Saving Google Docs/Sheets charts as PDF<div dir="ltr" style="text-align: left;" trbidi="on">
Google docs natively supports saving charts as PNG. But if you want to generate high quality images, such as PDF, you can follow the steps below.<br />
<br />
1. Go to the Google Spreadsheet page with the chart<br />
2. Open Chrome Developer Tools (from Chrome hamburger menu -- 3 lines menu -- on the top right)<br />
3. Select the "Elements" tab and click on the button "Select an element to inspect it" present on the top left.<br />
4. Click in the chart area.<br />
5. Look at the tree and find the beginning of svg description (e.g. <svg...).<br />
6. Right click on the SVG line and select "Copy as HTML"<br />
7. Paste it to your favorite editor, and save as "MyChart.svg"<br />
<br />
You can use image processing tools, such as Photoshop or GIMP to export the files as PDF.<br />
<br />
References:<br />
1. <a href="http://www.osmanoglu.org/computing/89-how-to-export-google-spreadsheet-charts-as-svg">http://www.osmanoglu.org/computing/89-how-to-export-google-spreadsheet-charts-as-svg</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-34680945769890973602015-11-24T17:25:00.000-08:002015-11-24T17:25:16.497-08:00R: MIssing legend when using scale_fill_manual <div dir="ltr" style="text-align: left;" trbidi="on">
When configuring ggplot using scale_fill_manual in R, sometimes the legend might not be displayed. This happens when we specify 'breaks' property within the scale_fill_manual command, and the values we supply don't correspond to the factor levels we use in fill.<br />
<br />
For instance, assume we have a data frame with columns 'X', 'Y', and 'Type', where 'Type' contains values 'A' and 'B'. In the below ggplot/ggplot2 command, breaks argument cannot contain a list of strings which do not map to factor levels in column 'Type':<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>ggplot2(data=df, aes(x=X, y=Y, fill=Type)) +
scale_fill_manual(values=c("black","red", name="Type", breaks=c("A","B"), labels=c("Type-A","Type-B"))
</code></pre>
<br />
Instead, we need to specify the breaks as:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>ggplot2(data=df, aes(x=X, y=Y, fill=Type)) +
scale_fill_manual(values=c("black","red", name="Type", breaks=levels(factor(df$Type)), labels=c("Type-A","Type-B"))
</code></pre>
<br />
Or as below, if we are sure of the factor ordering:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>ggplot2(data=df, aes(x=X, y=Y, fill=Type)) +
scale_fill_manual(values=c("black","red", name="Type", labels=c("Type-A","Type-B"))
</code></pre>
<br />
References:<br />
1. <a href="http://stackoverflow.com/questions/14546858/missing-legend-when-combining-scale-fill-manual-and-scale-x-discrete-in-bar-char">http://stackoverflow.com/questions/14546858/missing-legend-when-combining-scale-fill-manual-and-scale-x-discrete-in-bar-char</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com1tag:blogger.com,1999:blog-7614630376298450691.post-50248996732083276382015-09-23T21:50:00.000-07:002015-09-23T21:50:08.798-07:00Windows 7 Safe mode - Starting "Run Installer" and "Print Spooler" services<div dir="ltr" style="text-align: left;" trbidi="on">
Windows Installer will not work under Safe Mode, this means that programs cannot be installed or uninstalled in safe mode without giving a specific command using msiexec in command prompt.<br />
<br />
To make Windows Installer work under safe mode, you need to create a registry entry for every type of safe mode you are logged in to.<br />
<br />
Run these commands from command line:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer" /VE /T REG_SZ /F /D "Service"
</code></pre>
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>net start msiserver
</code></pre>
<br />
<hr />
To Start Print Spooler<br />
Method-1:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>REG ADD HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\Spooler /VE /T REG_SZ /F /D Service
</code></pre>
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>Net Start Spooler
</code></pre>
<br />
Method-2:<br />
Run Command prompt in administrator mode (right click and press "Run as Administrator"), and then run these commands.<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>Net stop spooler
sc config spooler depend= RPCSS
Net start spooler
exit
</code></pre>
<br />
Reference:<br />
1. <a href="http://www.symantec.com/connect/blogs/windows-installer-safe-mode">http://www.symantec.com/connect/blogs/windows-installer-safe-mode</a><br />
2. <a href="https://forums.techguy.org/threads/solved-enabling-print-spooler-in-safe-mode.1056317/">https://forums.techguy.org/threads/solved-enabling-print-spooler-in-safe-mode.1056317/</a><br />
3. <a href="http://www.techsupportall.com/solved-print-spooler-error-1068-the-dependency-service-or-group-failed-to-start/">http://www.techsupportall.com/solved-print-spooler-error-1068-the-dependency-service-or-group-failed-to-start/</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-9302120911725620862015-05-06T17:54:00.001-07:002015-05-06T17:54:57.163-07:00Latex to Word<div dir="ltr" style="text-align: left;" trbidi="on">
References:<br />
1. http://www.lsnl.jp/~ohsaki/research/linux-tips/tex2word/<br />
2. http://www.chikrii.com/products/tex2word/</div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-69179806134854251152015-05-06T17:54:00.000-07:002015-06-05T10:48:27.757-07:00R Plotting resources<div dir="ltr" style="text-align: left;" trbidi="on">
Changing the legend symbols or keys, without changing the plot<br />
1. <a href="http://stackoverflow.com/questions/16356052/control-ggplot2-legend-look-without-affecting-the-plot">http://stackoverflow.com/questions/16356052/control-ggplot2-legend-look-without-affecting-the-plot</a><br />
<br />
<br />
Changing the "par" settings<br />
1. <a href="http://groups.linguistics.northwestern.edu/speech_comm_group/documents/Presentation_par_cex.pdf">http://groups.linguistics.northwestern.edu/speech_comm_group/documents/Presentation_par_cex.pdf</a><br />
<br />
Dendrogram<br />
1. <a href="http://rpubs.com/gaston/dendrograms">http://rpubs.com/gaston/dendrograms</a><br />
<br />
Changing Legend<br />
1. <a href="https://kohske.wordpress.com/2010/12/25/various-position-adjustments-of-legend-in-ggplot2/">https://kohske.wordpress.com/2010/12/25/various-position-adjustments-of-legend-in-ggplot2/</a><br />
2. <a href="https://github.com/hadley/ggplot2/wiki/Legend-Attributes">https://github.com/hadley/ggplot2/wiki/Legend-Attributes</a><br />
<br />
geom_text<br />
1. hjust and vjust commands: <a href="http://stackoverflow.com/questions/7263849/what-do-hjust-and-vjust-do-when-making-a-plot-using-ggplot">http://stackoverflow.com/questions/7263849/what-do-hjust-and-vjust-do-when-making-a-plot-using-ggplot</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-53701128007053366562014-12-27T11:11:00.001-08:002014-12-27T11:17:08.500-08:00Activate/Enable Sound in Windows 7 Safemode<div dir="ltr" style="text-align: left;" trbidi="on">
Here are the sequence of steps. For full steps refer the reference [1].<br />
<br />
<ol style="text-align: left;">
<li>Run (Win key+R key) regedit</li>
<li>Press Ctrl+F</li>
<ol>
<li>Make sure "Keys", "Values", and "Data" are all selected</li>
<li>Type in Sound, video and game controllers</li>
<li>Click [Find Next]</li>
</ol>
<li>Take note of the branch address in the status bar at the bottom (it will be something like HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E96C-E325-11CE-BFC1-09002BE10318})</li>
<li>Copy the device-driver GUID (the long numeric part between braces) and paste it somewhere like Notepad</li>
<li>Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network</li>
<li>Create a new key (right-click, select New → Key)</li>
<ol>
<li>Copy the GUID you saved and paste it into the key name</li>
<li>Edit the (Default) value and type Sound, video and game controllers</li>
</ol>
<li>Create several new keys (under Network) called AudioEndpointBuilder, MMCSS and Audiosrv</li>
<li>Edit the (Default) values of each of the new keys and type Service</li>
<li>Reboot (you’ll boot into safe-mode)</li>
<li>Open the Services snap-in (Win key+R key → services.msc)</li>
<ol>
<li>Search for "Multimedia Class Scheduler", "Windows Audio Endpoint Builder", and "Windows Audio Service services", and check if they are automatically turned on (they should be). If not start them. </li>
</ol>
</ol>
References:<br />
1. http://superuser.com/questions/354325/how-to-enable-audio-in-safe-mode<br />
<br /></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com1tag:blogger.com,1999:blog-7614630376298450691.post-65905449674241053452014-10-30T12:42:00.001-07:002014-10-30T12:42:38.522-07:00Latex: Underlining text along with adjacent white space<div dir="ltr" style="text-align: left;" trbidi="on">
To underline text in latex we use \underline{...}.<br />
In cases when we need to underline text and the adjoining whitespace (before and after the text), like in situations of having a filled form, we can use the \makebox command as below:<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\underline{\makebox[2.5in][l]{Jane Doe}}
</code></pre>
<br />
Reference:<br />
1. http://www.latex-community.org/forum/viewtopic.php?f=44&t=5162</div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-86558275129148482782014-10-11T11:05:00.000-07:002014-10-11T11:05:25.853-07:00Latex: Centering text in a table row when there is a image<div dir="ltr" style="text-align: left;" trbidi="on">
When you are embedding images in a Latex table, often the text gets aligned to the bottom of the row, and the image decides the height of the row. To align the text in the columns to be vertically centered we have two options, as discussed in references [1][2][3][4].<br />
<h4 style="text-align: left;">
Solution 1</h4>
Vertically centering cell entries is possible via the m{<width>} column type from the array package. Horizontal centering is obtained by prepending the column entries with \centering\arraybackslash (also supported by array). As described in [2], you can defines a new column type M which does all of the above:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\usepackage{array}
\newcolumntype{M}{>{\centering\arraybackslash}m{\dimexpr.25\linewidth-2\tabcolsep}}
</code></pre>
And use can use it in a table as:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\begin{tabular}{|M|M|M|M|}
</code></pre>
<br />
Or as described in [4], we can also define a new column type C as follows:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}</code></pre>
<h4 style="text-align: left;">
Solution 2</h4>
Another simpler solution is to raise the baseline of the image, as text in a row is aligned to the image's baseline. The baseline of an image is at the bottom. You could use \raisebox to shift it up. Use half of \height, which stands for the height of the box to be raised.<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\raisebox{-.5\height}{\includegraphics{some_picture}}
</code></pre>
<br />
You can use it in a table as follows:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\begin{tabular}{lll}
\raisebox{-.5\height}{\includegraphics[scale=0.25]{example-image}} & text & text\\
\end{tabular}
</code></pre>
<br />
References:<br />
1. http://stackoverflow.com/questions/1357798/how-to-center-cell-contents-of-a-latex-table-whose-columns-have-fixed-widths<br />
2. http://tex.stackexchange.com/questions/46386/vertically-center-cells-of-a-table<br />
3. http://tex.stackexchange.com/questions/19080/how-to-vertically-center-text-with-an-image-in-the-same-row-of-a-table<br />
4. http://www.latex-community.org/forum/viewtopic.php?f=45&t=15908</div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-74975458558993152212014-10-11T10:22:00.000-07:002014-10-11T10:22:42.166-07:00Latex: Image in a table overlaps the row separator line<div dir="ltr" style="text-align: left;" trbidi="on">
When embedding images in Latex tables, you may find that the images will overlap with the horizontal line above its row. Like described by Stefan Kottwitz in [1], it looks like:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZ2uhO17bXQ_49vUuRVm-oWuzAhnfCOpuWJNk87na2SySRqIlVRJe7ryKMlaYa5etGKtJvbrqpipwaUm1Mux82glHhpZ60FNqn8_P5PI7XenxUeYGz-DIiz7g_yLSOb_9Lnrq600UMGdY/s1600/8KZ3G.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZ2uhO17bXQ_49vUuRVm-oWuzAhnfCOpuWJNk87na2SySRqIlVRJe7ryKMlaYa5etGKtJvbrqpipwaUm1Mux82glHhpZ60FNqn8_P5PI7XenxUeYGz-DIiz7g_yLSOb_9Lnrq600UMGdY/s1600/8KZ3G.png" height="174" width="320" /></a></div>
<br />
To avoid this problem, the easiest solution is to use the "trim" parameter of the includegraphics command. The trim option takes four lengths as argument, specifying the amount to remove or add to each side. trim= 1 2 3 4 would "crop" the picture by 1bp at the left, 2bp at the bottom, 3bp on the right and 4bp at the top.<br />
<br />
To add some spacing at the top, we can use a negative value as shown below:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\includegraphics[trim=0 0 0 -5]{figure.jpg}
</code></pre>
<br />
In case multiple parameters are to be specified, such as "width", we can do it as follows:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\includegraphics[trim=0 0 0 -5,width=0.2\textwidth]{figure.jpg}
</code></pre>
<br />
References:<br />
1. http://tex.stackexchange.com/questions/41788/image-in-table-covers-horizontal-line-above-it</div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-49339726660472561862014-08-16T22:50:00.001-07:002014-08-16T22:50:31.491-07:00Using embedded fonts in eps graphs generated using gnuplot <div dir="ltr" style="text-align: left;" trbidi="on">
When submitting camera ready versions to conferences/journals, you might come across a requirement where all the fonts (including those used in the EPS/PDF figures) should be embedded in the PDF.<br />
<br />
To use embedded fonts in graphs generated using gnuplot, we need to use the font file used by MIKTEX (on windows) or its equivalent on Linux. In the below example, we use the "NimbusSanL-Regu" embedded font available in the ".pfb" file in the fonts folder in the Miktex installation directory (something like ...\Program Files\MiKTeX 2.7\fonts\type1\urw\helvetic\).<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>set terminal postscript eps enhanced "NimbusSanL-Regu" 12 fontfile "uhvr8a.pfb"
set output 'filename.eps'
</code></pre>
<br />
When using the ".pfb" file you might come across an error in Gnuplot like:<br />
"Automatic font conversion pfb->pfa not supported"<br />
<br />
For this you can convert the pfb file to pfa file using tools like "pfbtops" (supports on-the-fly conversion to .pfa type) or "pfb2pfa" (if on-the-fly is not needed and you need the .pfa file output). There is also an online service (<a href="http://everythingfonts.com/pfb-to-pfa">http://everythingfonts.com/pfb-to-pfa</a>) that can generate the pfa file.<br />
<br />
Once the .pfa file is generated, you can use it in the same format.<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 653px;"><code>set terminal postscript eps enhanced "NimbusSanL-Regu" 12 fontfile "uhvr8a.pfa"
</code></pre>
<div>
<code><br /></code></div>
References:<br />
1. <a href="http://www.cepe.ethz.ch/howtodos/embed_fonts">http://www.cepe.ethz.ch/howtodos/embed_fonts</a><br />
2. <a href="http://everythingfonts.com/pfb-to-pfa">http://everythingfonts.com/pfb-to-pfa</a><br />
3. <a href="http://gnuplot.sourceforge.net/docs_4.2/node413.html">http://gnuplot.sourceforge.net/docs_4.2/node413.html</a><br />
<br /></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-49399839690336229072014-07-24T14:19:00.000-07:002014-07-24T14:19:00.728-07:00Latex 'pdfpagelabels' turned off when using Hyperref<div dir="ltr" style="text-align: left;" trbidi="on">
I received the following error when using ACM's sig-alternate.cls style file and using the PDFLatex command.<br />
<br />
<b><i>Error:</i></b><br />
Package hyperref Warning: Option `pdfpagelabels' is turned off<br />
hyperref because \thepage is undefined.<br />
<br />
That seems to be caused by an update of the hyperref package. The workaround is to switch this option off.<br />
Instead of using:<br />
<pre><span style="color: maroon;">\usepackage</span>{hyperref}</pre>
<pre><span style="font-family: 'Times New Roman'; white-space: normal;">
</span></pre>
<br />
Use:
<br />
<pre><span style="color: maroon;">\PassOptionsToPackage</span>{pdfpagelabels=true}{hyperref}</pre>
<br />
References:<br />
1. http://www.latex-community.org/forum/viewtopic.php?f=5&t=162</div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com1tag:blogger.com,1999:blog-7614630376298450691.post-69587755670993242392014-07-16T20:13:00.000-07:002014-07-16T20:15:54.158-07:00Gnuplot pdf terminal dashed lines<div dir="ltr" style="text-align: left;" trbidi="on">
To set pdf terminal in Gnuplot, check if the output of command "<span style="background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 17.804800033569336px; white-space: inherit;">print GPVAL_TERMINALS</span>" contains "pdfcairo" listed. If yes, then you can set the terminal output as PDF using the command<br />
<br />
<pre style="background: rgb(238, 238, 238); border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;">set terminal pdf
set output 'out.pdf'</code></pre>
<br />
To enables dashed lines when using PDF terminal in gnuplot, as pointed out in reference [1], set the terminal using the command below<br />
<br />
<pre style="background: rgb(238, 238, 238); border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;">set terminal pdf monochrome dashed
set output 'out.pdf'</code></pre>
<br />
References:<br />
1. http://theletterpsi.blogspot.com/2010/11/setting-dashed-line-style-on-pdf.html<br />
2. http://stackoverflow.com/questions/14004797/gnuplot-pdf-output</div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-2452417654737219912014-07-09T11:49:00.000-07:002014-07-09T11:49:39.771-07:00English Word Frequency Lists<div dir="ltr" style="text-align: left;" trbidi="on">
Many might have come across a requirement for reasonable sized English word frequency lists. Here is one good and free word frequency list based on <a href="http://info.ox.ac.uk/bnc">British National Corpus (BNC)</a>. This post is just a pointer to the real resource (Reference 1), but I will copy some text from the reference describing the details about the file structure.<br />
<br />
-----------------------------------------------<br />
These are all available in 6 forms:<br />
<ul>
<li>sorted alphabetically ("al") or by frequency (highest frequency first) ("num");</li>
<li>the complete lists, or a smaller file containing only those items occurring over five times (suffix "o5");</li>
<li>all lists are available compressed using gzip (".gz"). The</li>
</ul>
o5 lists are also available uncompressed (no suffix). The frequencies are for <CLAWS-word, POS> pairs.<br />
For a list and brief descriptions of CLAWS POS-tags, see <a href="http://www.kilgarriff.co.uk/BNClists/poscodes.html">here</a>.<br />
<br />
The format is: four fields, separated by spaces.<br />
<pre> 1: frequency
2: word
3: pos
4: number of files the word occurs in
</pre>
For non-orthographic words, spaces are replaced by underscore, giving eg "in_spite_of".<br />
Lists are provided for the complete BNC (<tt>all</tt>), and for three subsets, as below:<br />
<pre> cg 'context-governed' spoken material
(eg meetings, lectures etc) 6.2M tokens, 79,906 types
demog 'demographic' spoken material
(eg conversation) 4.2M tokens, 54,652 types
written 89.7M tokens, 921,074 types
all 100.1M tokens, 939,028 types
</pre>
File sizes in MB ("al" and "num" variants all the same size) are:<br />
<pre> all uncompressed .gz o5 o5.gz
-------------------------------------------------------------
all 18.1 4.8 4.0 1.32
cg 1.4 0.39 0.43 0.15
demog 0.9 0.26 0.25 0.09
written 17.8 4.7 3.9 1.30
-------------------------------------------------------------
</pre>
For all.al.gz click <a href="http://www.kilgarriff.co.uk/BNClists/all.al.gz">here</a><br />For all.al.o5 click <a href="http://www.kilgarriff.co.uk/BNClists/all.al.o5">here</a><br />For all.al.o5.gz click <a href="http://www.kilgarriff.co.uk/BNClists/all.al.o5.gz">here</a><br />For all.num.gz click <a href="http://www.kilgarriff.co.uk/BNClists/all.num.gz">here</a><br />For all.num.o5 click <a href="http://www.kilgarriff.co.uk/BNClists/all.num.o5">here</a><br />For all.num.o5.gz click <a href="http://www.kilgarriff.co.uk/BNClists/all.num.o5.gz">here</a><br />For written.al.gz click <a href="http://www.kilgarriff.co.uk/BNClists/written.al.gz">here</a><br />For written.al.o5 click <a href="http://www.kilgarriff.co.uk/BNClists/written.al.o5">here</a><br />For written.al.o5.gz click <a href="http://www.kilgarriff.co.uk/BNClists/written.al.o5.gz">here</a><br />For written.num.gz click <a href="http://www.kilgarriff.co.uk/BNClists/written.num.gz">here</a><br />For written.num.o5 click <a href="http://www.kilgarriff.co.uk/BNClists/written.num.o5">here</a><br />For written.num.o5.gz click <a href="http://www.kilgarriff.co.uk/BNClists/written.num.o5.gz">here</a><br />For cg.al.gz click <a href="http://www.kilgarriff.co.uk/BNClists/cg.al.gz">here</a><br />For cg.al.o5 click <a href="http://www.kilgarriff.co.uk/BNClists/cg.al.o5">here</a><br />For cg.al.o5.gz click <a href="http://www.kilgarriff.co.uk/BNClists/cg.al.o5.gz">here</a><br />For cg.num.gz click <a href="http://www.kilgarriff.co.uk/BNClists/cg.num.gz">here</a><br />For cg.num.o5 click <a href="http://www.kilgarriff.co.uk/BNClists/cg.num.o5">here</a><br />For cg.num.o5.gz click <a href="http://www.kilgarriff.co.uk/BNClists/cg.num.o5.gz">here</a><br />For demog.al.gz click <a href="http://www.kilgarriff.co.uk/BNClists/demog.al.gz">here</a><br />For demog.al.o5 click <a href="http://www.kilgarriff.co.uk/BNClists/demog.al.o5">here</a><br />For demog.al.o5.gz click <a href="http://www.kilgarriff.co.uk/BNClists/demog.al.o5.gz">here</a><br />For demog.num.gz click <a href="http://www.kilgarriff.co.uk/BNClists/demog.num.gz">here</a><br />For demog.num.o5 click <a href="http://www.kilgarriff.co.uk/BNClists/demog.num.o5">here</a><br />For demog.num.o5.gz click <a href="http://www.kilgarriff.co.uk/BNClists/demog.num.o5.gz">here</a><br />
<br />
References:<br />
1. <a href="http://www.kilgarriff.co.uk/bnc-readme.html">http://www.kilgarriff.co.uk/bnc-readme.html</a><br />
<br /></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-24286182281534360242014-06-29T09:33:00.000-07:002014-06-29T09:33:23.697-07:00Python Multiprocess programming - A Pool of Workers<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Python's Global Interpreter Lock prevents multithreading to actually be parallelizable, and sometimes making it much slower than single thread version. To obtain true parallelism, we need to use multiple processes.<br />
<br />
Here is the code to start a certain number of processes, and pass tasks to them through a queue. The done_queue.get() blocking function ensures that the parent process remains active until the child threads finish everything. Once we obtain all the results, we stop the child processes using the "STOP" input (as even the child processes also block on input.get()).<br />
<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>import time
import random
from multiprocessing import Process, Queue, current_process, freeze_support
#
# Function run by worker processes
#
def worker(input, output):
for func, args in iter(input.get, 'STOP'):
result = calculate(func, args)
output.put(result)
#
# Function used to calculate result
#
def calculate(func, args):
result = func(*args)
return '%s says that %s%s = %s' % \
(current_process().name, func.__name__, args, result)
#
# Functions referenced by tasks
#
def mul(a, b):
time.sleep(2*random.random())
return a * b
def plus(a, b):
time.sleep(2*random.random())
return a + b
#
#
#
def test():
NUMBER_OF_PROCESSES = 8
TASKS1 = [(mul, (i, 7)) for i in range(20)]
TASKS2 = [(plus, (i, 8)) for i in range(10)]
# Create queues
task_queue = Queue()
done_queue = Queue()
# Submit tasks
for task in TASKS1:
task_queue.put(task)
# Start worker processes
for i in range(NUMBER_OF_PROCESSES):
Process(target=worker, args=(task_queue, done_queue)).start()
# Get and print results
print 'Unordered results:'
for i in range(len(TASKS1)):
print '\t', done_queue.get()
# Add more tasks using `put()`
for task in TASKS2:
task_queue.put(task)
# Get and print some more results
for i in range(len(TASKS2)):
print '\t', done_queue.get()
# Tell child processes to stop
for i in range(NUMBER_OF_PROCESSES):
task_queue.put('STOP')
if __name__ == '__main__':
freeze_support()
test()
</code></pre>
<b>References: </b><br />
1. https://docs.python.org/dev/library/multiprocessing.html
</div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-60186998509080107212014-04-28T10:13:00.000-07:002014-04-28T10:13:10.462-07:00Microsoft Excel Bar/Column Chart Patterns<div dir="ltr" style="text-align: left;" trbidi="on">
It is possible to create GNUPlot style bar charts with patterns (shown below) in Excel.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxaO7Y7p-vUutYtj1YSOcddTq3p7rZDQ-OR6jVLAKbbI2wzWUp24vYHpkWZr6oLfui7XtWF7taX5NbVx8yaPDMItzHyA5FmWiAFLqBCnbYWGhEXu4L-Y-8PNXCcRARpewUspq9iaUqWkI/s1600/fillstyle.7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxaO7Y7p-vUutYtj1YSOcddTq3p7rZDQ-OR6jVLAKbbI2wzWUp24vYHpkWZr6oLfui7XtWF7taX5NbVx8yaPDMItzHyA5FmWiAFLqBCnbYWGhEXu4L-Y-8PNXCcRARpewUspq9iaUqWkI/s1600/fillstyle.7.png" height="224" width="320" /></a></div>
<br />
<br />
As discussed in Reference 2, for Excel 2007 you need to download the excel macro file "<b><i>Pattern Fill Add-In</i></b>". The usage instructions are provided in Reference 1.<br />
<br />
References:<br />
1. <a href="http://www.andypope.info/charts/patternfills.htm">http://www.andypope.info/charts/patternfills.htm</a><br />
2. <a href="http://answers.microsoft.com/en-us/office/forum/office_2007-excel/excel-2007-bar-chart-shading/99bab79a-e600-4bbe-a08e-448363d3173d">http://answers.microsoft.com/en-us/office/forum/office_2007-excel/excel-2007-bar-chart-shading/99bab79a-e600-4bbe-a08e-448363d3173d</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-52562067061393936482014-04-28T10:07:00.000-07:002014-04-28T10:07:08.933-07:00Microsoft Excel Clustered-Stacked Column/Bar Chart<div dir="ltr" style="text-align: left;" trbidi="on">
We can create clustered-stacked column/bar charts -- like those shown below (taken from Reference 1) -- in Excel. It is doable, but the process involves many steps. Follow the instructions in Reference 1.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg623Mhg3ts95tYjQSBpEa2mIoWigohZOcKf3ybuNfTq-Hu6IfNWKDtX913CfeXG9Wcd4ulGnfDZzEuI-Q8UimXI5b1SjhQgsGKDrHg8OsKFfqgKq7iqFAC2w2RYkLzVawXKxxAiPNifE/s1600/CS_ColBar_18.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg623Mhg3ts95tYjQSBpEa2mIoWigohZOcKf3ybuNfTq-Hu6IfNWKDtX913CfeXG9Wcd4ulGnfDZzEuI-Q8UimXI5b1SjhQgsGKDrHg8OsKFfqgKq7iqFAC2w2RYkLzVawXKxxAiPNifE/s1600/CS_ColBar_18.png" /></a></div>
<br />
At one point, the instructions say - "Copy the range, and use paste special to add this data to the chart as a new series", for this if using Excel 2007 you need to click the 'Home' tab on the ribbon, click the 'Paste' drop-down arrow and choose 'Paste Special'.<br />
<br />
References:<br />
1. <a href="http://peltiertech.com/WordPress/clustered-stacked-column-bar-charts/">http://peltiertech.com/WordPress/clustered-stacked-column-bar-charts/</a><br />
2. <a href="http://www.mrexcel.com/forum/excel-questions/559998-charts-add-new-data-copy-paste-special.html">http://www.mrexcel.com/forum/excel-questions/559998-charts-add-new-data-copy-paste-special.html</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-69470120828193639692014-04-08T04:34:00.000-07:002014-04-08T04:34:53.772-07:00Changing Windows Internet time synchronization frequency<div dir="ltr" style="text-align: left;" trbidi="on">
You might come across situations when you need multiple Windows machines to have their times synchronized. You could setup time synchronization protocols between the machines, making one as the master and the others as slaves.<br />
<br />
An easier alternative is to sync all the machine times to Internet times - the NIST time or Windows server time available by default in the <i>Date & Time</i> settings. Once you sync the machines with the Internet time, the machines might start drifting away over a period. Hence Windows periodically syncs the times with the Internet time; however, the default sync duration ranges from few days to weeks.<br />
<br />
You can make the time sync happen much more frequently - like few hours. To do this, you need to make system registry changes. The following instructions are for Windows XP machine; for other versions, the process might be similar.<br />
<br />
1. Go to Start-> Run and type "regedit" to open the registry settings.<br />
<br />
2. Navigate to the following in the Registry:<br />
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient<br />
<br />
3. The parameter you need to change is <b><i>SpecialPollInterval</i></b><br />
Right click on 'SpecialPollInterval' in the right hand column and select Modify>Decimal. The decimal number is in seconds. For example, you can set it to 86400 to mean 24 hours.<br />
<br />
<b><u>NOTE</u></b>: Please backup the Registry beforehand to avoid any issues later (I do not know how this can be done).<br />
<br />
Reference:<br />
1. <a href="http://www.tomshardware.com/forum/55562-45-changing-frequency-internet-time-synchronisation">http://www.tomshardware.com/forum/55562-45-changing-frequency-internet-time-synchronisation</a> </div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-42522995379668873452014-04-06T03:42:00.002-07:002014-04-06T03:43:41.366-07:00English words present in dictionary for Python use<div dir="ltr" style="text-align: left;" trbidi="on">
A good resource of English words available in English dictionary is <a href="https://wordnet.princeton.edu/">WordNet</a> by Princeton University. Though its primary usage is not for getting the list of English words and their meanings, you can still get that information from WordNet.<br />
<br />
Either you could download the WordNet database and do the parsing yourself (or using other pre-existing Python scripts), or use the NLTK natural language processing toolkit in Python. The toolkit provides instructions for using wordnet at <a href="http://www.nltk.org/howto/wordnet.html">WordNet Interface</a>.<br />
<br />
You could also use the <a href="http://pythonhosted.org/pyenchant/">PyEnchant</a> spell checking library available for Python. Using this you can check whether a word is acceptable as per a specific English dictionary, though you won't get the word meanings.<br />
<br />
As stated in [2], the word coverage in WordNet is not complete, but it is very useful. Depending on the use case, one option can be preferred over the other.<br />
<br />
References:<br />
1. <a href="http://www.velvetcache.org/2010/03/01/looking-up-words-in-a-dictionary-using-python">http://www.velvetcache.org/2010/03/01/looking-up-words-in-a-dictionary-using-python</a><br />
2. <a href="http://stackoverflow.com/questions/3788870/how-to-check-if-a-word-is-an-english-word-with-python">http://stackoverflow.com/questions/3788870/how-to-check-if-a-word-is-an-english-word-with-python</a><br />
3. <a href="http://www.nltk.org/howto/wordnet.html">http://www.nltk.org/howto/wordnet.html</a><br />
4. <a href="http://pythonhosted.org/pyenchant/">http://pythonhosted.org/pyenchant/</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-36131875683121965632014-01-28T04:01:00.001-08:002014-01-28T04:01:46.384-08:00Delete "Not Existing" files in Windows 7<div dir="ltr" style="text-align: left;" trbidi="on">
Sometimes even after we delete a file or move it, its ghost copy might still remain in the original folder. The ghost file might have been created due to a race condition. When we try to delete the file, we get an error stating "Cannot Delete the File, The file does not exist".<br />
<br />
In that case, use a command prompt in windows and navigate to the folder. Use "<span style="background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 17.804800033569336px;">dir /x</span>" command to see if the ghost file is being listed. As per the reference [1], if you can identify the 8.3 format filename in the output, you can use it to delete the file using "del <filename>" command from the prompt. An easier way would be to use wildcard filename to delete the ghost file. The wildcard command might look like "<span style="background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804800033569336px;"> </span><code style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 17.804800033569336px; margin: 0px; padding: 0px; vertical-align: baseline;">del *file.txt</code>".<br />
<br />
<br />
References:<br />
1. <a href="http://superuser.com/questions/388860/cant-delete-files-that-do-not-exist-but-appear-in-my-download-directory">http://superuser.com/questions/388860/cant-delete-files-that-do-not-exist-but-appear-in-my-download-directory</a><br />
<br /></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-67558762998198522962013-11-13T09:41:00.000-08:002013-11-13T09:41:19.873-08:00Latex hyperref, url packages: Break URL<div dir="ltr" style="text-align: left;" trbidi="on">
When using both <b>hyperref</b> and <b>url</b> packages, and you get a package conflict, make sure the <b>url</b> package is listed before the <b>hyperref</b> package.<br />
<br />
Also, if you need to break the URL into multiple lines, then you need to use the <b>hyphens</b> option in the <b>url</b> package. So your latex configuration should look like:<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\usepackage[hyphens]{url}
\usepackage{hyperref}
</code></pre>
<br />
Reference:<br />
1. <a href="http://stackoverflow.com/questions/2625714/linebreak-in-url-with-bibtex-and-hyperref-package">http://stackoverflow.com/questions/2625714/linebreak-in-url-with-bibtex-and-hyperref-package</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-57864332360241894152013-11-07T16:55:00.001-08:002013-11-07T16:55:41.855-08:00Microsoft Excel overlapping Bar charts/Histograms<div dir="ltr" style="text-align: left;" trbidi="on">
Follow Reference 1 to generate bar charts that look like:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://peltiertech.com/WordPress/wp-content/img200810/EBarChart2c.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="198" src="http://peltiertech.com/WordPress/wp-content/img200810/EBarChart2c.png" width="320" /></a></div>
<br />
<br />
Follow Reference 2 to generate bar charts that look like:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://peltiertech.com/WordPress/wp-content/img200810/EBarB4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="198" src="http://peltiertech.com/WordPress/wp-content/img200810/EBarB4.png" width="320" /></a></div>
<br />
<br />
References:<br />
1. <a href="http://peltiertech.com/WordPress/overlapped-bar-chart-longer-bars-in-back/">http://peltiertech.com/WordPress/overlapped-bar-chart-longer-bars-in-back/</a><br />
2. <a href="http://peltiertech.com/WordPress/overlapped-bar-chart-thinner-bars-in-front/">http://peltiertech.com/WordPress/overlapped-bar-chart-thinner-bars-in-front/</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-59367548570599839882013-08-04T10:14:00.001-07:002013-08-04T10:14:22.244-07:00R - commands cheat sheet<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
</div>
To read a text file<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>> data <- read.csv('R - anon answers to total answers.txt',sep=",",header=TRUE)
</code></pre>
<br />
To convert cells (row-column pairs) satisfying a certain condition to NA.<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>> data$Column[data$Column == 0] <- NA
> data$Column[data$Column == -Inf] <- NA
</code></pre>
<br />
To generate a linear model from the data<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>> linear=lm(data[,2]~data[,1])
> polynomial=lm(data[,2]~data[,1]+I(data[,1]^2))
> loglinear=lm(logdata[,2]~logdata[,1])
</code></pre>
<br />
To get a summary of the generated models<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>> summary(linear)
> summary(polynomial)
</code></pre>
<br />
To plot data<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>> plot(data[,1],data[,2])
> plot(data[,2]~data[,1])
> plot(log(data[,1]),log(data[,2])) </code></pre>
<br />
Adding text to plot<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>> text(c(300,300),c(0.8,0.82),labels=c("R^2 = 0.0001","y = 0.00072 * x - 0.163"))
</code></pre>
<br />
To draw the linear model generated using "lm" command<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>> abline(linear)
</code></pre>
<br />
We can draw polynomial curve generated using lm/glm using<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>> lines(sort(x), linear$fitted.values[order(x)])
</code></pre>
<br />
To generate log-linear models using the glm package<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>> glm_test2=glm(data[,2]~data[,1],family=poisson())
> glm_test2=update(glm_test,.~.+I(data[,1]^3),family=poisson())
</code></pre>
<br />
We can compare different linear models generated using lm or glm commands through anova tests. When there are more than 2 models, model-1 is compared to null hypothesis, model-2 with model-1, model-3 with model-2 and so on.<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>> anova(glm_test,glm_test2,glm_test3,glm_test4,glm_test5,glm_test6,glm_test7,glm_test8,glm_test9,glm_test10,test = "Chisq")
</code></pre>
<br />
<br /></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-32225556884632826392013-08-04T09:28:00.000-07:002013-08-04T09:28:21.970-07:00vmware tools copy-paste feature in Ubuntu<div dir="ltr" style="text-align: left;" trbidi="on">
You will need the vmware tools for having the feature to copy-paste feature between the VM and the host machine. Installing vmware tools on an Ubuntu machine was a little tricky.<br />
<br />
You can find the instructions at: <a href="http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1022525">Installing VMware Tools in an Ubuntu virtual machine (1022525)</a><br />
<br />
References:<br />
1. <a href="http://communities.vmware.com/thread/395491?start=0&tstart=0">http://communities.vmware.com/thread/395491?start=0&tstart=0</a><br />
2. <a href="http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1014294">http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1014294</a><br />
3. <a href="http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1022525">http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1022525</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-90883993577391983032013-08-03T12:33:00.002-07:002013-08-03T12:33:35.927-07:00Extract range of lines from text file in unix<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: inherit;">It is possible to use command line sed to</span> easily extract a range of lines from a text file. The command to be used is:<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>sed -n 16224,16482p filename > newfile
</code></pre>
<span style="font-family: inherit;"><br /></span>
<br />
<div style="text-align: left;">
<span style="font-family: inherit;"><span style="background-color: white; font-size: 14px; line-height: 18px;">Where </span></span><span style="background-color: white; font-family: inherit; font-size: 14px; line-height: 18px;">16224,16482 are the start line number and end line number, inclusive. This is 1-indexed. </span></div>
<div style="text-align: left;">
<span style="font-family: inherit;"><code style="background-color: #eeeeee; border: 0px; font-size: 14px; line-height: 18px; margin: 0px; padding: 1px 5px; vertical-align: baseline;">-n</code><span style="background-color: white; font-size: 14px; line-height: 18px;">suppresses echoing the input as output, which you clearly don't want; </span></span><br />
<span style="font-family: inherit;"><span style="background-color: white; font-size: 14px; line-height: 18px;">the numbers indicate the range of lines to make the following command operate on; </span></span><br />
<span style="font-family: inherit;"><span style="background-color: white; font-size: 14px; line-height: 18px;">the command </span><code style="background-color: #eeeeee; border: 0px; font-size: 14px; line-height: 18px; margin: 0px; padding: 1px 5px; vertical-align: baseline;">p</code><span style="background-color: white; font-size: 14px; line-height: 18px;"> prints out the relevant lines.</span></span></div>
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">References:</span><br />
<a href="http://stackoverflow.com/questions/83329/how-can-i-extract-a-range-of-lines-from-a-text-file-on-unix">http://stackoverflow.com/questions/83329/how-can-i-extract-a-range-of-lines-from-a-text-file-on-unix</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com0tag:blogger.com,1999:blog-7614630376298450691.post-73209750649756582212013-08-03T12:28:00.000-07:002013-08-03T12:28:50.845-07:00Motorola Atrix - Unlocking bootloader and reflashing ICS<div dir="ltr" style="text-align: left;" trbidi="on">
I recently tried unlocking the boot loader to load Ice Cream Sandwich onto my Atrix MB860 phone. During the process, I had some difficulties, and wanted to document the steps for future reference (and for other's benefit).<br />
<h4 style="text-align: left;">
Unlocking bootloader</h4>
This webpage(<a href="http://forum.xda-developers.com/showthread.php?t=2230432&highlight=unlock+bootloader">Installing Atrix-MROM on an Atrix 4G with 4.5.145 update</a>) mentioned it is possible to unlock Atrix4G with 2.3.6 Gingerbread and 4.5.145 update using the unlock instructions given here: <a href="http://forum.xda-developers.com/showthread.php?t=1182871">Automatic bootloader UNLOCK/ROOT for AT&T 1.26/1.57/1.83/4.5.91 [UPDATE 07/31/11]</a><br />
<br />
I followed the instructions in <a href="http://forum.xda-developers.com/showthread.php?t=1182871">Automatic bootloader UNLOCK/ROOT for AT&T 1.26/1.57/1.83/4.5.91 [UPDATE 07/31/11]</a>. To unlock I used option-1 (Automatic Bootloader Unlock for ATT ATRIX 4G Only), and then selected the option 3 (4.5.91). It threw a "unable to boot" screen, and gave around 10 options (first option was RSD and second was fastboot, and some others followed) and automatically started the fastboot mode - but windows was not able to recognize the device. Since the instructions on the terminal were asking us to select the fastboot mode by pressing "volume down+power" combo, I removed the battery for 30 seconds and tried it multiple times but the phone was not booting. At last after few trials it booted to fastboot mode. the terminal instructions showed an unlock code and asked me to enter it (probably option3 - Apply FIX for "Failed to boot 0x1000"/ NO OS Users (fastboot) must have been initiated). Later the phone restarted automatically and I reached the "Welcome to MOTOBLUR" screen. During the motorola boot screen, I saw "unlocked" on the top left corner.<br />
<br />
This video should help out too: <a href="http://www.youtube.com/watch?v=S6a0BWquqAc">http://www.youtube.com/watch?v=S6a0BWquqAc</a><br />
<h4 style="text-align: left;">
Flashing ROM</h4>
I then selected "Automatic ROOT/CWM for Unlocked ATT ATRIX 4G Only (Tenfar CWM)" for backing up my old ROM.<br />
<br />
It is to be noted that the cell battery does not get charged while in the boot menu and connected to a power source (either a computer or the power port on the wall). While trying to flash ROM, I received a "Low battery to flash error". For the battery to charge, I need to flash a ROM and flashing was not possible at the moment.<br />
<br />
I purchased an external battery charger like the <a href="http://www.amazon.com/Enercell%C2%AE-Universal-Li-ion-Ni-Cd-Charger/dp/B007MWZC7A">enercell universal external battery charger</a> and charged the battery completely. Now I was able to flash a new ROM.<br />
<br />
I followed the instructions at this <a href="http://forum.xda-developers.com/showthread.php?t=2262869&highlight=soft+brick">XDA forum webpage</a> to solve the soft brick issue during the flash process.<br />
<br />
After launching ICS, I was unable to download apps from playstore. So removed the gmail account and re-added it without sync as per this <a href="http://forums.androidcentral.com/google-nexus-7-tablet/224884-google-play-error-solution-rpc-s-5-aec-0-a.html">forum</a> .<br />
<br />
References:<br />
1. <a href="http://forum.xda-developers.com/showthread.php?t=1182871">http://forum.xda-developers.com/showthread.php?t=1182871</a><br />
2. <a href="http://forum.xda-developers.com/showthread.php?t=2230432&highlight=unlock+bootloader">http://forum.xda-developers.com/showthread.php?t=2230432&highlight=unlock+bootloader</a><br />
3. <a href="http://forum.xda-developers.com/showthread.php?t=2262869&highlight=soft+brick">http://forum.xda-developers.com/showthread.php?t=2262869&highlight=soft+brick</a><br />
4. <a href="http://forums.androidcentral.com/google-nexus-7-tablet/224884-google-play-error-solution-rpc-s-5-aec-0-a.html">http://forums.androidcentral.com/google-nexus-7-tablet/224884-google-play-error-solution-rpc-s-5-aec-0-a.html</a></div>
psaitejahttp://www.blogger.com/profile/06620559074313497145noreply@blogger.com1