[R] remove NA or 0 values

sudhi rao forsudhi at gmail.com
Thu Nov 29 11:14:50 CET 2012


df <- df[-which(is.na(df$Field)), ] - removing rows with NULL fields
df <- df[-which(df$Field == "" ), ] - removing rows with empty fields



On Wednesday, November 28, 2012 2:23:00 PM UTC+5:30, catalin roibu wrote:
>
> Dear R users, 
> I want to remove zero's or NA values after this model. 
>
> year value1 value2 
> 1854 0 12 
> 1855 0 13 
> 1866 12 16 
> 1877 11 24 
>
> year value1 value2 
> 1 12 12 
> 2 11 13 
> 3 16 
> 4 24 
>
> Thank you! 
>
>
> -- 
> --- 
> Catalin-Constantin ROIBU 
> Forestry engineer, PhD 
> Forestry Faculty of Suceava 
> Str. Universitatii no. 13, Suceava, 720229, Romania 
> office phone     +4 0230 52 29 78, ext. 531 
> mobile phone   +4 0745 53 18 01 
>                        +4 0766 71 76 58 
> FAX:                +4 0230 52 16 64 
> silvic.usv.ro 
>
>         [[alternative HTML version deleted]] 
>
> ______________________________________________ 
> R-h... at r-project.org <javascript:> mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help 
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html 
> and provide commented, minimal, self-contained, reproducible code. 
>


More information about the R-help mailing list