x <- tryCatch( "OK", warning=function(w){ return(paste( "Warning:", conditionMessage(w))); }, error = function(e) { return(paste( "Error:", conditionMessage(e))); }, finally={ print("This is try-catch test. check the output.") }); print(x); x <- tryCatch( warning("got a warning!"), warning=function(w){ return(paste( "Warning:", conditionMessage(w))); }, error = function(e) { return(paste( "Error:", conditionMessage(e))); }, finally={ print("This is try-catch test. check the output.") }); print(x); x <- tryCatch( stop("an error occured!"), warning=function(w){ return(paste( "Warning:", conditionMessage(w))); }, error = function(e) { return(paste( "Error:", conditionMessage(e))); }, finally={ print("This is try-catch test. check the output.") }); print(x);
December 30, 2013
Simple try-catch code in R
Here is a simple code sample to demonstrate tryCatch function in R.
December 29, 2013
How to change the limit of uploaded file size in php?
Edit the following configurations in the php.ini file, and then restart webserver (apache).
You may find the php.ini file in /etc/php5/apache2 directory of ubuntu. If you forget the location of ini file, you may find it by running a simple php file as below.
upload_max_filesize = 10M post_max_size = 20M
You may find the php.ini file in /etc/php5/apache2 directory of ubuntu. If you forget the location of ini file, you may find it by running a simple php file as below.
<?php phpinfo(); ?>
Note: you will probably require write permission to edit the php.ini file.
For more information, you may visit this page.
December 28, 2013
Automatic mapping (or conversion) among different biological databases
biomaRt is an R package to map among different biological databases. Here is a simple code-snippet to convert human gene id to gene symbol.
library(biomaRt) ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl") symbols = getBM(attributes=c('entrezgene','hgnc_symbol'), filters='entrezgene', values=c("7157","5601"), mart=ensembl)
Installation note:
- In Ubuntu, you may need to install 'libxml2-dev' and 'libcurl4-openssl-dev'.
Subscribe to:
Posts (Atom)