Re: [R] Count non-zero values in excluding NA Values

2017-10-30 Thread David L Carlson
roject.org Subject: Re: [R] Count non-zero values in excluding NA Values Dear R Staff This is my file (www.fiscalforecasting.com/data.csv) if you don't download this file, my dataset same as following Year Month A B C D E 2005 July 0 *4* NA NA *1* 2005 July 0 NA NA 0 *9*

Re: [R] Count non-zero values in excluding NA Values

2017-10-29 Thread Daniel Nordlund
On 10/29/2017 3:25 AM, Engin YILMAZ wrote: Dear R Staff You can see my data.csv file in the annex. I try to count non-zero values in dataset but I need to exclude NA in this calculation My code is very long (following), How can I write this code more efficiently and shortly? ## [NA_Count] - F

Re: [R] Count non-zero values in excluding NA Values

2017-10-29 Thread Engin YILMAZ
Thanks Esawi,Barradas and Berger Sincerely Engin YILMAZ Virus-free. www.avast.com

Re: [R] Count non-zero values in excluding NA Values

2017-10-29 Thread Ek Esawi
What was suggested by Eric and Rui works well, but here is a short and may be simpler answer provided your data is similar what Eric posted. It should work for your l data too. aa <- is.na(data)|data==0 nrow(data)-colSums(aa) EK On Sun, Oct 29, 2017 at 6:25 AM, Engin YILMAZ wrote: > Dear R Sta

Re: [R] Count non-zero values in excluding NA Values

2017-10-29 Thread Engin YILMAZ
Dear R Staff This is my file (www.fiscalforecasting.com/data.csv) if you don't download this file, my dataset same as following Year Month A B C D E 2005 July 0 *4* NA NA *1* 2005 July 0 NA NA 0 *9* 2005 July NA *4* 0 *1* 0 2005 July *4* 0 *2* *9* NA I try to c

Re: [R] Count non-zero values in excluding NA Values

2017-10-29 Thread Ek Esawi
Since i could not see your data, the easiest thing comes to mind is court values excluding NAs, is something like this sum(!is.na(x)) Best of luck--EK On Sun, Oct 29, 2017 at 6:25 AM, Engin YILMAZ wrote: > Dear R Staff > > You can see my data.csv file in the annex. > > I try to count non-zero v

Re: [R] Count non-zero values in excluding NA Values

2017-10-29 Thread Eric Berger
If one does not need all the intermediate results then after defining data just one line: grand_total <- nrow(data)*ncol(data) - sum( sapply(data, function(x) sum( is.na(x) | x == 0 ) ) ) # 76 On Sun, Oct 29, 2017 at 2:38 PM, Rui Barradas wrote: > Hello, > > Your attachment didn't came throu

Re: [R] Count non-zero values in excluding NA Values

2017-10-29 Thread Rui Barradas
Hello, Your attachment didn't came through, R-Help strips off most types of files, including CSV. Anyway, the following will do what I understand of your question. Tested with a fake dataset. set.seed(3026)# make the results reproducible data <- matrix(1:100, ncol = 10) data[sample(100,

[R] Count non-zero values in excluding NA Values

2017-10-29 Thread Engin YILMAZ
Dear R Staff You can see my data.csv file in the annex. I try to count non-zero values in dataset but I need to exclude NA in this calculation My code is very long (following), How can I write this code more efficiently and shortly? ## [NA_Count] - Find NA values data.na =sapply(data[,3:ncol(d