Thanks, everyone!
Quoting Jim Lemon :
Oops, I sent this to Tom earlier today and forgot to copy to the list:
VendorID=rep(paste0("V",1:10),each=5)
AcctID=paste0("A",sample(1:5,50,TRUE))
Data<-data.frame(VendorID,AcctID)
table(Data)
# get multiple vendors for each account
dupAcctID<-colSums(t
Oops, I sent this to Tom earlier today and forgot to copy to the list:
VendorID=rep(paste0("V",1:10),each=5)
AcctID=paste0("A",sample(1:5,50,TRUE))
Data<-data.frame(VendorID,AcctID)
table(Data)
# get multiple vendors for each account
dupAcctID<-colSums(table(Data)>0)
Data$dupAcct<-NA
# fill in the
On Wed, Nov 18, 2020 at 5:40 AM Bert Gunter wrote:
>
> z <- with(Data2, tapply(Vendor,Account, I))
> n <- vapply(z,length,1)
> data.frame (Vendor = unlist(z),
>Account = rep(names(z),n),
>NumVen = rep(n,n)
> )
>
> ## which gives:
>
>Vendor Account NumVen
> A1 V1 A1 1
> A
z <- with(Data2, tapply(Vendor,Account, I))
n <- vapply(z,length,1)
data.frame (Vendor = unlist(z),
Account = rep(names(z),n),
NumVen = rep(n,n)
)
## which gives:
Vendor Account NumVen
A1 V1 A1 1
A21 V2 A2 3
A22 V3 A2 3
A23 V1 A2 3
.
-Original Message-
From: R-help On Behalf Of Tom Woolman
Sent: Tuesday, November 17, 2020 6:30 PM
To: Bill Dunlap
Cc: r-help@r-project.org
Subject: Re: [R] counting duplicate items that occur in multiple groups
Hi Bill. Sorry to be so obtuse with the example data, I was trying (too hard)
not
Why 0's in the data frame? Shouldn't that be 1 (vendor with that account)?
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Tue, Nov 17, 2020 at 3:29 PM Tom
Yes, good catch. Thanks
Quoting Bert Gunter :
Why 0's in the data frame? Shouldn't that be 1 (vendor with that account)?
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County"
Hi Bill. Sorry to be so obtuse with the example data, I was trying
(too hard) not to share any actual values so I just created randomized
values for my example; of course I should have specified that the
random values would not provide the expected problem pattern. I should
have just used s
What should the result be for
Data1 <- data.frame(Vendor=c("V1","V2","V3","V4"),
Account=c("A1","A2","A2","A2"))
?
Must each vendor have only one account? If not, what should the result be
for
Data2 <- data.frame(Vendor=c("V1","V2","V3","V1","V4","V2"),
Account=c("A1","A2","A2","A2","A3","A4
Inline.
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Tue, Nov 17, 2020 at 1:20 PM Tom Woolman
wrote:
> Hi everyone. I have a dataframe that is a collectio
Hi everyone. I have a dataframe that is a collection of Vendor IDs
plus a bank account number for each vendor. I'm trying to find a way
to count the number of duplicate bank accounts that occur in more than
one unique Vendor_ID, and then assign the count value for each row in
the dataframe
emius
Sent: Thursday, March 21, 2019 5:55 PM
To: reichm...@sbcglobal.net; 'r-help mailing list'
Subject: Re: [R] counting unique values (summary stats)
On 3/21/19 3:31 PM, reichm...@sbcglobal.net wrote:
> r-help
>
> I have the following little scrip to create a df of summary stats. I&
On 3/21/19 3:31 PM, reichm...@sbcglobal.net wrote:
r-help
I have the following little scrip to create a df of summary stats. I'm
having problems obtaining the # of unique values
unique=sapply(myData, function (x)
length(unique(x), replace = TRUE))
I just looked up
r-help
I have the following little scrip to create a df of summary stats. I'm
having problems obtaining the # of unique values
unique=sapply(myData, function (x)
length(unique(x), replace = TRUE))
Can I do that, or am I using the wrong R function?
summary.stats <- data
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
To be fair, the OP did provide brief snippets of data.table usage below the
data dump indicating some level of effort, but posted it all in HTML (what you
see we do not see), did not make the example reproducible (dput is great, and
library calls really clear things up [1][2][3]), and this looks
> On Jun 21, 2017, at 2:50 PM, Ek Esawi wrote:
>
> I have a data.table which is shown below. I want to count combinations of
> columns on i and count on j with by. A few examples are given below the
> table.
>
>
>
> I want to:
>
> all months to show on the output including those that they ha
Have you gone through any R tutorials? If not, why not? If so, maybe
you need to spend some more time with them.
It looks like you want us to do your work for you. We don't do this.
See (and follow) the posting guide below for what we might do (we're
volunteers, so no guarantees).
Cheers,
Bert
I have a data.table which is shown below. I want to count combinations of
columns on i and count on j with by. A few examples are given below the
table.
I want to:
all months to show on the output including those that they have zero value
I want the three statements combined in on if possible
Let's be a bit careful.
You'll probably need a regular expression. But maybe a regex can't work in
principle, so one can't just gloss over the details.
You said: "blah blah blah" can contain ANY text. If this is true, "blah blah
blah" could contain the delimiters. If that is the case, a regex i
What's the expected output for this sample?
How do _you_ define what should be counted?
> On Apr 26, 2017, at 8:33 AM, Dan Abner wrote:
>
> Hi all,
>
> I was not clearly enough in my example code. Please see below where "blah
> blah blah" can be ANY text or numbers: No predictable pattern
Hi all,
I was not clearly enough in my example code. Please see below where "blah
blah blah" can be ANY text or numbers: No predictable pattern at all to
what may or may not be written in place of "blah blah blah".
text1<-c("blah blah blah.
blah blah blah
1) blah blah blah 1
2) blah blah blah
10)
Thanks, Ista. I thought there might be a "tidy" way to do this, but I
hadn't use stringr.
-- Mike
On Tue, Apr 25, 2017 at 8:47 PM, Ista Zahn wrote:
> stringr::str_count (and stringi::stri_count that it wraps) interpret
> the pattern argument as a regular expression by default.
>
> Best,
> Ista
stringr::str_count (and stringi::stri_count that it wraps) interpret
the pattern argument as a regular expression by default.
Best,
Ista
On Tue, Apr 25, 2017 at 11:40 PM, Michael Hannon
wrote:
> I like Boris's "Hadley" solution. For the record, I've appended a
> version that uses regular expres
I like Boris's "Hadley" solution. For the record, I've appended a
version that uses regular expressions, the only benefit of which is
that it could be generalized to find more-complicated patterns.
-- Mike
counts <- sapply(text1, function(next_string) {
loc_example <- length(gregexpr("Exampl
I should add: there's a str_count() function in the stringr package.
library(stringr)
str_count(text1, "Example")
# [1] 5 5 5 5
I guess that would be the neater solution.
B.
> On Apr 25, 2017, at 8:23 PM, Boris Steipe wrote:
>
> How about:
>
> unlist(lapply(strsplit(text1, "Example"), func
How about:
unlist(lapply(strsplit(text1, "Example"), function(x) { length(x) - 1 } ))
Splitting your string on the five "Examples" in each gives six elements.
length(x) - 1 is the number of
matches. You can use any regex instead of "example" if you need to tweak what
you are looking for.
B.
Hi all,
I am looking for a streamlined way of counting the number of enumerated
items are each element of a character vector. For example:
text1<-c("This is an example.
List 1
1) Example 1
2) Example 2
10) Example 10
List 2
1) Example 1
2) Example 2
These have been examples.","This is another ex
On 03/10/15 04:42, David Winsemius wrote:
On Oct 2, 2015, at 2:33 AM, Duncan Murdoch wrote:
The zoo package replaces as.Date.numeric() with a function that
assumes an origin of "1970-01-01". There may be other packages
that also make a replacement like this. David appears to have one
of t
On Oct 2, 2015, at 2:33 AM, Duncan Murdoch wrote:
> On 01/10/2015 11:29 PM, Rolf Turner wrote:
>> On 02/10/15 15:47, David Winsemius wrote:
>>
>>
>>
>>> On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote:
P.S. I have been unable to find a corresponding vector of the names
of the day
On 01/10/2015 11:29 PM, Rolf Turner wrote:
> On 02/10/15 15:47, David Winsemius wrote:
>
>
>
>> On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote:
>>>
>>> P.S. I have been unable to find a corresponding vector of the names
>>> of the days of the week, although I have a very vague recollection
>>> of
On Oct 1, 2015, at 8:29 PM, Rolf Turner wrote:
> On 02/10/15 15:47, David Winsemius wrote:
>
>
>
>> On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote:
>>>
>>> P.S. I have been unable to find a corresponding vector of the names
>>> of the days of the week, although I have a very vague recollection
On 02/10/15 15:47, David Winsemius wrote:
On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote:
P.S. I have been unable to find a corresponding vector of the names
of the days of the week, although I have a very vague recollection
of the existence of such a vector. Does it exist, and if so what
is
On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote:
> On 02/10/15 10:54, peter dalgaard wrote:
>
>>> On 01 Oct 2015, at 23:04 , Rolf Turner
>>> wrote:
>>>
>>> On 02/10/15 03:45, David L Carlson wrote:
>>>
>>>
>>>
If you want the month names:
> mnt <- c("Jan", "Feb", "Mar", "Apr",
On 02/10/15 10:54, peter dalgaard wrote:
On 01 Oct 2015, at 23:04 , Rolf Turner
wrote:
On 02/10/15 03:45, David L Carlson wrote:
If you want the month names:
mnt <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "July", "Aug", "Sep", "Oct", "Nov", "Dec")
dimnames(tbl)$Month <- mnt
U
> On 01 Oct 2015, at 23:04 , Rolf Turner wrote:
>
> On 02/10/15 03:45, David L Carlson wrote:
>
>
>
>> If you want the month names:
>>
>>> mnt <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun",
>> + "July", "Aug", "Sep", "Oct", "Nov", "Dec")
>>> dimnames(tbl)$Month <- mnt
>
>
>
> Unnecessary
On 02/10/15 03:45, David L Carlson wrote:
If you want the month names:
mnt <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "July", "Aug", "Sep", "Oct", "Nov", "Dec")
dimnames(tbl)$Month <- mnt
Unnecessary typing; there is a built-in data set "month.abb" (in the
"base" package) that is
31
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
From: smart hendsome [mailto:putra_autum...@yahoo.com]
Sent: Wednesday, September 30, 2015 9:24 PM
To: David L Carlson
Subject: Re: [R] Counting number of rain
df <- data.frame( V1= 1, V2= c( 2, 3, 2, 1), V3= c( 1, 2, 1, 1))
dfO <- df[ do.call( order, df), ]
dfOD <- duplicated( dfO)
dfODTrigger <- ! c( dfOD[-1], FALSE)
dfOCounts <- diff( c( 0, which( dfODTrigger)))
cbind( dfO[ dfODTrigger, ], dfOCounts)
V1 V2 V3 dfOCounts
4 1 1 1 1
3 1 2
Have a look at the dplyr package
library(dplyr)
n <- 1000
data_frame(
V1 = sample(0:1, n, replace = TRUE),
V2 = sample(0:1, n, replace = TRUE),
V3 = sample(0:1, n, replace = TRUE)
) %>%
group_by(V1, V2, V3) %>%
mutate(
Freq = n()
)
ir. Thierry Onkelinx
Instituut voor natuur- en b
10, 2015 9:11 AM
> To: r-help@r-project.org
> Subject: [R] Counting occurrences of a set of values
>
> Can anyone suggest a way of counting how frequently sets of values occurs in a
> data frame? Like table() only with sets.
>
> So for a dataset:
>
> V1, V2, V3
> 1, 2
On 10/09/2015 9:11 AM, Thomas Chesney wrote:
> Can anyone suggest a way of counting how frequently sets of values occurs in
> a data frame? Like table() only with sets.
Do you want 1,2,1 to be the same as 1,1,2, or different? What about
1,2,2? For sets, those are all the same, but for most purp
Can anyone suggest a way of counting how frequently sets of values occurs in a
data frame? Like table() only with sets.
So for a dataset:
V1, V2, V3
1, 2, 1
1, 3, 2
1, 2, 1
1, 1, 1
The output would be something like:
1,2,1: 2
1,3,2: 1
1,1,1: 1
Thank you,
Thomas Chesney
This message and an
age-
> From: r-help@r-project.org
> Sent: Tue, 8 Sep 2015 06:58:58 + (UTC)
> To: r-help@r-project.org
> Subject: [R] Counting number of rain
>
> Hello R-users,
> I want to ask how to count the number of daily rain data. My data as
> below:
> Year Month Day Amoun
Try the following:
## step 1: write raw data to an array
junk<-scan('clipboard')
# entering the numbers (not the 'year' etc. labels) into R as a vector after
junk<-t(array(junk,dim=c(4,length(junk)/4)))
# convert the vector into a 2-d array with 4 columns (year, month, day,
amount)
## step 2:
Hello R-users,
I want to ask how to count the number of daily rain data. My data as below:
Year Month Day Amount 1901 1 1 0 1901 1 2 3 1901 1 3 0 1901 1 4 0.5 1901 1 5 0
1901 1 6 0 1901 1 7 0.3 1901 1 8 0 1901 1 9 0 1901 1 10 0 1901 1 11 0.5 1901 1
12 1.8 1901 1 13 0 1901 1 14 0 1901 1 15 2.5
to:r...@knut-krueger.de]
> Sent: Friday, June 26, 2015 12:50 PM
> To: PIKAL Petr; r-h...@stat.math.ethz.ch
> Subject: Re: [R] counting similar strings in data.frame
>
> Am 26.06.2015 um 10:38 schrieb PIKAL Petr:
> > Hi
> >
> > I am little bit lost in your logic. Why tripl
Am 26.06.2015 um 10:38 schrieb PIKAL Petr:
Hi
I am little bit lost in your logic. Why triple in your fourth line is one. I
expected it will be four?
Petr
Sorry yes you are right ...
type mismatch
Knut
__
R-help@r-project.org mailing list -- To UNS
Sorry last count was wrong ...
test =data.frame("first"=c("seven","two","five","four"),
"second"=c("three","one","three","one"),
"third"=c("four","two","three","four"),
"fourth"=c("four","one","one","four"))
count =data.frame("dobule1"=c("four",
at.math.ethz.ch
> Subject: [R] counting similar strings in data.frame
>
> Dear Members,
>
> is there a better solution to count the amounts of occurrence in a row
> with string data than with loops to get the count data.frame?
>
> test =data.frame("first"=c("seven
Dear Members,
is there a better solution to count the amounts of occurrence in a row
with string data than with loops to get the count data.frame?
test =data.frame("first"=c("seven","two","five","four"),
"second"=c("three","one","three","one"),
"third"=c("four
I normally use rle() for these problems, see ?rle.
for instance,
k <- rbinom(999, 1, .5)
series <- function(run) {
Assuming I understand the problem correctly, you want to check for
runs of at least length five where both Score and Test_desc assume
particular values. You don't care where they are or what other data
are associated, you just want to know if at least one such run exists
in your data frame.
Here's
Hi,
I have the following dataframe
structure(list(Type = c("QRS", "QRS", "QRS", "QRS", "QRS", "QRS",
"QRS", "QRS", "QRS", "QRS", "QRS", "QRS", "RR", "RR", "RR", "PP",
"PP", "PP", "PP", "PP", "PP", "PP", "PP", "PP", "QTc", "QTc",
"QTc", "QTc", "QTc", "QTc", "QTc", "QTc", "QTc", "QTc", "QTc",
"QTc"
That' s perfect. Many thanks forma your appreciated help.
El 22/01/2015 19:50, "Chel Hee Lee" escribió:
> > x <- c("hola mundo mundo");
> > table(unlist(strsplit(x, " ")))
>
> hola mundo
> 1 2
> >
>
> Is this what you are looking for? I hope this helps.
>
> Chel Hee Lee
>
> On 1/22/2015
In addition to the other suggestions, which are fine for your simple
example, I would take a trip to the CRAN Task View "Natural Language
Processing", and see if there's anything there.
-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423
table(strsplit("hola mundo mundo", " ")[[1]])
On Thu, Jan 22, 2015 at 9:25 AM, bgnumis bgnum wrote:
> Hi all,
>
> I want to cout the different words in a text.
>
> You see if the text is: "hola mundo mundo" the program will count:
>
> hola 1
> mundo 2
>
> Is posible that Cran r have a similar fun
> x <- c("hola mundo mundo");
> table(unlist(strsplit(x, " ")))
hola mundo
1 2
>
Is this what you are looking for? I hope this helps.
Chel Hee Lee
On 1/22/2015 8:25 AM, bgnumis bgnum wrote:
Hi all,
I want to cout the different words in a text.
You see if the text is: "hola mundo m
Hi all,
I want to cout the different words in a text.
You see if the text is: "hola mundo mundo" the program will count:
hola 1
mundo 2
Is posible that Cran r have a similar function?
[[alternative HTML version deleted]]
__
R-help@r-project.
ginal Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Mike Miller
Sent: Monday, 5 January 2015 1:03 p.m.
To: R-Help List
Subject: [R] counting sets of consecutive integers in a vector
I have a vector of sorted positive integer values (e.g., postive integers after
ap
Here is a solution using data.table
> require(data.table)
> x <- data.table(v, diff = cumsum(c(1, diff(v)) != 1))
> x
v diff
1: 10
2: 20
3: 51
4: 61
5: 71
6: 81
7: 252
8: 303
9: 313
10: 323
11: 333
> x[, list(value = v[1L], length = .
oject.org] On Behalf Of Mike
> Miller
> Sent: Monday, 5 January 2015 1:03 p.m.
> To: R-Help List
> Subject: [R] counting sets of consecutive integers in a vector
>
> I have a vector of sorted positive integer values (e.g., postive integers
> after applying sort() and unique()). F
f Mike Miller
Sent: Monday, 5 January 2015 1:03 p.m.
To: R-Help List
Subject: [R] counting sets of consecutive integers in a vector
I have a vector of sorted positive integer values (e.g., postive integers after
applying sort() and unique()). For example, this:
c(1,2,5,6,7,8,25,30,31,32,33)
I w
I have a vector of sorted positive integer values (e.g., postive integers
after applying sort() and unique()). For example, this:
c(1,2,5,6,7,8,25,30,31,32,33)
I want to make a matrix from that vector that has two columns: (1) the
first value in every run of consecutive integer values, and (2
rk and how to adapt them:
> ave(dfa$value, dfa$group, FUN=length)
[1] 3 3 3 4 4 4 4 1
> ave(dfa$value, dfa$group)
[1] 2 2 2 3 3 3 3 1
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Messag
Help file ?ave should apply here.
Please read the Posting Guide mentioned in the footer of every email on this
list and on the list manager page for this mailing list. It warns you to read
the archives before posting and to post in plain text format rather than HTML
format.
Hi everyone!
I have problems finding a solution to the following two problems:
My sample-dataframe consists of two variables "group" and "value":
group<-c("A", "A", "A", "B", "B", "B", "B", "C")
value<-c(1,3,2,2,2,4,4,1)
df<-as.data.frame(cbind(group, value))
Problem 1:
**
Now I'd like
Hi,
Try:
set.seed(42)
X <- as.data.frame(matrix(sample(0:1, 4*50,replace=TRUE), ncol=4))
table(X[1:2])[4]
#[1] 15
sum(rowSums(X[1:2])==2)
#[1] 15
A.K.
On Saturday, June 21, 2014 10:59 AM, Kate Ignatius
wrote:
I have 4 columns, and about 300K plus rows with 0s and 1s.
I'm trying to count h
Thanks!
On Sat, Jun 21, 2014 at 11:05 AM, Jorge I Velez
wrote:
> Hi Kate,
>
> You could try
>
> sum(X[, 1] == 1 & X[, 2] == 1)
>
> where X is your data set.
>
> HTH,
> Jorge.-
>
>
>
> On Sun, Jun 22, 2014 at 12:57 AM, Kate Ignatius
> wrote:
>>
>> I have 4 columns, and about 300K plus rows with
Hi Kate,
You could try
sum(X[, 1] == 1 & X[, 2] == 1)
where X is your data set.
HTH,
Jorge.-
On Sun, Jun 22, 2014 at 12:57 AM, Kate Ignatius
wrote:
> I have 4 columns, and about 300K plus rows with 0s and 1s.
>
> I'm trying to count how many rows satisfy a certain criteria... for
> instan
I have 4 columns, and about 300K plus rows with 0s and 1s.
I'm trying to count how many rows satisfy a certain criteria... for
instance, how many rows are there that have the first column == 1 as
well as the second column == 1.
I've tried using rowSums and colSums but it keeps giving me this type
Hi all ,
I have a package and i want to count the 1st
execution day of the package till 30 days afterwards ?
I hope I am clear with this question .
Please reply if you have anything to share .
Thanks
ASHIS
[[alternative HTML version deleted]]
Hi,
May be this helps:
vec1 <- c("victory","happiness","medal","war","service","ribbon", "dates")
vec2 <- c("The World War II Victory Medal was first issued as a service ribbon
referred to as the Victory Ribbon.", "By 1946, a full medal had been
established which was referred to as the World W
On 01/23/2014 04:49 PM, Hervé Pagès wrote:
Hi Mintewab,
With the IRanges packages (from Bioconductor):
> library(IRanges)
> countMatches(z, w)
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 0 3 1 1 0 1 0 0 0 0 0 0 1 3
2 0 0 1 0 0
[39] 0 0 0 0 0 0 0 0
And if you don't want to depend on I
Here's a solution:
# This gives a vector of counts (if z is a data frame, first convert
it to a matrix)
res = sapply(as.vector(z), function(x) sum(w==x))
# This copies the dimensions of the variable 'z' to 'res':
dim(res) = dim(z)
Peter
On Thu, Jan 23, 2014 at 7:43 AM, wrote:
>Hi all,
> I
Hi Mintewab,
With the IRanges packages (from Bioconductor):
> library(IRanges)
> countMatches(z, w)
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 0 3 1 1 0 1 0 0 0 0 0 0 1 3
2 0 0 1 0 0
[39] 0 0 0 0 0 0 0 0
To install the IRanges package:
source("http://bioconductor.org/biocLite.R";)
Thank you for the reproducible example, but your description is missing a clear
definition of what you want.
For example, if your desired output is
result <- c(rep(0,16),2,1,0,3,1,1,0,1,0,0,0,0,0,0,1,3,2,0,0,1,rep(0,10))
then one answer might be
as.vector(table(factor(w,levels=z)))
--
Many thanks, Arun.
Res 1 is exactly what I wanted.
Mintewab
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of arun
Sent: 23 January 2014 16:27
To: R help
Subject: Re: [R] counting matches in two vectors
Hi,
May be this helps:
z1
Also,
res3 <- table(z1[match(w,z1)])
identical(res3,res1)
#[1] TRUE
A.K.
On Thursday, January 23, 2014 11:26 AM, arun wrote:
Hi,
May be this helps:
z1 <- factor(z)
res1 <- table(z1[cut(w,breaks=c(-Inf,z,Inf),labels=F)])
res1
#
#-5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Hi,
May be this helps:
z1 <- factor(z)
res1 <- table(z1[cut(w,breaks=c(-Inf,z,Inf),labels=F)])
res1
#
#-5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# 0 0 0 0 0 0 0 0 0 0 2 1 0 3 1 1 0 1 0 0 0 0 0 0 1 3
#21 22 23 24 25 26 27 28 29 30 31 32
Hi all,
I have the following reproducible example
z<-c(-5:40)
w<-c(11, 11, 12, 14, 14, 14, 15, 16, 18, 25, 26, 26, 26, 27, 27, 30)
r<-z %in% w
now r gives me the presence or absence of elements in z that are in w but I am
interested in getting the number of times each element in z appears (o
Hi,
Try:
data_m <- read.table(text="Abortusovis07918 Agona08561 Anatum08125 Arizonae65S
Braenderup08488
1 S5305B_IGR S5305B_IGR S5305B_IGR S5305B_IGR S5305B_IGR
2 S5305A_IGR S5300A_IGR S5305A_IGR S5300A_IGR S5300A_IGR
3 S5300A_IGR S5300B_IGR S5300A_IGR S5300B_IGR S5300B_IGR
4
Hi!
I'm new in R and I'm writing you asking for some guidance. I had
analyzed a comparative genomic microarray data of /56 Salmonella/
strains to identify absent genes in each of the serovars, and finally I
got a matrix that looks like that:
> data[1:5,1:5]
Abortusovis07918 Agona08561 Anat
I got sorted,
Thanks all
On Fri, Oct 4, 2013 at 2:03 PM, S Ellison wrote:
> > I have a set of data and I need to find out how many points are below a
> > certain value but R will not calculate this properly for me.
> R will. But you aren't.
>
> > Negative numbers seem to be causing the issue.
> I have a set of data and I need to find out how many points are below a
> certain value but R will not calculate this properly for me.
R will. But you aren't.
> Negative numbers seem to be causing the issue.
You haven't got any negative numbers in your data set. In fact, you haven't got
any nu
It is hard to know exactly what you mean with such a generic question.
If you mean "treat survival as a counting process", then the answer is yes. The survival
package in S (which is the direct ancestor of the Splus package, which is the direct
ancestor of the R package) was the very first to d
s it what you want?
Petr
From: zuzana zajkova [mailto:zuzu...@gmail.com]
Sent: Friday, May 03, 2013 7:10 PM
To: PIKAL Petr; jholt...@gmail.com
Cc: r-help@r-project.org
Subject: Re: [R] Counting number of consecutive occurrences per rows
Hi,
I'm sorry that it takes me so much time to respond,
limits, include.lowest=T)))
> res <- rep(rrr$lengths, rrr$lengths)
> res
> }
>
> you can use split/lapply approach
>
> test$res2<-unlist(lapply(split(test$act, factor(test$day, levels=c(1,0))),
> fff))
>
> Beware of correct ordering of days in output. Without
[0,1] 4
2 14655 (1,199] 1
3 14655 (199,200] 2
Regards
Petr
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of zuzana zajkova
> Sent: Monday, April 29, 2013 12:45 PM
> To: r-help@r-project.org
> Subject
try this:
> test <- structure(list(jul = structure(c(14655, 14655, 14655, 14655,
+ 14655, 14655, 14655, 14655, 14655, 14655, 14655, 14655, 14655,
+ 14655, 14655, 14655), origin = structure(0, class = "Date")),
+ time = structure(c(1266258354, 1266258954, 1266259554, 1266260154,
+ 126626075
Forgot the last part of the question:
> test <- structure(list(jul = structure(c(14655, 14655, 14655, 14655,
+ 14655, 14655, 14655, 14655, 14655, 14655, 14655, 14655, 14655,
+ 14655, 14655, 14655), origin = structure(0, class = "Date")),
+ time = structure(c(1266258354, 1266258954, 1266259554,
Hi,
I would appreciate if somebody could help me with following calculation.
I have a dataframe, by 10 minutes time, for mostly one year data. This is
small example:
> dput(test)
structure(list(jul = structure(c(14655, 14655, 14655, 14655,
14655, 14655, 14655, 14655, 14655, 14655, 14655, 14655, 1
AM
Subject: [R] Counting various elemnts in a vactor
Dear R forum
I have a vector say as given below
df = c("F", "C", "F", "B", "D", "A", "D", "D", "A", "F", "D", "F", "B"
Dear Sir,
Thanks a lot for your great help. I couldn't have figured it out.
Thanks again.
Regards
Katherine
--- On Tue, 26/3/13, D. Rizopoulos wrote:
From: D. Rizopoulos
Subject: Re: [R] Counting various elemnts in a vactor
To: "Katherine Gobin"
Cc: "r-help@r-project
try this:
df <- c("F", "C", "F", "B", "D", "A", "D", "D", "A", "F", "D", "F", "B",
"C")
tab <- table(df)
tab
rep(names(tab), 100 * tab)
I hope it helps.
Best,
Dimitris
On 3/26/2013 9:12 AM, Katherine Gobin wrote:
> Dear R forum
>
> I have a vector say as given below
>
> df = c("F", "C",
Dear R forum
I have a vector say as given below
df = c("F", "C", "F", "B", "D", "A", "D", "D", "A", "F", "D", "F", "B", "C")
I need to find
(1) how many times each element occurs? e.g. in above vector F occurs 4 times,
C occurs 2 times etc.
(2) Depending on the number of occurrences, I ne
You should look at findInterval. Used with as.numeric it could do what you
request although it has a much wider range of uses.
--
David
Sent from my iPhone
On Mar 20, 2013, at 5:15 PM, Greg Snow <538...@gmail.com> wrote:
> The TeachingDemos package has %<% and %<=% functions that can be chain
The TeachingDemos package has %<% and %<=% functions that can be chained
simply, so you could do something like:
sum( 5:1 %<=% 1:5 %<=% 10:14 )
and other similar approaches.
The idea is that you can do comparisons as:
lower %<% x %<% upper
instead of
lower < x & x < upper
On Mon, Mar 18, 2
> There _is_ a function ?within.
Drat! of course there is. I even use it, though not often.
> Maybe your function can be
> named 'between'
Good thought - thanks
Steve E
***
This email and any attachments are confidential. Any u
Hello,
There _is_ a function ?within. Maybe your function can be named 'between'
Rui Barradas
Em 18-03-2013 16:16, S Ellison escreveu:
I want to cont how many
times a number say 12 lies in the interval. Can anyone assist?
Has anyone else ever wished there was a moderately general 'inside' or
1 - 100 of 436 matches
Mail list logo