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 intervals. The
sum(M[1]12 12=M[2]) untested, no data
---
Jeff NewmillerThe . . Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go...
,] 7 29
#[2,] 11 30
#[3,] 3 30
#[4,] 2 26
#[5,] 10 22
#[6,] 6 22
A.K.
From: Jim Silverton jim.silver...@gmail.com
To: r-help@r-project.org
Sent: Monday, March 18, 2013 9:03 AM
Subject: Re: [R] Counting confidence intervals
Hi,
I
Thanks.
Jeff
On Mon, Mar 18, 2013 at 9:30 AM, Jeff Newmiller jdnew...@dcn.davis.ca.uswrote:
sum(M[1]12 12=M[2]) untested, no data
---
Jeff NewmillerThe . . Go Live...
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 2 x 1
0.502
res1
#[1] 80070
A.K.
From: Jim Silverton jim.silver...@gmail.com
To: arun smartpink...@yahoo.com
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 smartpink
Silverton jim.silver...@gmail.com
To: arun smartpink...@yahoo.com
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 smartpink...@yahoo.com wrote:
Hi,
Try this:
set.seed(25)
mat1-
matrix(cbind
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=NULL,
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'
I am new to R and learned to program 10 years ago in C++. I am currently
working a project that looks at the distribution of randomly generated beta
values. I take 20 random beta values find their sum, repeat 10 times.
Here is my code that it took me 4 hours to get
s=numeric(length=10)
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)
}
Hello,
I am looking at a two-way ANOVA dataset, and would like to count the rows in
the dataframe with the same level of the first factor (Gender) and the
second factor (Dosage). In other words, I am interested in the number of
observations per each cell in a (not necessarily balanced) two-way
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 dataset
as...@wharton.upenn.edu
To: r-help@r-project.org
Cc:
Sent: Sunday, October 21, 2012 10:02 PM
Subject: [R] Counting duplicates in a dataframe
Hello,
I am looking at a two-way ANOVA dataset, and would like to count the rows in
the dataframe with the same level of the first factor (Gender) and the
second factor
To: r-help@r-project.org
Cc:
Sent: Sunday, October 21, 2012 10:02 PM
Subject: [R] Counting duplicates in a dataframe
Hello,
I am looking at a two-way ANOVA dataset, and would like to count the rows in
the dataframe with the same level of the first factor (Gender) and the
second factor (Dosage
is that different than:
table(dat1$Gender, dat1$Dosage)
--
David.
A.K.
- Original Message -
From: asafwe as...@wharton.upenn.edu
To: r-help@r-project.org
Cc:
Sent: Sunday, October 21, 2012 10:02 PM
Subject: [R] Counting duplicates in a dataframe
Hello,
I am looking
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.
__
Cc: asafwe as...@wharton.upenn.edu; R help r-help@r-project.org
Sent: Monday, 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
Hi,
This is a simple problem, but for the life of me I cannot find the answer.
How to determine frequency within given ranges ?
I know that table() gives frequency, for example
a - table(numbers)
a
numbers
4 5 23 34 43 54 56 65 67 324 435 453 456 567 657
2 1 2 2 1 1
Combine cut() and table()
Michael
On Jul 26, 2012, at 8:22 PM, Chintanu chint...@gmail.com wrote:
Hi,
This is a simple problem, but for the life of me I cannot find the answer.
How to determine frequency within given ranges ?
I know that table() gives frequency, for example
a -
-bounces@r-
project.org] On Behalf Of Chintanu
Sent: Thursday, July 26, 2012 8:23 PM
To: r-help@r-project.org
Subject: [R] Counting frequency within each range
Hi,
This is a simple problem, but for the life of me I cannot find the
answer.
How to determine frequency within given ranges
.
- Original Message -
From: Chintanu chint...@gmail.com
To: r-help@r-project.org
Cc:
Sent: Thursday, July 26, 2012 9:22 PM
Subject: [R] Counting frequency within each range
Hi,
This is a simple problem, but for the life of me I cannot find the answer.
How to determine frequency within given
: Thursday, July 26, 2012 9:22 PM
Subject: [R] Counting frequency within each range
Hi,
This is a simple problem, but for the life of me I cannot find the answer.
How to determine frequency within given ranges ?
I know that table() gives frequency, for example
a - table(numbers)
a
numbers
4
Dear R,
I have data like this
I I D I D D D D D I D I D I D I D I D D D I D D I I I I
I I I I D I D I D I I I D I I I D I D I D I D I 0 0 I I I I I I I
I I D I D I D I D I I I D I I I D I D I D I D I I I D I I I I I
Now for each row i want to make count in groups
2 in each group for all
Hello,
I have a vector wherein the cases are either uniform or mixed-strings (so
AAA vs ABABABABA). Different parts of the vector apply to
different users, so [1:29] is one guy, [30:50] is another, and [51:70] is
another. There are about
100,000 users, and I have an object that
Hi,
Is there a short way of doing this?
I have the following table in R:
12.0 0.5 0.6 0.2 0 0
12.3 1.2 0.8 0 0 0
13.1 0 1.2 0 0 0
10.1 0 0 0 1.3 0
10.2 1.3
There's almost always a better way than a loop (although
sometimes it isn't worth the effort to figure it out). This time
it's straightforward:
apply(c5[, 2:4], 1, function(x)sum(x 0))
[1] 3 2 1 0 3
Sarah
On Tue, Feb 21, 2012 at 6:04 PM, Valerie Moore vmoore2...@yahoo.com wrote:
Hi,
Is
Valerie,
In additio to Sarah's suggestion, you could also use
rowSums(c5[, 2:4] 0)
HTH,
Jorge.-
On Tue, Feb 21, 2012 at 7:45 PM, Sarah Goslee wrote:
There's almost always a better way than a loop (although
sometimes it isn't worth the effort to figure it out). This time
it's
I have three character strings represented below as seq1, seq2, and seq3. Each
string has a reference character different from the other. Thus, for seq1, the
reference character is U, seq2, S (3rd S from left where A is leftmost
character) and for seq3 Y.
seq1 = PQRTUWXYseq2 = AQSDSSDHRSseq3 =
Hello,
Try
seq1 - 'PQRTUWXY'
seq2 - 'AQSDSSDHRS'
seq3 - 'EEZYJKFFBHO'
ref1 - 'U'
ref2 - 'S'
ref3 - 'Y'
fun - function(seq, chr){
f - function(x, seq, chr){
pos - regexpr(x, seq)
if(pos 0)
99
else
On Feb 19, 2012, at 04:25 , jim holtman wrote:
For completeness, if you want to count all possible four transitions:
x - c(0,1,0,1,0,0,0,1,1,1,0,0,0,1)
# lets keep count of the 4 different transitions that can happen
indx - cbind(head(x, -1), tail(x, -1)) %*% c(2, 1)
table(indx) # 0=0-0,
maris478 wrote
Good afternoon,
I've encountered a little bit of a problem, would appreciate any help
here.
I made a small vector consisting of ones and zeros.
Something like this x - c(0,1,0,1,0,0,1,0), and all I need is to count
how many times 0 becomes 1.
Tried various, of what I
On Sat, Feb 18, 2012 at 11:51:39AM -0800, Pete Brecknock wrote:
maris478 wrote
Good afternoon,
I've encountered a little bit of a problem, would appreciate any help
here.
I made a small vector consisting of ones and zeros.
Something like this x - c(0,1,0,1,0,0,1,0), and all I
tibco.com
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Pete Brecknock
Sent: Saturday, February 18, 2012 11:52 AM
To: r-help@r-project.org
Subject: Re: [R] Counting value changes
maris478 wrote
Good afternoon,
I've
try this:
x - c(0,1,0,1,0,0,0,0)
sum(diff(x) == 1)
[1] 2
On Sat, Feb 18, 2012 at 2:51 PM, Pete Brecknock peter.breckn...@bp.com wrote:
maris478 wrote
Good afternoon,
I've encountered a little bit of a problem, would appreciate any help
here.
I made a small vector consisting of ones
Good afternoon,
I've encountered a little bit of a problem, would appreciate any help here.
I made a small vector consisting of ones and zeros.
Something like this x - c(0,1,0,1,0,0,1,0), and all I need is to count how
many times 0 becomes 1.
Tried various, of what I thought, methods with
Just for clarity, I changed your x a bit - in your version, the 0-1 and 1-0
change occurred the same number of times.
If all your values are 0 and 1, this will work:
x - c(0,1,0,1,0,0,0,1,1,1)
table(diff(x))
-1 0 1
2 4 3
sum(diff(x) == 1)
[1] 3
If other values can occur, it would need
For completeness, if you want to count all possible four transitions:
x - c(0,1,0,1,0,0,0,1,1,1,0,0,0,1)
# lets keep count of the 4 different transitions that can happen
indx - cbind(head(x, -1), tail(x, -1)) %*% c(2, 1)
table(indx) # 0=0-0, 1=0-1, 2=1-0, 3=1-1
indx
0 1 2 3
4 4 3 2
On Sat,
Consider using sapply instead of a for loop, if the code in the sapply
call returns a vector, and every vector is the same length, then
sapply will automatically form it into a matrix for you.
On Sun, Feb 12, 2012 at 12:30 PM, jolo999 jonas.lor...@ebs.de wrote:
It seems to work. Simple and
Amazing. Thanks everybody for the help. I have about 12,000 rows of data
with up to 50 reccurrences, but it seems to work like a charm.
Best,
Kai
On Sun, Feb 12, 2012 at 8:11 AM, Petr Savicky savi...@cs.cas.cz wrote:
On Sat, Feb 11, 2012 at 04:05:25PM -0500, David Winsemius wrote:
On Feb
Dear all,
i have daily stock prices for more than 10 years and want to compute annual
volatilities for certain dates during this period. Since i have found no
easy way to work with time data, the data presents itself in the structure
TIme Index - Stock Price
1 - 15,6
2 - 17
...
...
2010 - 28
Hi,
You can initialize a counter and update it in the loop. An silly example
(unrelated to yours because it was not reproducible) of this technique is:
x - matrix( , ncol = 2, nrow = 26)
n - 0
for(i in letters) {
n - n+1
x[n,] - c(i, n)
}
Best,
Ista
On Sunday, February 12, 2012
It seems to work. Simple and effective!
Thanks!
--
View this message in context:
http://r.789695.n4.nabble.com/Counting-the-loop-round-of-a-for-loop-tp4381319p4381780.html
Sent from the R help mailing list archive at Nabble.com.
__
Hi everybody,
I have a large dataframe similar to this one:
knames -c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af')
kdate - as.Date( c('20111001', '2002', '20101001', '20100315',
'20101201', '20110105', '20101001', '20110504', '20110603', '20110201'),
format=%Y%m%d)
kdata -
Hello Kai
This looks like a fun question.
Here is my solution, I'd be curious to see solutions by other people here.
It can also be tweaked in various ways, and easily put into a function
(actually, if you do it - please put it back online :) )
The only thing that might require some work is the
On Sat, Feb 11, 2012 at 07:17:54PM +0100, Kai Mx wrote:
Hi everybody,
I have a large dataframe similar to this one:
knames -c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af')
kdate - as.Date( c('20111001', '2002', '20101001', '20100315',
'20101201', '20110105', '20101001',
On Feb 11, 2012, at 1:17 PM, Kai Mx wrote:
Hi everybody,
I have a large dataframe similar to this one:
knames -c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af')
kdate - as.Date( c('20111001', '2002', '20101001', '20100315',
'20101201', '20110105', '20101001', '20110504',
On Sat, Feb 11, 2012 at 04:05:25PM -0500, David Winsemius wrote:
On Feb 11, 2012, at 1:17 PM, Kai Mx wrote:
Hi everybody,
I have a large dataframe similar to this one:
knames -c('ab', 'aa', 'ac', 'ad', 'ab', 'ac', 'aa', 'ad','ae', 'af')
kdate - as.Date( c('20111001', '2002',
On Thu, Dec 1, 2011 at 10:32 AM, Douglas Esneault
douglas.esnea...@mecglobal.com wrote:
I am new to R but am experienced SAS user and I was hoping to get some help
on counting the occurrences of a character within a string at a row level.
My dataframe, x, is structured as below:
Col1
I am new to R but am experienced SAS user and I was hoping to get some help on
counting the occurrences of a character within a string at a row level.
My dataframe, x, is structured as below:
Col1
abc/def
ghi/jkl/mno
I found this code on the board but it counts all occurrences of / in the
## It's not a data frame -- it's just a vector.
x
[1] abc/def ghi/jkl/mno
gsub([^/],,x)
[1] / //
nchar(gsub([^/],,x))
[1] 1 2
?gsub
?nchar
-- Bert
On Thu, Dec 1, 2011 at 8:32 AM, Douglas Esneault
douglas.esnea...@mecglobal.com wrote:
I am new to R but am experienced SAS user and I
I used within and vapply:
x - data.frame(Col1 = c(abc/def, ghi/jkl/mno), stringsAsFactors = FALSE)
count.slashes - function(string)sum(unlist(strsplit(string, NULL)) ==
/)within(x, Col2 - vapply(Col1, count.slashes, 1))
Col1 Col21 abc/def 12 ghi/jkl/mno 2
On Thu, Dec 1, 2011
Resending my code, not sure why the linebreaks got eaten:
x - data.frame(Col1 = c(abc/def, ghi/jkl/mno), stringsAsFactors = FALSE)
count.slashes - function(string)sum(unlist(strsplit(string, NULL)) == /)
within(x, Col2 - vapply(Col1, count.slashes, 1))
Col1 Col2
1 abc/def1
2
strsplit is certainly an alternative, but your approach is
unnecessarily complicated and inefficient. Do this, instead:
sapply(strsplit(x,/),length)-1
Cheers,
Bert
On Thu, Dec 1, 2011 at 7:44 PM, Florent D. flo...@gmail.com wrote:
Resending my code, not sure why the linebreaks got eaten:
x -
Inefficient, maybe, but what you suggest does not work if a string
starts or ends with a slash.
On Thu, Dec 1, 2011 at 11:11 PM, Bert Gunter gunter.ber...@gene.com wrote:
strsplit is certainly an alternative, but your approach is
unnecessarily complicated and inefficient. Do this, instead:
On Dec 1, 2011, at 11:11 PM, Bert Gunter wrote:
strsplit is certainly an alternative, but your approach is
unnecessarily complicated and inefficient. Do this, instead:
sapply(strsplit(x,/),length)-1
Definitely more compact that the regex alternates I came up with, but
one of these still
Dear R users,
I am running simulations (1000), and in my simulation I am looking at
specific sums. For example, if the sum is =4 then count this, if say 3,
then don't count, if the sum=3, then generate a random number from uniform
distribution, if this number is say less than 0.5, then count this
How are you computing the sum? Does FAQ 7.31 apply? Showing at least a
sample of your code would help.
On Friday, November 25, 2011, Sl K s.ka...@gmail.com wrote:
Dear R users,
I am running simulations (1000), and in my simulation I am looking at
specific sums. For example, if the sum is =4
You need to read the posting guide. Provide a reproducible code sample,
simplified, with self-contained data.
You might find the ave function useful if you are working with vectorized
simulations.
---
Jeff Newmiller
A) you need to reply-all to keep the discussion on the mailing list.
B) you need to post in plain text.
C) this has the arbitrary smell of homework. This is not a homework help line.
D) You are overwriting your accumulation variable sumt after each test. Since
you are not handling this
Hi,
I am a little new in R but I'm finding it extremely useful :)
Here's my tiny question:
I've got a table with a lot of columns. What I am interested now is to
evaluate how many of 4 columns have a value greater than 1.
I think it can be done with subset() but it will take a very long
try this:
x
Col1 Col2 Col3 Col4
11111
22111
34141
43333
apply(x, 1, function(a) sum(a 1))
[1] 0 1 2 4
x$count - apply(x, 1, function(a) sum(a 1))
x
Col1 Col2 Col3 Col4 count
11111 0
22111
Hi JL,
How about the following?
rowSums(d 1) # d is your data
Best,
Jorge.-
On Thu, Nov 10, 2011 at 10:24 AM, JL Villanueva wrote:
Hi,
I am a little new in R but I'm finding it extremely useful :)
Here's my tiny question:
I've got a table with a lot of columns. What I am interested
Hi:
Here's a toy example:
# Default var names are V1-V20:
u - as.data.frame(matrix(rpois(100, 3), ncol = 20))
u - transform(u,
ngt1 = apply(u[, c('V1', 'V4', 'V9', 'V15')], 1, function(x) sum(x 1)) )
u
HTH,
Dennis
On Thu, Nov 10, 2011 at 7:24 AM, JL Villanueva jlpost...@gmail.com wrote:
Hello
I'm trying to solve this problem without using a for loop but I have so
far failed to find a solution.
I have two matrices of K columns each, e.g. (K=5), and with numbers of
row N_A and N_B respectively
A = (1 5 3 8 15;
2 7 20 11 13;
12 19 20 21 43)
B = (2 6
Try this:
# create dummy data
a - matrix(sample(20, 50, TRUE), ncol = 5)
b - matrix(sample(20, 50, TRUE), ncol = 5)
# create combinations to test
x - expand.grid(seq(nrow(a)), seq(nrow(b)))
# test
result - mapply(function(m1, m2) any(a[m1, ] %in% b[m2, ])
, x[, 1]
, x[, 2]
Jim
I tried that and it works. Thank you very much for your help!
Regards
Pietro
-Original Message-
From: jim holtman [mailto:jholt...@gmail.com]
Sent: 04 November 2011 13:38
To: Parodi, Pietro
Cc: r-help@r-project.org
Subject: Re: [R] Counting number of common elements between
Hi,
I am an R novice and I am trying to do something that it seems should be fairly
simple, but I can't quite figure it out and I must not be using the right words
when I search for answers.
I have a dataset with a number of individuals and observations for each day (7
possible codes plus
Hi:
After cleaning up your data, here's one way using the plyr and
reshape packages:
d - read.csv(textConnection(
Individual, A, B, C, D
Day1, 1,1,1,1
Day2, 1,3,4,2
Day3, 3,,6,4), header = TRUE)
closeAllConnections()
d
library('plyr')
library('reshape')
# Stack the variables
dm - melt(d, id =
Dear all,
I have two matrices lets call them A and B. Each of which is a 100 x 3
matrix. What I do is take the corresponding row from each matrix and form
100 2 x 3 tables. If we call the column sums for each 2 x 3 n1, n2 and n3, I
would like to compute the following probability:
Basically the
You guys are working too hard.
Rgames y - c(0,1,1,3,3,3,5,5,6)
Rgames rle(sort(y))
Run Length Encoding
lengths: int [1:5] 1 2 3 2 1
values : num [1:5] 0 1 3 5 6
--
-
Sent from my Cray XK6
__
R-help@r-project.org mailing list
Dear R users,
I'd like to count the number of integers in a vector y.
Here is an example.
y - c(0,1,1,3,3,3,5,5,6)
In fact, I know how to count the number of specific number in y.
sum(y==0) - 1
sum(y==1) - 2
sum(y==2) - 0
sum(y==3) - 3
sum(y==4) - 0
sum(y==5) - 2
sum(y==6) - 1
However, in
I think there must be an easier solution, but this works:
y - c(0,1,1,3,3,3,5,5,6)
x-matrix(0:6,ncol=1)
apply(x,1,function(x){length(y[y==x])})
HTH,
Daniel
Kathie wrote:
Dear R users,
I'd like to count the number of integers in a vector y.
Here is an example.
y -
Table() or more generally tabulate()
Though, as a general warning, you may need to be a little careful
depending on the source of your data. Once you get into floating point
business, the definition of an integer becomes a little less cut and
dry. If your data are all integer, the data type, then
Slight addendum, tabulate() ignores zeros so you'll need to do tabulate(y+1).
Table will handle zeros but won't look for values that never appear
(in your example 2 4).
Michael
On Thu, Oct 13, 2011 at 8:51 AM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
Table() or more generally
try this:
y - c(0,1,1,3,3,3,5,5,6)
x - tabulate(y+1)
names(x) - seq(from = 0, by = 1, length = length(x))
x
0 1 2 3 4 5 6
1 2 0 3 0 2 1
On Thu, Oct 13, 2011 at 7:33 AM, Kathie kathryn.lord2...@gmail.com wrote:
Dear R users,
I'd like to count the number of integers in a vector y.
Here
Kathie wrote on 10/13/2011 06:33:59 AM:
Dear R users,
I'd like to count the number of integers in a vector y.
Here is an example.
y - c(0,1,1,3,3,3,5,5,6)
In fact, I know how to count the number of specific number in y.
sum(y==0) - 1
sum(y==1) - 2
sum(y==2) - 0
sum(y==3) - 3
Startsituation:
structure(c(1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1,
0, 1, 1), .Dim = 4:5, .Dimnames = structure(list(subject = c(s1,
s2, s3, s4), class = c(c1, c2, c3, c4, c5)), .Names =
c(subject,
class)), class = c(xtabs, table), call = xtabs(formula = ~subject +
class, data
Metronome123 wrote on 09/27/2011 07:24:50 AM:
Startsituation:
structure(c(1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1,
0, 1, 1), .Dim = 4:5, .Dimnames = structure(list(subject = c(s1,
s2, s3, s4), class = c(c1, c2, c3, c4, c5)), .Names =
c(subject,
class)), class = c(xtabs,
Jean: Thanks!
Works great!
Lars
Op 27 sep. 2011 (w39), om 17:22 heeft Jean V Adams [via R] het volgende
geschreven:
df - as.data.frame(unclass(xt))
dfu - unique(df)
class_cnt - apply(dfu, 1, sum)
subject_cnt - tabulate(match(apply(df, 1, paste, collapse=-),
apply(dfu, 1, paste,
, August 31, 2011 9:25 AM
To: r-help
Subject: [R] counting the duplicates in an object of list
Hi all,
I have a list x:
x=list(a=c('1','2'),b=c('2','3'),c=c('1','2'),d=c('2','3'))
I can get the unique elements with unique(), but how can I get the
number of duplicates for each
with the
data.
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 zhenjiang xu
Sent: Wednesday, August 31, 2011 9:25 AM
To: r-help
Subject: [R] counting
Dunlap
Cc: r-help
Subject: Re: [R] counting the duplicates in an object of list
Now I nailed down the problem, but I am still confused why match() takes the
1st two components and the last two the same.
match(a,a)
[1] 1 2 3 1 2
a
[[1]]
[1] YARCTy1-1 YAR009C YBLWTy1-1 YBL005W-B YBRWTy1-2
:* Wednesday, September 07, 2011 7:25 PM
*To:* William Dunlap
*Cc:* r-help
*Subject:* Re: [R] counting the duplicates in an object of list
** **
Now I nailed down the problem, but I am still confused why match() takes
the 1st two components and the last two the same.
** **
match
Spotfire, TIBCO Software
wdunlap tibco.com
From: zhenjiang xu [mailto:zhenjiang...@gmail.com]
Sent: Wednesday, September 07, 2011 8:04 PM
To: William Dunlap
Cc: r-help
Subject: Re: [R] counting the duplicates in an object of list
I tried converting the elements to strings before, but due to the large
...@gmail.com]
*Sent:* Wednesday, September 07, 2011 8:04 PM
*To:* William Dunlap
*Cc:* r-help
*Subject:* Re: [R] counting the duplicates in an object of list
** **
I tried converting the elements to strings before, but due to the large
data size it took forever to finish with paste
Hi all,
I have a list x:
x=list(a=c('1','2'),b=c('2','3'),c=c('1','2'),d=c('2','3'))
I can get the unique elements with unique(), but how can I get the
number of duplicates for each unique elements?
unique(x)
[[1]]
[1] 1 2
[[2]]
[1] 2 3
Thanks
--
Best,
Zhenjiang
Of zhenjiang xu
Sent: Wednesday, August 31, 2011 9:25 AM
To: r-help
Subject: [R] counting the duplicates in an object of list
Hi all,
I have a list x:
x=list(a=c('1','2'),b=c('2','3'),c=c('1','2'),d=c('2','3'))
I can get the unique elements with unique(), but how can I get the
number
Hello everyone,
What is the most elegant and efficient way to count non-missing values of a
vector?
Thanks!
Dan
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do
sum(!is.na(x))
Michael
On Aug 27, 2011, at 4:39 PM, Dan Abner dan.abne...@gmail.com wrote:
Hello everyone,
What is the most elegant and efficient way to count non-missing values of a
vector?
Thanks!
Dan
[[alternative HTML version deleted]]
) ?
Jean
Edward Patzelt patze...@umn.edu wrote on 08/22/2011 03:58:38 PM:
[image removed]
Re: [R] Counting Elements Conditionally
Edward Patzelt
to:
Jean V Adams
08/22/2011 03:58 PM
Cc:
r-help
Awesome, this is close, couple changes
R -
I have 3 variables with data below. Variable Rev is a vector that changes
from 1 to 2, 2 to 3, etc Variable FF is a binary variable with 1's
and 0's. Variable bin is a different binary variable with 1's and 0's.
I want to calculate the number of elements:
1. Starting with the first
[R] Counting Elements Conditionally
Edward Patzelt
to:
r-help
08/22/2011 02:33 PM
R -
I have 3 variables with data below. Variable Rev is a vector that
changes
from 1 to 2, 2 to 3, etc Variable FF is a binary variable with
1's
and 0's. Variable bin is a different binary
Re: [R] Counting Elements Conditionally
Jean V Adams
to:
Edward Patzelt
08/22/2011 03:53 PM
[R] Counting Elements Conditionally
Edward Patzelt
to:
r-help
08/22/2011 02:33 PM
R -
I have 3 variables with data below. Variable Rev is a vector that
changes
from 1 to 2
)), .Names = c(Rev, FF, bin), row.names = c(NA,
-125L), class = data.frame)
On Mon, Aug 22, 2011 at 3:57 PM, Jean V Adams jvad...@usgs.gov wrote:
Re: [R] Counting Elements Conditionally
Jean V Adams
to:
Edward Patzelt
08/22/2011 03:53 PM
[R] Counting Elements Conditionally
Edward
= data.frame)
On Mon, Aug 22, 2011 at 3:57 PM, Jean V Adams jvad...@usgs.gov wrote:
Re: [R] Counting Elements Conditionally
Jean V Adams
to:
Edward Patzelt
08/22/2011 03:53 PM
[R] Counting Elements Conditionally
Edward Patzelt
to:
r-help
08/22/2011 02:33 PM
R
So, using the full data set, what should the result look like?
c(NA, NA, NA, 3, NA,NA, NA, 2) ?
Jean
Edward Patzelt patze...@umn.edu wrote on 08/22/2011 03:58:38 PM:
[image removed]
Re: [R] Counting Elements Conditionally
Edward Patzelt
to:
Jean V Adams
08/22/2011
, NA, 3, NA,NA, NA, 2) ?
Jean
Edward Patzelt patze...@umn.edu wrote on 08/22/2011 03:58:38 PM:
[image removed]
Re: [R] Counting Elements Conditionally
Edward Patzelt
to:
Jean V Adams
08/22/2011 03:58 PM
Cc:
r-help
Awesome, this is close, couple
Hello,
I have an input file that contains multiple columns, but the column I'm
concerned about looks like:
TR
5
0
4
1
0
2
0
To count all of the rows in the column I know how to do NROW(x$TR) which
gives 7.
However, I would also like to count only the number of rows with values =1
(i.e. not 0).
Hi,
I have a matrix (pwdiff in the example below) with ~48 rows and 780
columns.
For each row, I want to get the percentage of columns that have an absolute
value above a certain threshold t. I then want to allocate that percentage
to matrix 'perc' in the corresponding row. Below is my
101 - 200 of 429 matches
Mail list logo