Skip to main content

Posts

Showing posts from April, 2015

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...