From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vikas Rawal Subject: Re: Org-mode/R/Latex treatment of NAs Date: Mon, 14 Jul 2014 05:12:05 +0200 Message-ID: References: <9C0E84C3-9349-466B-907E-7C1469EFE9F1@agrarianresearch.org> Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6Wge-0008GR-69 for emacs-orgmode@gnu.org; Sun, 13 Jul 2014 23:12:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6WgW-0007Wo-Jn for emacs-orgmode@gnu.org; Sun, 13 Jul 2014 23:12:20 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:44105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6WgW-0007WT-BX for emacs-orgmode@gnu.org; Sun, 13 Jul 2014 23:12:12 -0400 Received: by mail-wi0-f175.google.com with SMTP id ho1so1798348wib.14 for ; Sun, 13 Jul 2014 20:12:11 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Grant Rettke Cc: org-mode mailing list > Just wanting to understand more: >=20 > Do you equate nil in Emacs Lisp with NA in R or do you equate it some = other way? >=20 When I execute my source code block, the NAs show up in the results = block as nil. See example below. I would prefer a blank in place of nil. Any idea how to do that? Vikas -------------- #+NAME: ccpc-negative-income-cerealstate-in #+BEGIN_SRC R :results value :colnames yes :hline yes = ccpc[,c(1:5,43,44,45,84,75,76,81,107,10,11,13,12,14:41,46:60,66,67,92,109:= 114)]->b subset(b,Year_Agriculture=3D=3D2009)->b subset(b,Crop_code %in% c(10,20,40,140,150))->b (b$Main_Product_Rs+b$By_Product_Rs-b$Cost_A2)->b$Net_income_A2 = (b$Main_Product_Rs+b$By_Product_Rs-b$Cost_C2)/b$Crop_Area_Ha->b$Net_income= _C2 ifelse(b$Net_income_A2<0,1,0)->b$loss b$count<-1 = b[,c(16:ncol(b))]*b$Cluster_Factor_Weight*b$Zone_factor->b[,c(16:ncol(b))]= = melt(b,id=3Dc("Year_Agriculture","State","Crop_code","Crop","Zone_Code","Z= one_factor","Area_of_Crop_in_Zone_ha","state_multiplier","Tehsil_Code","Si= ze_Group","Period_of_crop_months","Cluster_Factor_Weight","Parcel_Plot_Sea= son","Ha_Month_in_Ground"),m=3Dc("loss","count","Crop_Area_Ha"))->a = dcast(a,Year_Agriculture+State+Crop_code+Crop+Zone_Code+state_multiplier+A= rea_of_Crop_in_Zone_ha~variable,sum)->b = melt(b,id=3Dc("Year_Agriculture","State","Crop_code","Crop","Zone_Code","s= tate_multiplier","Area_of_Crop_in_Zone_ha","Crop_Area_Ha"),m=3Dc("loss","c= ount"))->a a$value*a$Area_of_Crop_in_Zone_ha/a$Crop_Area_Ha->a$value dcast(a,Year_Agriculture+Crop_code+Crop~variable,sum)->b dcast(a,Year_Agriculture+State+Crop_code+Crop~variable,sum)->b1 b$State<-"All states" rbind(b,b1)->b round(b$loss*100/b$count,1)->b$prop = #ggplot(b,aes(x=3DYear_Agriculture,y=3Dprop,group=3DState,color=3DState,li= netype=3DState))->p #p+geom_line()+scale_y_continuous("Prportion of = farms")+scale_x_continuous("Year",breaks=3Dc(1994,1997,2000,2003,2006,2009= ),labels=3Dc("1994-95","1997-98","2000-01","2003-04","2006-07","2009-10"))= +theme_bw() = melt(b,id=3Dc("Year_Agriculture","Crop_code","Crop","State","loss","count"= ))->a dcast(a,State~Crop_code,mean,drop=3DT)->t t[is.na(t)]<-NA names(t)<-c("State","Wheat","Paddy","Maize","Bajra","Ragi") t #+END_SRC #+NAME: ccpc-negative-income-cerealstate #+CAPTION: Proportion of cultivators with negative returns from = cultivation of different crops, by State, 2009-10 #+attr_latex: :environment tabulary :width \textwidth :align lRRRRR #+RESULTS: ccpc-negative-income-cerealstate-in | State | Wheat | Paddy | Maize | Bajra | Ragi | |------------------+-------+-------+-------+-------+------| | All states | 2.7 | 7.4 | 23.2 | 6.1 | 15 | | Andhra Pradesh | nil | 5.8 | 17.8 | nil | 0 | | Assam | nil | 6.5 | nil | nil | nil | | Bihar | nil | 4.8 | nil | nil | nil | | Chhattisgarh | 55.3 | 1.2 | 0 | nil | nil | | Gujarat | 0 | 0.3 | 15.2 | 6.4 | nil | | Haryana | 0.1 | 0.2 | nil | 3 | nil | | Himachal Pradesh | 7.6 | 0.1 | 1.4 | nil | nil | | Jharkhand | 1.4 | 42.7 | nil | nil | nil | | Karnataka | nil | 2.2 | 3.2 | 39.9 | 14.9 | | Kerala | nil | 8.6 | nil | nil | nil | | Madhya Pradesh | 0 | 0.9 | 16.7 | nil | nil | | Maharashtra | 6.5 | 37.1 | nil | 15.2 | 18.2 | | Orissa | nil | 0.6 | nil | nil | nil | | Punjab | 0.1 | 1.3 | nil | nil | nil | | Rajasthan | 0 | nil | 24 | 0.8 | nil | | Tamil Nadu | nil | 4.5 | 10.1 | nil | 0.6 | | Uttar Pradesh | 1.1 | 4.2 | 39.3 | 1 | nil | | Uttarakhand | 0 | 0 | nil | nil | nil | | West Bengal | 26.9 | 7.5 | nil | nil | nil | Vikas=