[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

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,

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 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] HELP relevel INTERCEPT-COMPARISONS

2017-10-29 Thread Michael Dewey
Dear Xavier You problem comes from using attach(). Do not do that, it usually ends in tears. Either use the data parameter to the functions which support it or look at with() and within(). On 28/10/2017 21:11, CHIRIBOGA Xavier wrote: Dear colleagues, How can I do to "relevel" the intercept

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
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
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 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

[R] Counting nuber of sentences by qdap package

2017-10-29 Thread Elahe chalabi via R-help
Hi all, I have a data frame with a variable Description containing text of speeches and I would like to count number of sentences in each speech, > str(data) 'data.frame': 255 obs. of 3 variables: $ Group : Factor w/ 255 levels "AlzheimerGroup1","AlzheimerGroup10",..: 1 112 179 190

Re: [R] Add a vertical line and some values on a plot

2017-10-29 Thread varin sacha via R-help
Hi Rui, Many thanks for your response. De : Rui Barradas roject.org> Envoyé le : Dimanche 22 octobre 2017 18h27 Objet : Re: [R] Add a vertical line and some values on a plot Hello, After the plot just do abline(v = median(A)) As for how to plot point

[R] An iterative function

2017-10-29 Thread li li
Dear all, The function f() below is a function of m1 and m2, both of which are matrices with 3 rows. The function works sequentially one row after another. So altogether there are three stages. I am trying to update the coding to write a generic function that will work for arbitrary k stages. I

Re: [R] An iterative function

2017-10-29 Thread Boris Steipe
Write a for-loop that tests your condition and carries the necessary parameters forward. break() when your condition is met. B. > On Oct 29, 2017, at 10:24 PM, li li wrote: > > Dear all, > The function f() below is a function of m1 and m2, both of which are > matrices with 3 rows. The func

[R] How to install packages from GitHubb

2017-10-29 Thread Patrick Connolly
R-3.4.1 Running the train function from the latest version of the caret package on CRAN fails with this message: unable to find variable "optimismBoot" The purported workaround is to use devtools::install_github('topepo/caret/pkg/caret') to get the development version. However, that evidentl

[R] run r script in r-fiddle

2017-10-29 Thread Frank Mei
Hi All, I want to know how to run an R file on my computer in R-Fiddle? I tried source("filename.r"), but not working. thanks, Frank [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see htt

Re: [R] run r script in r-fiddle

2017-10-29 Thread Jeff Newmiller
You can't. Use R on your computer instead. -- Sent from my phone. Please excuse my brevity. On October 29, 2017 5:56:55 PM PDT, Frank Mei wrote: >Hi All, > >I want to know how to run an R file on my computer in R-Fiddle? > >I tried source("filename.r"), but not working. > >thanks, >Frank > >