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
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
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
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.
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
Dear Thomas,
How about this?
> table(apply(Data, 1, paste, collapse=","))
1,1,1 1,2,1 1,3,2
1 2 1
I hope this helps,
John
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas
> Chesney
> Sent: September 10, 2015 9:11 AM
> To: r-hel
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
Assuming your data is already in R format please sent it dput() format. See
?dput or
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
and http://adv-r.had.co.nz/Reproducibility.html for more details.
John Kane
Kingston ON Canada
> -Original Message--
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:
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",
Hi
I am little bit lost in your logic. Why triple in your fourth line is one. I
expected it will be four?
Petr
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Knut
> Krueger
> Sent: Friday, June 26, 2015 10:10 AM
> To: r-h...@stat.math.ethz.ch
> Su
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
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
Thanks, Peter. Why not cbind your idea for the first column with my idea
for the second column and get it done in one line?:
v <- c(1,2,5,6,7,8,25,30,31,32,33)
M <- cbind( v[ c(1, which( diff(v) !=1 ) + 1 ) ] , rle( v - 1:length(v)
)$lengths )
M
[,1] [,2]
[1,]12
[2,]54
[3
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 = .
Here is another approach:
> v <- c(1,2,5,6,7,8,25,30,31,32,33)
>
> # split by differences != 1
> t(sapply(split(v, cumsum(c(1, diff(v)) != 1)), function(x){
+ c(value = x[1L], length = length(x)) # output first value and length
+ }))
value length
0 1 2
1 5 4
225 1
Tena koe Mike
An alternative, which is slightly fast:
diffv <- diff(v)
starts <- c(1, which(diffv!=1)+1)
cbind(v[starts], c(diff(starts), length(v)-starts[length(starts)]+1))
Peter Alspach
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Mike Mill
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,
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
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,
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
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,
Hi,
I'm sorry that it takes me so much time to respond, finally yesterday I got
time to try your suggestions. Thank you for them!
I tried both, they give the same results, but in both there are some things
I still need to solve. I would appreciate your help.
I include a little bigger dataframe (t
Hi
rrr<-rle(as.numeric(cut(test$act, c(0,1,199,200), include.lowest=T)))
test$res <- rep(rrr$lengths, rrr$lengths)
If you put it in function
fff<- function(x, limits=c(0,1,199,200)) {
rrr<-rle(as.numeric(cut(x, limits, include.lowest=T)))
res <- rep(rrr$lengths, rrr$lengths)
res
}
you can use s
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,
library(plyr)
df1<-count(df)
rep(df1[,1],df1[,2]*100)
count(as.character(rep(df1[,1],df1[,2]*100)))
# x freq
#1 A 200
#2 B 200
#3 C 200
#4 D 400
#5 F 400
A.K.
- Original Message -
From: Katherine Gobin
To: r-help@r-project.org
Cc:
Sent: Tuesday, March 26, 2013 4:12 AM
Subjec
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",
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
> > 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 'within'
function in R for this problem?
For example, something that behaves more or less like
within <- function(x, interval=N
# user system elapsed
> # 0.500 0.000 0.502
> res1
> #[1] 80070
>
>
> A.K.
>
>
>
>
>
>
> ________
> From: Jim Silverton
> To: arun
> Sent: Monday, March 18, 2013 10:08 AM
> Subject: Re: [R] Counting confidence intervals
>
>
> t
user system elapsed
# 0.500 0.000 0.502
res1
#[1] 80070
A.K.
From: Jim Silverton
To: arun
Sent: Monday, March 18, 2013 10:08 AM
Subject: Re: [R] Counting confidence intervals
thanks arun!!
On Mon, Mar 18, 2013 at 10:06 AM, arun wrote:
Hi,
gt; #[1] 80070
> head(mat2[sapply(seq_len(nrow(mat2)),function(i)
> any(seq(mat2[i,1],mat2[i,2])==12)),])
> # [,1] [,2]
> #[1,]7 29
> #[2,] 11 30
> #[3,]3 30
> #[4,]2 26
> #[5,] 10 22
> #[6,]6 22
> A.K.
>
>
>
>
>
Thanks.
Jeff
On Mon, Mar 18, 2013 at 9:30 AM, Jeff Newmiller wrote:
> sum(M[1]<12 & 12<=M[2]) untested, no data
> ---
> Jeff NewmillerThe . . Go Live...
> DCN:Basics: ##.#.
[,1] [,2]
#[1,] 7 29
#[2,] 11 30
#[3,] 3 30
#[4,] 2 26
#[5,] 10 22
#[6,] 6 22
A.K.
From: Jim Silverton
To: r-help@r-project.org
Sent: Monday, March 18, 2013 9:03 AM
Subject: Re: [R] Counting confidence intervals
Hi,
I have a
sum(M[1]<12 & 12<=M[2]) untested, no data
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dea
Hi Jim,
Try either of the following (untested):
sum( x[1, ] < 12 & x[2, ] > 12)
sum(apply(x, 2, function(x) x[1] < 12 & x[2] > 12))
where "x" is your 2x1000 matrix.
HTH,
Jorge.-
On Tue, Mar 19, 2013 at 12:03 AM, Jim Silverton <> wrote:
> Hi,
> I have a 2 x 1 matrix of confidence interva
Hi,
I have a 2 x 1 matrix of confidence intervals. The first column is the
lower and the next column is the upper. I want to cont how many times a
number say 12 lies in the interval. Can anyone assist?
--
Thanks,
Jim.
[[alternative HTML version deleted]]
Hello,
As you know R better it will take you less and less time to get it
right, and almost surely less and less lines of code to do the same
thing. Here's a one liner:
set.seed(1510)
s=numeric(length=10)
for(i in 1:10){
pop=(rbeta(n=20,shape1=2,shape2=1))
s[i]=sum(pop)
}
set.se
, October 22, 2012 5:26 PM
Subject: Re: [R] Counting duplicates in a dataframe
On Oct 22, 2012, at 7:48 AM, arun wrote:
> HI,
> Another way:
> dat1<-read.table(text="
> Observation Gender Dosage Alertness
> 1 1 m a 8
> 2 2
Thank you all; David -- this is, in fact, exactly what I need!
Asaf
--
View this message in context:
http://r.789695.n4.nabble.com/Counting-duplicates-in-a-dataframe-tp4646954p4647075.html
Sent from the R help mailing list archive at Nabble.com.
__
On Oct 22, 2012, at 7:48 AM, arun wrote:
> HI,
> Another way:
> dat1<-read.table(text="
> Observation Gender Dosage Alertness
> 11 m a8
> 22 m a12
> 33 m a13
> 44 m a12
> 5
HI,
Another way:
dat1<-read.table(text="
Observation Gender Dosage Alertness
1 1 m a 8
2 2 m a 12
3 3 m a 13
4 4 m a 12
5 5 m b 6
6 6 m b
Hi,
try this:
dat1<-read.table(text="
Observation Gender Dosage Alertness
1 1 m a 8
2 2 m a 12
3 3 m a 13
4 4 m a 12
5 5 m b 6
6 6 m b
Hi
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of asafwe
> Sent: Monday, October 22, 2012 4:02 AM
> To: r-help@r-project.org
> Subject: [R] Counting duplicates in a dataframe
>
> Hello,
>
> I am looking at a two-way ANOVA d
Thank you, all !
That's very helpful.
Kind regards,
Chintanu
=
On Fri, Jul 27, 2012 at 12:57 PM, arun wrote:
> Hi,
>
> Try this:a<-c(4,5,23,34,43,54,56,65,67,324,435,453,456,567,657)
> a1<-melt(table(cut(a,breaks=c(0,10,20,30,60,120,240,480,960
> a2<-d
Hi,
Try this:a<-c(4,5,23,34,43,54,56,65,67,324,435,453,456,567,657)
a1<-melt(table(cut(a,breaks=c(0,10,20,30,60,120,240,480,960
a2<-data.frame(sapply(a1,function(x) gsub("\\(|\\]","",gsub("\\,","-",x
colnames(a2)<-c("numbers","Freq")
a2
# numbers Freq
#1 0-10 2
#2 10-20 0
#3
1 - 100 of 344 matches
Mail list logo