Let your heart guide you......It whispers so listen closely

Monday, February 18, 2013

Package making in R

Recently I was trying to make a package in R. As always I searched on internet. I realised that many people have discussed the technique of package making. But there are lot of complexities involved in the procedure, probably that is why I was stuck for too long. I went through many different manuals, but somehow, they were too much for my level. I wanted some very simple steps, very basic ones. Since I was a starter, so I wanted to get one in working condition and then refine it further. I found Rob J Hyn­d­man's discussion quite useful. I am presenting here a further simplified version (which worked for me) of his steps:

Step.1- Install R tools (available on the web).

Step.2 - Goto Control Panel -> System -> Advanced System Settings-> Environment Variables -> System Variables 
Edit the variable with name Path as follows:
Add C:\Program Files\R\R-2.15.1\bin\i386;c:\Rtools\bin; c:\Rtools\MinGW; c:\Perl\bin; (where first directory should be the one which contains R-executable) to already existing C:\Program Files\MiKTeX 2.7\miktex\bin; %SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem; %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\; C:\Program Files\MATLAB\R2008a\bin; C:\Program Files\MATLAB\R2008a\bin\win32
etc.

Step.3 - Goto DOS prompt and type the following
PATH 
R.exe (R should boot up from any directory if above step is correct)

Step.4 - Create an R work­space con­tain­ing all the relevant functions and data sets that you want to include in the package. Delete anything from the work­space that you do not want to include in the package.
Set the current directory to where ever you want create the package.

Step.5 - To cre­ate a pack­age called basicpack, use the R command
package.skeleton(name="basicpack")
This will gen­er­ate a direc­tory fred and sev­eral sub-​​directories in the required structure. A pack­age con­sists of a direc­tory con­tain­ing a file ‘DESCRIPTION’ and usu­ally has the sub­di­rec­to­ries R, data and man.The package.skeleton com­mand above will have cre­ated the required files and directories. You now need to edit them so they con­tain the right information. To start with one may not edit all of them. There is only one field which is compulsory to edit, without which you cannot proceed. Goto the directory where you have created the skeleton of the package, you will see a folder with package name i.e. basicpack -> man
You will see some R files. Each of which will have a \title{ } field, which will be empty. To install your package, you need make this field non-empty in each R-file.

Step.6 - For com­pil­ing goto DOS prompt in the direc­tory con­tain­ing your pack­age and type
Rcmd INSTALL --build basicpack

Step.7 - To check that the pack­age sat­is­fies the require­ments for a CRAN pack­age, use
Rcmd check basicpack
The checks are quite strict. A pack­age will often work ok even if it doesn’t pass these tests. But it is good prac­tice to build pack­ages that do sat­isfy these tests as it may save prob­lems later.


With this you have a package in working condition, which you can install from local zip file and it will be available in the list of Packages in your R window. The steps I have discussed, will only help you make a very basic and raw package. Offcourse there is lot more to package making. Like one needs to add descriptions, examples, add namespaces, datasets, bring dependency on other packages, help file, and much more. I think lot of information about these steps is available on internet. I have not explored any of these yet. Its like I was unable to stand, and people were giving me a mixed guide on how to stand, walk and run :(


Thursday, February 14, 2013

News about "The Uncertain Affairs"

On last birthday of our dear blog we came up with a special poster. This year both of us were so tied up in things, that the birthday passed without any gifts/blasts/celebrations. Actually speaking we were busy collecting gifts whole year... I was wondering that there are many a things which we have added to the store recently.

FB page - Somewhere around September/October last year we got into Facebook. Going to FB was required to catch up with the masses. We are not just posting the events news but also the random news related to Statistical world, like those of Statisticians, Softwares, Resources etc. 

Classy poster for the Cover - On World Statistics Day, we came up with a sort of promotional cover photo for the FB page. It has got a nice classic and antique look. Take a glimpse.

New (sub) page - We always felt the lack of common space for news about Statistics related news. Once we entered FB, and were updating those small tit bits, other than events, the need was more concrete. Because everyone is not on FB. We tried subpages, but apparently multiple dynamic pages are not possible in blogger, and we had no plans of moving to Wordpress. We attempted Google+. Somehow I am personally not very comfortable with it, but that seemed to be the only option and need of the hour. The attempt failed miserably. It was a near-death experience for our blog. But we managed to survive. We were in no mood to touch Google+ again. But at the same time we are not the ones who can stop so easily. We again started struggling for adding dynamic pages to blogger. With the constraints and our typical choosy behaviour we could not come up with any feasible option. At last we came up with a new page, which wasn't although a subpage but we managed giving it a feel of that type.

Moving to personal domain - Having a domain was another thing which was in our mind since long. So we are now uncertainaffairs.com and the subpage is uncertainstuff.uncertainaffairs.com. Thanks to blogger (and in turn Google), that they are kind enough to allow people like us to host the blog from personal domain. And the best part is, our usual traffic on blogspot gets automatically redirected to the page. It is really appreciable.


I think the list ends here. So although the birthday went uneventful, the year didn't :)

I really wish that the journey will continue.. with more and more people helping and contributing and at the same time more and more getting the benefit.