Skip to main content

Posts

Showing posts from 2015

Simple tikz example in R

Hi, A useful package if you want to make drawings in R using the tikzDevice package. Another great tool from Yihui. Here I show step by step the installation and how to run some simple code in R to create some pdf's with the help of Miktex, tikz and knitr. Useful document I refered to for minimal tikz commands http://cremeronline.com/LaTeX/minimaltikz.pdf Requirements: 1. Install Miktex. I go for the 64 bit installer. If you choose the portable one then remember to add the paths to your windows paths. 2. Install Rtools 3. Of course install R and RStudio!! Installation: 1. Fire up an R Script in RStudio. 2. Run the following code library(knitr) devtools::install_github( 'yihui/tikzDevice' ) # This is part is required as cran version has a problem when referencing the paths to the Miktex installation require(tikzDevice) tikz('normal.tex', standAlone = TRUE, width=5, height=5) # This is a barbone standalone pdf document which will be compiled int...

Getting RInside to work for you

RInside is a way to get R code working from within C++. Based on the examples from Dirk's book I decided to try this out. I eventually got stuck at several places trying to get it to work. So I just wanted to share with you all steps to get it right the first time. Some of the errors you will face are "R.dll not found" error or the "Fatal Error: unable to open the base package" Important: For RInside to work it is very important that you have all the directories and variables set in the PATH and R_HOME variables. 1. PATH should contain /e/R/R-3.1.3/bin/i386, /c/RBuildTools/3.1/gcc-4.6.3/bin, /c/RBuildTools/3.1/bin 2. R_HOME should equal /e/R/R-3.1.3 3. I am using the MinGW\Msys shell to do all this. 4. The RInside examples are located in /e/R/R-3.1.3/library/RInside/examples/standard folder. 5. To compile this under windows use command make -f Makefile.win 6. All the files will be compiled using gcc. Hope this helps all.

A motorized coconut scrapper

My dad, brother and me made a motorized coconut scrapping machine. Thought of sharing with everyone on how we made it.  Fig 1  Fig 2  Fig 3 Fig 4 Fig 5  Fig 6 Fig 7 Fig 8 Fig 9 Fig 10 Fig 11 Fig 12 Fig 13 The total cost would come to around 5000 Rs. The price is inclusive of cost of making the stand,  shaping the metallic scraper part (lathe required),  2 splendour motorbike ball bearings,  2 pulleys,  1 belt,  1 shaft for attaching big pulley to ball bearings (lathe required) Motor 1400 rpm. This itself costs 4000 Rs.!!!! Screws for attaching the machine to table flat plastic container for preventing the scraped coconut from flying all over the place. :-) We also made the table, but designed a very ugly looking sturdy table. Pressed wood will not do. The mechanics are very easy to understand and the stand is quite strong to take a good beating for several years. The pulley...

A cookbook on regular expressions and bash scripts

Since I started using this for searching strings I cannot dream of using anything else. I will put down some of the usual scripts I use wither with MINGW shell or Cygwin or even oracle to search data in a file or an oracle database.Think of it as a how to manual. 1. (Mingw) You want to filter the files on the command line which match two words? Here I try to match the word FR_BLOCK and word starting with C from a list of files. ls -lf | grep -iE "FR_BLOCK"| grep -iE "^C" What this does is divided into 3 parts ls -lf will list the directory contents in long format and remoe all extra information like date of creation and file size etc. grep -iE "FR_BLOCK" The output of above command is piped to grep via | operator. The grep command will search for FR_BLOCK word and assumes matching with or without capital letters(i) and uses extended regular expressions(E). The third part of grep -iE "^C" will search the piped out of the above comma...

How to modify elements in a list and return list usingrapply

Using rapply one can write a function which runs over elements in a list returning a list. # Here I create a list of 10 normal random numbers testList <- data-blogger-escaped-0="" data-blogger-escaped-add="" data-blogger-escaped-all="" data-blogger-escaped-are="" data-blogger-escaped-by="" data-blogger-escaped-code="" data-blogger-escaped-elements="" data-blogger-escaped-function="" data-blogger-escaped-here="" data-blogger-escaped-how="list" data-blogger-escaped-i="" data-blogger-escaped-ifelse="" data-blogger-escaped-list="" data-blogger-escaped-newlist="" data-blogger-escaped-numbers="" data-blogger-escaped-rapply="" data-blogger-escaped-reduce="" data-blogger-escaped-replace="" data-blogger-escaped-rnorm="" data-blogger-escaped-testlist="" data-blogger-escaped-the="" d...

Installing and using ROracle in R

Hi, Hope this post keeps you in the best of health. I am an oracle user and wanted to know how to fetch database information in R. There is a package out there called ROracle but there are no binaries for it and it thus needs to be built and then installed. Here are the steps to install it on Windows 7 machines. 1. Download the package from http://cran.r-project.org/web/packages/ROracle/index.html. Since I wrote this post the latest that was available was  ROracle_1.1-12.tar.gz . 2. Place the package in the directory where R is installed. I placed mine in E:\R\R-3.0.2\bin folder. 3. Install RTools from http://cran.r-project.org/bin/windows/Rtools/. Since my R version is R-3.0.2 the toolkit I needed was RTools31.exe. 4. Install the Rtools software in the R home directory. I placed mine in E:\R\Rtools. Place all the extras in there too. For example I placed my 32 bit extras in E:\R\RExtras32 and the 64 bit in E:\R\RExtras64 folder. These extras are not necessary for ...

Step by step guide to installing and using miktex with RStudio (Windows)

Using miktex with Rstudio is very easy with the miktex portable app available from http://miktex.org/portable. Steps 1. Follow the instructions from http://miktex.org/portable to download and unzip the miktex portable application in a loccation of your choice. 2. In R write the following code in a script and save it. Note that the E:\\Software-Silo\\Miktex\\miktex\\bin location is the location where I unzipped the miktex portable application. # Install miktex y <- Sys.getenv("PATH") x <- paste0(y,";","E:\\Software-Silo\\Miktex\\miktex\\bin") Sys.setenv(PATH=x) 3. Run Miktex by double clicking the following application "miktex-portable.cmd" in the Miktex main directory. 4. Run step 2 in RStudio to install the path into R environment. 5. Open a new RNW in RStudio to test whether Miktex works . 6. Run Compile PDF in RStudio. It should be just at the top of the RNW file created in step 5. 7. You will now see a PDF file whic...