Re: [R] Count data in random Forest

2023-05-18 Thread Bert Gunter
This is R-**Help**, not R- **we give you all the answers.** Please read and follow the posting guide linked below for what sorts of questions are appropriate for this list and what you should include when asking them. Incidentally, there are several packages in R that do (versions of) random fores

Re: [R] Count data in random Forest

2023-05-18 Thread Suriya Kannan
Respected Sir Good Evening. My name is V.Suriya, I am a research scholar. Doing my Ph.D at University of Madras, Tamil Nadu, India. I need the r code for random forest count data. It helps me lot to complete my research work sir. And also need the r code for comparison of predictors with the help

Re: [R] Count matrix of GSE146049

2023-04-02 Thread Bert Gunter
Go to Bioconductor.org -- Bert On Sun, Apr 2, 2023 at 9:38 AM Anas Jamshed wrote: > > How can I subscribe to R genomic list? > > On Sun, 2 Apr 2023, 9:28 pm Peter Langfelder, > wrote: > > > It's a microarray data set, so I don't think you would want to apply > > an RNA-seq pipeline. You'd be be

Re: [R] Count matrix of GSE146049

2023-04-02 Thread Anas Jamshed
How can I subscribe to R genomic list? On Sun, 2 Apr 2023, 9:28 pm Peter Langfelder, wrote: > It's a microarray data set, so I don't think you would want to apply > an RNA-seq pipeline. You'd be better off applying a normalization > appropriate for this type of microarray data. > > HTH, > > Pete

Re: [R] Count matrix of GSE146049

2023-04-02 Thread Peter Langfelder
It's a microarray data set, so I don't think you would want to apply an RNA-seq pipeline. You'd be better off applying a normalization appropriate for this type of microarray data. HTH, Peter On Sun, Apr 2, 2023 at 11:09 PM Anas Jamshed wrote: > > I want to get the count matrix of genes from >

Re: [R] Count matrix of GSE146049

2023-04-02 Thread Marc Girondot via R-help
Dear Anas Jamshed, This is a list for R, not for specific genomic question using R. You will have more chance to have answers using a genomic list. And when you ask question, it is better to not use abbreviation that only people from that field will understand: TMM ? Marc Le 02/04/2023 à 17

[R] Count matrix of GSE146049

2023-04-02 Thread Anas Jamshed
I want to get the count matrix of genes from https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE146049. Is it possible for GSE146049? After getting counts, I want to do TMM normalization. [[alternative HTML version deleted]] __ R-help@r-proje

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

Re: [R] count number of stop words in R

2017-06-12 Thread Bert Gunter
t . But > the water is still flowing . > > > > > > On Monday, June 12, 2017 7:24 AM, Patrick Casimir wrote: > > > > You can define stop words as below. > data <- tm_map(data, removeWords, stopwords("english")) > > > Patrick Casimir, PhD >

Re: [R] count number of stop words in R

2017-06-12 Thread Florian Schwendinger
lt;- DocumentTermMatrix(corp, cntrl) col_sums(dtm[, which(colnames(dtm) %in% stopwords("en"))]) Best, Florian   Gesendet: Montag, 12. Juni 2017 um 16:12 Uhr Von: "Bert Gunter" An: "Elahe chalabi" Cc: "R-help Mailing List" Betreff: Re: [R] count numbe

Re: [R] count number of stop words in R

2017-06-12 Thread Patrick Casimir
nday, June 12, 2017 11:42:43 AM To: Patrick Casimir; Bert Gunter Cc: R-help Mailing List Subject: Re: [R] count number of stop words in R Defining data as you mentioned in your respond causes the following error: Error in UseMethod("tm_map", x) : no applicable method for 'tm_map

Re: [R] count number of stop words in R

2017-06-12 Thread Patrick Casimir
List Subject: Re: [R] count number of stop words in R Defining data as you mentioned in your respond causes the following error: Error in UseMethod("tm_map", x) : no applicable method for 'tm_map' applied to an object of class "character" I can solve this error by us

Re: [R] count number of stop words in R

2017-06-12 Thread Elahe chalabi via R-help
June 12, 2017 11:23:42 AM To: Patrick Casimir; Bert Gunter Cc: R-help Mailing List Subject: Re: [R] count number of stop words in R Thanks for your reply. I know the command data <- tm_map(data, removeWords, stopwords("english")) removes English stop words, I don't know how sho

Re: [R] count number of stop words in R

2017-06-12 Thread Patrick Casimir
rick Casimir, PhD Health Analytics, Data Science, Big Data Expert & Independent Consultant C: 954.614.1178 From: Elahe chalabi Sent: Monday, June 12, 2017 11:23:42 AM To: Patrick Casimir; Bert Gunter Cc: R-help Mailing List Subject: Re: [R] count number o

Re: [R] count number of stop words in R

2017-06-12 Thread Elahe chalabi via R-help
lish")) Patrick Casimir, PhD Health Analytics, Data Science, Big Data Expert & Independent Consultant C: 954.614.1178 From: R-help on behalf of Bert Gunter Sent: Monday, June 12, 2017 10:12:33 AM To: Elahe chalabi Cc: R-help Mailing List Subject:

Re: [R] count number of stop words in R

2017-06-12 Thread Patrick Casimir
er Sent: Monday, June 12, 2017 10:12:33 AM To: Elahe chalabi Cc: R-help Mailing List Subject: Re: [R] count number of stop words in R You can use regular expressions. ?regex and/or the stringr package are good places to start. Of course, you have to define "stop words." Cheers, Bert

Re: [R] count number of stop words in R

2017-06-12 Thread Bert Gunter
You can use regular expressions. ?regex and/or the stringr package are good places to start. Of course, you have to define "stop words." Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathe

[R] count number of stop words in R

2017-06-12 Thread Elahe chalabi via R-help
Hi all, Is there a way in R to count the number of stop words (English) of a string using tm package? str="Mhm . Alright . There's um a young boy that's getting a cookie jar . And it he's uh in bad shape because uh the thing is falling over . And in the picture the mother is washing dishes and

[R] Count of included observations in sp.correlogram

2015-11-04 Thread Robert U
Dear Rusers, I’m tryingto figure out what I think is a pretty simple thing for anyone who knows about correlograms.I’ve a regular grid (say 5*5 points) with some quantity associated to eachpoint (count data). I’m trying to verify whether this quantity is regularly /randomly or “clusterdly” distr

Re: [R] count by category

2015-10-06 Thread Jim Lemon
Hi Val, You can even get a graphic illustration of this quite easily: library(plotrix) sizetree(dataset) Jim On Tue, Oct 6, 2015 at 10:00 AM, Val wrote: > Hi All, > > I have a data set ( region, city, town and district). The data looks like > region, city, town, district > 1 1 1 1 > 1 1

Re: [R] count by category

2015-10-06 Thread Thierry Onkelinx
er solutions but I would use ave with length function > for each column separately to add new column. > > See ?ave > > Cheers > Petr > > > -Original Message- > > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Val > > Sent: Tuesday, Octob

Re: [R] count by category

2015-10-05 Thread PIKAL Petr
M > To: r-help@r-project.org > Subject: [R] count by category > > Hi All, > > I have a data set ( region, city, town and district). The data looks > like region, city, town, district > 1 1 1 1 > 1 1 1 2 > 1 1 1 3 > 1 1 2 1 > 1 1 2 2 > 1 2 1

[R] count by category

2015-10-05 Thread Val
Hi All, I have a data set ( region, city, town and district). The data looks like region, city, town, district 1 1 1 1 1 1 1 2 1 1 1 3 1 1 2 1 1 1 2 2 1 2 1 1 I want the counts for region, city and town. Here region 1 has 6 records, city 1 has 5 records and city 2 has 1 re

Re: [R] Count number of rain more than zero in matrix form

2015-10-01 Thread Duncan Mackay
R-help [mailto:r-help-boun...@r-project.org] On Behalf Of smart hendsome Sent: Thursday, 1 October 2015 12:47 To: r-help@r-project.org Subject: [R] Count number of rain more than zero in matrix form Hello R-users, I want to ask how to count the number of daily rain data. My data using dput() as

Re: [R] Count number of rain more than zero in matrix form

2015-10-01 Thread PIKAL Petr
01, 2015 8:53 AM To: PIKAL Petr Subject: Re: [R] Count number of rain more than zero in matrix form Hi PIKAL, Thanks for your reply, I dont know how to send my data after using the dput(). I also attached my real data in csv format. I have tried using the function length but not working. Can you h

Re: [R] Count number of rain more than zero in matrix form

2015-09-30 Thread PIKAL Petr
31961 3 HTH Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of smart > hendsome > Sent: Thursday, October 01, 2015 4:47 AM > To: r-help@r-project.org > Subject: [R] Count number of rain more than zero in matrix form > > H

[R] Count number of rain more than zero in matrix form

2015-09-30 Thread smart hendsome
Hello R-users, I want to ask how to count the number of daily rain data.  My data using dput() as below: structure(list(Year = c(1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L, 1960L,

Re: [R] Count unchanged class attribute

2015-05-20 Thread Soe Xiyan
not knowledge. And knowledge is > > certainly not wisdom." > > Clifford Stoll > > > > > > > > On Tue, May 19, 2015 at 7:02 PM, John Kane wrote: > > > >> Is this a list of data.frames or what? > >> > >> Please have a look at one or both o

Re: [R] Count unchanged class attribute

2015-05-19 Thread Jim Lemon
a >> question and provide information on the problem. The better you can >> describe what you have and what you need the better people can help. >> >> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example >> and http://adv-r

Re: [R] Count unchanged class attribute

2015-05-19 Thread John Kane
John Kane Kingston ON Canada -Original Message- From: gunter.ber...@gene.com Sent: Tue, 19 May 2015 20:04:58 -0700 To: jrkrid...@inbox.com Subject: Re: [R] Count unchanged class attribute Probably "or what." This demonstrates a fundamental conundrum: many users or prospective

Re: [R] Count unchanged class attribute

2015-05-19 Thread Bert Gunter
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example > and http://adv-r.had.co.nz/Reproducibility.html > > > John Kane > Kingston ON Canada > > > > -Original Message- > > From: soe.xi...@gmail.com > > Sent: Tue, 19 M

Re: [R] Count unchanged class attribute

2015-05-19 Thread John Kane
/how-to-make-a-great-r-reproducible-example and http://adv-r.had.co.nz/Reproducibility.html John Kane Kingston ON Canada > -Original Message- > From: soe.xi...@gmail.com > Sent: Tue, 19 May 2015 23:37:13 +0700 > To: r-help@r-project.org > Subject: [R] Count unchanged

Re: [R] Count unchanged class attribute

2015-05-19 Thread Rolf Turner
On 20/05/15 04:37, Soe Xiyan wrote: Maybe someone can help me. Suppose I have data-set like this: Netto Bruto class 1 10 1000yes 2 100 20 yes Netto Bruto class 1 101 1000yes 2 100 210 no Netto Bruto class 1 10 10 yes 2 12 28

Re: [R] Count number in r

2015-05-19 Thread John Kane
hnwas...@gmail.com Sent: Tue, 19 May 2015 18:26:35 +0200 To: jrkrid...@inbox.com Subject: Re: [R] Count number in r Dear all, I am kindly requesting for help on how I can count pixels with value less and equal to -0.08 for a raster stack. Thanks for your help John On Tue, May 19, 2015 at 5:57 PM, John

[R] Count unchanged class attribute

2015-05-19 Thread Soe Xiyan
Maybe someone can help me. Suppose I have data-set like this: Netto Bruto class 1 10 1000yes 2 100 20 yes Netto Bruto class 1 101 1000yes 2 100 210 no Netto Bruto class 1 10 10 yes 2 12 28 yes 3 100 20 yes Netto

Re: [R] Count number in r

2015-05-19 Thread John Wasige
rom: hafizuddinarsha...@gmail.com > > Sent: Tue, 19 May 2015 03:10:32 -0700 > > To: r-help@r-project.org > > Subject: [R] Count number in r > > > > Dear R users, > > > > Could someone help me on this? I have this kind of data set: > > > > st

Re: [R] Count number in r

2015-05-19 Thread John Kane
age- > From: hafizuddinarsha...@gmail.com > Sent: Tue, 19 May 2015 03:10:32 -0700 > To: r-help@r-project.org > Subject: [R] Count number in r > > Dear R users, > > Could someone help me on this? I have this kind of data set: > > structure(list(Year = c(1971L, 1971

Re: [R] Count number in r

2015-05-19 Thread David L Carlson
ege Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jorge I Velez Sent: Tuesday, May 19, 2015 8:21 AM To: Hafizuddin Arshad Cc: R Help Subject: Re: [R] Count number in r Dear Arshad, Here is a possibility using tapply(): with(d, ta

Re: [R] Count number in r

2015-05-19 Thread Jorge I Velez
Dear Arshad, Here is a possibility using tapply(): with(d, tapply(Rain, list(Month, Year), function(x) sum(x > .1))) ##1971 #1 12 #20 where "d" is your data.frame(). See also ?aggregate and ?ave. Best, Jorge.- On Tue, May 19, 2015 at 8:10 PM, Hafizuddin Arshad < hafizuddinarsha...@gm

[R] Count number in r

2015-05-19 Thread Hafizuddin Arshad
Dear R users, Could someone help me on this? I have this kind of data set: structure(list(Year = c(1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 19

Re: [R] Count

2015-05-13 Thread Sarah Goslee
Hi, On Wed, May 13, 2015 at 5:58 AM, venkadesan venky wrote: > Hello Team, > > I have data like this > > have Small doubts on the following calculation > > > For example, > > Employee sizeCamp 1camp 2 Camp 3 > > 11 0 0 > > 2

[R] Count

2015-05-13 Thread venkadesan venky
Hello Team, I have data like this have Small doubts on the following calculation For example, Employee sizeCamp 1camp 2 Camp 3 11 0 0 20 0 1 3

Re: [R] Count number of Fridays

2014-10-10 Thread Abhinaba Roy
Thanks Jim :) Regards Abhinaba On Fri, Oct 10, 2014 at 9:02 PM, jim holtman wrote: > Here is one way of doing it: > > > > require(lubridate) > > now <- as.Date('2014-10-10') # some date > > # get first of month > > first_mon <- now - day(now) + 1 > > # create sequence of days in the month so y

Re: [R] Count number of Fridays in a month

2014-10-10 Thread PO SU
In my Impression, there seems  exsits a function (let just call weekday) which can return a POSIXlt format date 's weekday. That means,  weekday( 31-may-2014 ) may return the right weekday maybe 5, so  a clumsy method is start to judge from 1-may-2014 to 31-may-2014 , you get  a vector x, sum(w

Re: [R] Count number of Fridays in a month

2014-10-10 Thread Gabor Grothendieck
On Fri, Oct 10, 2014 at 7:28 AM, Abhinaba Roy wrote: > Hi R helpers, > > I want to write a function which will > > 1. Count the number of fridays in the current month ( to extract month from > given date) and also the number of fridays in the preceeding month > > 2. Calculate the ratio of the numb

Re: [R] Count number of Fridays

2014-10-10 Thread jim holtman
Here is one way of doing it: > require(lubridate) > now <- as.Date('2014-10-10') # some date > # get first of month > first_mon <- now - day(now) + 1 > # create sequence of days in the month so you can count Fridays > x <- seq(first_mon, by = '1 day', length = days_in_month(first_mon)) > first_f

Re: [R] Count number of Fridays in a month

2014-10-10 Thread Barry Rowlingson
Or try this: fridays <- function(the_day){ require(lubridate) day(the_day) = 1 the_month = seq(the_day, the_day+months(1)-days(1),1) sum(wday(the_month) == 6) } That returns the number of Fridays in the month of a Date object given as arg: > fridays(as.Date("2012-01-01")) [1] 4 >

Re: [R] Count number of Fridays in a month

2014-10-10 Thread Duncan Murdoch
On 10/10/2014 8:10 AM, Abhinaba Roy wrote: Hi Duncan, I have converted the string to a POSIXIt object using > strptime('31-may-2014',format="%d-%b-%Y") But could not figure out the way forward. Could you please elaborate a bit? Try this: ?POSIXlt Duncan Murdoch On Fri, Oct 10, 2014 at

Re: [R] Count number of Fridays in a month

2014-10-10 Thread Abhinaba Roy
Hi Duncan, I have converted the string to a POSIXIt object using > strptime('31-may-2014',format="%d-%b-%Y") But could not figure out the way forward. Could you please elaborate a bit? On Fri, Oct 10, 2014 at 5:14 PM, Duncan Murdoch wrote: > On 10/10/2014, 7:28 AM, Abhinaba Roy wrote: > > Hi

Re: [R] Count number of Fridays in a month

2014-10-10 Thread Duncan Murdoch
On 10/10/2014, 7:28 AM, Abhinaba Roy wrote: > Hi R helpers, > > I want to write a function which will > > 1. Count the number of fridays in the current month ( to extract month from > given date) and also the number of fridays in the preceeding month > > 2. Calculate the ratio of the number of f

[R] Count number of Fridays in a month

2014-10-10 Thread Abhinaba Roy
Hi R helpers, I want to write a function which will 1. Count the number of fridays in the current month ( to extract month from given date) and also the number of fridays in the preceeding month 2. Calculate the ratio of the number of fridays in current month to the number of fridays in the prec

Re: [R] Count number of change in a specified time interval

2014-08-04 Thread jim holtman
Here is the solution using 'rle': > require(data.table) > x <- read.table(text = "CASE_ID YEAR_MTH ATT_1 + CB26A201302 1 + CB26A201302 0 + CB26A201302 0 + CB26A201303 1 + CB26A201303 1 + CB26A201304 0 + CB26A201305

Re: [R] Count number of change in a specified time interval

2014-08-04 Thread Bert Gunter
Or ?rle Bert Sent from my iPhone -- please excuse typos. > On Aug 4, 2014, at 8:28 AM, jim holtman wrote: > > Try this, but I only get 2 changes for CB27A instead of you indicated 3: > >> require(data.table) >> x <- read.table(text = "CASE_ID YEAR_MTH ATT_1 > + CB26A201302 1 > +

Re: [R] Count number of change in a specified time interval

2014-08-04 Thread jim holtman
Try this, but I only get 2 changes for CB27A instead of you indicated 3: > require(data.table) > x <- read.table(text = "CASE_ID YEAR_MTH ATT_1 + CB26A201302 1 + CB26A201302 0 + CB26A201302 0 + CB26A201303 1 + CB26A201303 1 + CB26A201

Re: [R] Count number of change in a specified time interval

2014-07-30 Thread Adams, Jean
I may not understand exactly what you want, because when I try to follow your instructions, I get a different result. But, perhaps you can use this code and modify it to suit your needs. # number of rows L <- dim(df)[1] # determine for each row if it is within the first 3 months mins <- aggregat

[R] Count number of change in a specified time interval

2014-07-30 Thread Abhinaba Roy
Dear R-helpers, I want to count the number of times ATT_1 has changed in a period of 3 months(can be 4months) from the first YEAR_MTH entry for a CASE_ID. So if for a CASE_ID we have data only for two distinct YEAR_MTH, then all the entries should be considered, otherwise only the relevant entries

Re: [R] Count the number of unique days

2014-02-24 Thread Jeff Newmiller
Certainly it is possible. One way might involve using the "unique" function based on location and date before attaching the data to your SPDF. --- Jeff NewmillerThe . . Go Live... DCN

[R] Count the number of unique days

2014-02-24 Thread bogdan_antonescu
Hi All, I am working on a script to that is producing a lightning density map (numer of lightning flashes per area) based on a data set containing: date(year/month/day), time(hh/mm/ss), latitude, and longitude for each lightning flash. The attaches script is producing this map using a hexagonal g

Re: [R] count and sum simultaneously in R pivot table

2014-02-18 Thread Crombie, Burnette N
The script works nicely, Arun. You were right, I pasted code from email instead of Rhelp and didn't reformat properly in R. I appreciate your time with this! -Original Message- It seems like part of the next line is also being run (in the end 'colnames'). For e.g. res2 <- within(as.dat

Re: [R] count and sum simultaneously in R pivot table

2014-02-18 Thread Crombie, Burnette N
r-help@r-project.org Cc: Crombie, Burnette N Subject: Re: [R] count and sum simultaneously in R pivot table Hi, Check if this works: library(reshape2) res1 <- acast(FLSAdata_melt, ViolationDesc + ReasonDesc ~ variable, sum, margins=TRUE)[,-4] res2 <- within(as.data.frame(res1),`Count

Re: [R] count and sum simultaneously in R pivot table

2014-02-17 Thread arun
Hi, Check if this works: library(reshape2) res1 <- acast(FLSAdata_melt, ViolationDesc + ReasonDesc ~ variable, sum, margins=TRUE)[,-4] res2 <- within(as.data.frame(res1),`Count of Case ID` <- dcast(FLSAdata_melt, ViolationDesc + ReasonDesc ~ variable, length, margins=TRUE)[,3])[,c(4,1:3)] colna

Re: [R] Count observation based on hour

2014-02-08 Thread arun
Hi, Try: #using the same `data`  res1 <- as.data.frame(table(with(dat,cut(Date,breaks=seq(as.POSIXct("2013-01-01 00:00:00"),max(Date)+3600,by='1 hour') A.K. Hi A.K. Thank you very much! It worked!!  Just another quick follow-up question: res <- as.data.frame(table( with(dat,cut(Dat

Re: [R] Count observation based on hour

2014-02-06 Thread arun
HI Map, I am not sure what you really wanted.  Perhaps, this helps: dat <- structure(list(Date = c("2014-01-01 00:00:00", "2014-01-02 11:00:00", "2014-01-02 22:00:00", "2014-01-03 03:00:00", "2014-01-01 00:00:00", "2014-02-02 11:00:00", "2014-02-02 22:00:00", "2014-02-03 03:00:00", "2014-02-01

[R] count and sum simultaneously in R pivot table

2014-02-06 Thread bcrombie
Based on the following code, how can I add a column to this pivot table output that will count CaseID's for each variable sum? CaseID is a factor. # library(reshape) # FLSA_Violation_Reason_melt <- melt(FLSA_ViolRsnfixed, #id=c("CaseID", "ViolationDesc", "Reas

Re: [R] Count observation based on hour

2014-02-05 Thread arun
Hi, Try: data.frame(table(dat$Date)) A.K. Hi guys, I have some 20,000 observations like this:           Date       2014-01-01 00:00:00 2014-01-02 11:00:00 2014-01-02 22:00:00 2014-01-03 03:00:00 I want to perform an hourly count (e.g. the frequency occur at each hour for a specific date)

Re: [R] Count number of consecutive zeros by group

2013-11-01 Thread PIKAL Petr
Hi Yes you are right. This gives number of zeroes not max number of consecutive zeroes. Regards Petr > -Original Message- > From: arun [mailto:smartpink...@yahoo.com] > Sent: Friday, November 01, 2013 2:17 PM > To: R help > Cc: PIKAL Petr; Carlos Nasher > Subject: Re

Re: [R] Count number of consecutive zeros by group

2013-11-01 Thread arun
To: S Ellison > Cc: r-help@r-project.org > Subject: Re: [R] Count number of consecutive zeros by group > > If I apply your function to my test data: > > ID <- c(1,1,1,2,2,3,3,3,3) > x <- c(1,0,0,0,0,1,1,0,1) > data <- data.frame(ID=ID,x=x) > rm(ID,x) >

Re: [R] Count number of consecutive zeros by group

2013-11-01 Thread PIKAL Petr
1, 2013 6:46 PM > To: S Ellison > Cc: r-help@r-project.org > Subject: Re: [R] Count number of consecutive zeros by group > > If I apply your function to my test data: > > ID <- c(1,1,1,2,2,3,3,3,3) > x <- c(1,0,0,0,0,1,1,0,1) > data <- data.frame(ID=ID,x=x) >

Re: [R] Count number of consecutive zeros by group

2013-10-31 Thread William Dunlap
o max() will take care of that. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of S Ellison > Sent: Thursday, October 31, 2013 11:27 AM > To: Carlos Nas

Re: [R] Count number of consecutive zeros by group

2013-10-31 Thread Hervé Pagès
Hi Carlos, With Bioconductor, this can simply be done with: library(IRanges) ID <- Rle(1:3, c(3,2,4)) x <- Rle(c(1,0,0,0,0,1,1,0,1)) groups <- split(x, ID) idx <- groups == 0 Then: > max(runLength(idx)[runValue(idx)]) 1 2 3 2 2 1 Should be fast even with hundreds of thousands

Re: [R] Count number of consecutive zeros by group

2013-10-31 Thread S Ellison
> If I apply your function to my test data: > > the result is > 1 2 3 > 2 2 2 > ... > I think f2 does not return the max of consecutive zeros, but the max of any > consecutve number... Any idea how to fix this? The toy example of tapply using f2 does indeed return the maximum run lengths i

Re: [R] Count number of consecutive zeros by group

2013-10-31 Thread arun
Hi, May be this helps: fun1 <- function(dat){  lst1 <- lapply(split(dat,dat$ID),function(y){  rl <- rle(y$x)  data.frame(ID=unique(y$ID),MAXZero=max(rl$lengths[rl$values==0]))  })  do.call(rbind,lst1)  } fun1(df) #  ID MAXZero #1  1   2 #2  2   2 #3  3   1 A.K. On Thursday, O

Re: [R] Count number of consecutive zeros by group

2013-10-31 Thread Carlos Nasher
If I apply your function to my test data: ID <- c(1,1,1,2,2,3,3,3,3) x <- c(1,0,0,0,0,1,1,0,1) data <- data.frame(ID=ID,x=x) rm(ID,x) f2 <- function(x) { max( rle(x == 0)$lengths ) } with(data, tapply(x, ID, f2)) the result is 1 2 3 2 2 2 which is not what I'm aiming for. It should be 1 2 3

Re: [R] Count number of consecutive zeros by group

2013-10-31 Thread S Ellison
> -Original Message- > So I want to get the max number of consecutive zeros of variable x for each > ID. I found rle() to be helpful for this task; so I did: > > FUN <- function(x) { > rles <- rle(x == 0) > } > consec <- lapply(split(df[,2],df[,1]), FUN) You're probably better off wit

[R] Count number of consecutive zeros by group

2013-10-31 Thread Carlos Nasher
Dear R-helpers, I need to count the maximum number of consecutive zero values of a variable in a dataframe by different groups. My dataframe looks like this: ID <- c(1,1,1,2,2,3,3,3,3) x <- c(1,0,0,0,0,1,1,0,1) df <- data.frame(ID=ID,x=x) rm(ID,x) So I want to get the max number of consecutive z

Re: [R] count each answer category in each column

2013-04-19 Thread arun
colnames(x1)[2];x3[,c(1,7,2:6)]}) names(lst2)<- colnames(dat1)[-1] identical(lst1,lst2) #[1] TRUE   A.K. ________ From: Ye Lin To: arun Sent: Friday, April 19, 2013 5:49 PM Subject: Re: [R] count each answer category in each column Hey A.K I modified the scripts

Re: [R] count each answer category in each column

2013-04-19 Thread arun
$Rate  # Var1 Rate A B C #1  Bad    2 0 2 0 #2 Good    2 2 0 0 #3     1 0 0 1 A.K. From: Ye Lin To: arun Sent: Friday, April 19, 2013 1:44 PM Subject: Re: [R] count each answer category in each column Yes, but I am wondering if I can calculate how many ki

Re: [R] count each answer category in each column

2013-04-19 Thread arun
male  1  NA   NA #2   Male  1  NA   NA #3     0   0    0 #4  11-20 NA   2   NA #5    Bad NA  NA    2 #$C  # Var1 Gender Age Rate #1 Male  1  NA   NA #2   0   0    1 #3  >20 NA   1   NA A.K. ________ From: Ye Lin To: arun Cc: R help

Re: [R] count each answer category in each column

2013-04-19 Thread Ye Lin
t; # Var1 Age > #1 0-10 2 > #2 11-20 2 > #3 >20 1 > #4 0 > > #[[3]] > # Var1 Rate > #1 Bad 2 > #2 Good2 > #3 1 > A.K. > > > > - Original Message - > From: Ye Lin > To: R help > Cc: > Sent: Thursday, April

Re: [R] count each answer category in each column

2013-04-19 Thread Ye Lin
Thanks David! I do get confused sometimes when sth can be easily and directly done in Excel which is what I am familiar with, but I find it takes more time for me to operate that in R. On Thu, Apr 18, 2013 at 4:27 PM, David Winsemius wrote: > > On Apr 18, 2013, at 3:46 PM, Ye Lin wrote: > > > He

Re: [R] count each answer category in each column

2013-04-18 Thread arun
l Message - From: arun To: Ye Lin Cc: R help Sent: Thursday, April 18, 2013 7:04 PM Subject: Re: [R] count each answer category in each column Hi, Try this: Assuming that "table" is "data.frame" dat1<-read.table(text=" Gender  Age  Rate Female    0-10  Good M

Re: [R] count each answer category in each column

2013-04-18 Thread Jim Lemon
On 04/19/2013 08:46 AM, Ye Lin wrote: Hey, Is it possible that R can calculate each options under each column and return a summary table? Suppose I have a table like this: Gender Age Rate Female0-10 Good Male0-10 Good Female 11-20 Bad Male 11-20 Bad Male>20

Re: [R] count each answer category in each column

2013-04-18 Thread David Winsemius
On Apr 18, 2013, at 3:46 PM, Ye Lin wrote: > Hey, > > Is it possible that R can calculate each options under each column and > return a summary table? > > Suppose I have a table like this: > > Gender Age Rate > Female0-10 Good > Male0-10 Good > Female 11-20 Bad > Male

Re: [R] count each answer category in each column

2013-04-18 Thread arun
>20   1 #4     0 #[[3]]  # Var1 Rate #1  Bad    2 #2 Good    2 #3     1 A.K. - Original Message - From: Ye Lin To: R help Cc: Sent: Thursday, April 18, 2013 6:46 PM Subject: [R] count each answer category in each column Hey, Is it possible that R can calculate each options unde

[R] count each answer category in each column

2013-04-18 Thread Ye Lin
Hey, Is it possible that R can calculate each options under each column and return a summary table? Suppose I have a table like this: Gender Age Rate Female0-10 Good Male0-10 Good Female 11-20 Bad Male 11-20 Bad Male >20 N/A I want to have a summary

Re: [R] count values

2013-04-18 Thread arun
 vec1<- c(0,1,1,1,2,2,2,3,3) length(unique(vec1[vec1!=0])) #[1] 3  vec2<- c(0,2,2,3)  length(unique(vec2[vec2!=0])) #[1] 2 A.K. >Hi. I have a new question. >I need count the different numbers in a vector,but different of zero. >I mean,if I have c(0,2,2,3) the result is 2. If the  >vector is c(

Re: [R] count by value

2013-04-10 Thread Rui Barradas
Hello, Any of the two lapply intructions will give what you want. The difference is in the definition of "decade". In the first case, it's ten years starting 1592. So the first decade are the 10 years 1592, 1593, ..., 1601, the second decade are the 10 years 1602, ..., 1611, etc. In the second

Re: [R] count by value

2013-04-10 Thread David Winsemius
On Apr 9, 2013, at 11:45 AM, catalin roibu wrote: Hello all! I have a big problem now. I want a data frame like this: dput(head(test,100)) structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,

Re: [R] count by value

2013-04-10 Thread Jim Lemon
On 04/10/2013 04:45 AM, catalin roibu wrote: Hello all! I have a big problem now. I want a data frame like this: dput(head(test,100)) > ... Now I want to group rownames (in this case year) in 10 years classes and I want to count for each 10 years classe (decade) the number of major and minor ev

[R] count by value

2013-04-09 Thread catalin roibu
Hello all! I have a big problem now. I want a data frame like this: dput(head(test,100)) structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA

Re: [R] count NAs with aggregate

2013-03-25 Thread Rui Barradas
Hello, The problem seems to be with the formula interface. # Make up some data var1 <- rnorm(100) var2 <- rnorm(100) var3 <- rnorm(100) subject <- sample(4, 100, replace = TRUE) time <- sample(10, 100, replace = TRUE) var1[sample(100, 10)] <- NA var2[sample(100, 10)] <- NA var3[sample(100, 10)]

[R] count NAs with aggregate

2013-03-25 Thread Timo Stolz
Dear members of this list, I'd like to count missing values using the aggregate function. Something like this: count_nas <- function(arg1) { return(sum(is.na(arg1))) } aggregate(cbind(var1, var2, var3) ~ subject + time, data = mydataset, count_nas) It's not working: I end up with a matri

  1   2   3   4   >