similar to: counting the data in different groups for each row

Displaying 20 results from an estimated 100000 matches similar to: "counting the data in different groups for each row"

2012 May 25
2
problem with installing rms package
Hi I am trying to install "rms" package but while installing it shows following error package 'survival' 2.36-2 is loaded, but >= 2.36.3 is required by 'rms' what to do? i am using linux OS I have tried by updated r-base-core but it didnt work regards GRR [[alternative HTML version deleted]]
2011 Nov 04
1
Counting number of common elements between the rows of two different matrices
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 30 8 16; 3 8 19 11 13) (the actual matrices have hundreds of thousands of entry, that's why I'm keen to avoid
2007 Dec 23
0
RE : Re: number of count of each unique row
Thanks to Jay Kerns and Jim Lemon for their help. It's exactly what I wanted and "aggregate" is very efficient even with a huge data. Thanks "G. Jay Kerns" <gkerns@ysu.edu> a écrit : Hi Louis, If I am understanding your question correctly, here is one way: suppose your matrix is M of dimension n x k. D <- data.frame(M) # convert to data frame ones <- rep(1,
2010 Feb 08
2
Counting by rows based on multiple criteria
Dear all, I have a data frame of 6 columns and ~60000 rows which I hope to perform the following calculation on. For each row, I wish to determine whether there are a greater number of positive or negative numbers. Then, if there are more positive numbers in the row, count how many occur - but if there are more negative numbers in the row, count them instead and insert a minus symbol before
2017 Jun 23
0
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
Hello, The obvious way would be to preallocate the resulting data.frame, to expand an empty one on each iteration being a time expensive operation. n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2))) D4 <- data.frame(distance=integer(n),difference=integer(n)) k <- 0 for (i in 1:nrow(D1)){ for (j in 1:nrow(D2)) { k <- k + 1 D4[k, ] <-
2017 Jun 23
0
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
You appear to be trying to write C code in R. Don't do this. If you can trade off space for efficiency, the calculation can be easily vectorized (assuming I correctly understand what you want to do, of course). set.seed(135) ## for reproducibility D1<-data.frame(x=1:5,y=6:10,z=rnorm(5)) D2<-data.frame(x=19:30,y=41:52,z=rnorm(12)) D.all <-merge(D1,D2, by.x=NULL,by.y=NULL) ##
2007 Dec 21
2
number of count of each unique row
Hi, I have a matrix of duplicate rows. How to output a list the unique rows with their count? I have used "unique" to have the unique rows, but can't produce the occurences of each unique row. Thanks Louis --------------------------------- [[alternative HTML version deleted]]
2024 Dec 02
0
Identify first row of each ID within a data frame, create a variable first =1 for the first row and first=0 of all other rows
John, Thanks for enlightening us so we better understand. I won't argue with your wish to learn to do things in base R first. I started that way, myself, and found lots of the commands not particularly easy to fit into a single worldview. Many functions I read about were promptly forgotten, especially those without great documentation and not enough examples of real world usage. This is why
2017 Jun 23
1
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
Hello, Another way would be n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2))) D5 <- data.frame(distance=integer(n),difference=integer(n)) D5[] <- do.call(rbind, lapply(seq_len(nrow(D1)), function(i) t(sapply(seq_len(nrow(D2)), function(j){ c(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2) } )))) identical(D3, D5) In my first answer I forgot to say that
2011 Jun 10
2
Counting the Number of Letters in a row
I'm trying to find the total number of letters in a row of a data frame. Let's say I have the following data frame. f1 <- data.frame(keyword=c("I live in Denver", I live in Kansas City, MO", "Pizza is good")) The following function gives me the number of characters in each string. So for "I live in Denver", I get 1, 4, 2, and 6. However, I want to
2008 Nov 11
1
data which has different size of elements in each row
Hi all, I have problem reading in a text file as follow. The following data has not column header. I tried the following command but failed, temp<-read.table("data.txt",header=F) An error message stated that line 3 did not have 4 elements. 0.293290E-05 0.117772E-05 -0.645205 rs2282755 0.307521E-05 0.000314 0.412997 rs1336838 0.484017E-05
2017 Aug 02
0
Error in `row.names<-.data.frame`(`*tmp*`, value = c("1.9", "1.9", "1.9", : duplicate 'row.names' are not allowed
Hi I did not notice any answer to your question so I try. After studying docs and other responses to similar question I deduct that chid.var and alt.var are mixed together and new data frame is being build with chid.var and alt.var combination as new row names. As the combination is not unique this operation results to error. But I may be completely wrong. Cheers Petr > -----Original
2011 Sep 27
1
Counting similar rows
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",
2007 Jul 13
1
counting occurances of matching rows in a matrix
I need help regarding to the following problem: Consider this matrix: > M <- matrix(c(1,2, 4,3, 1, 2),3, 2, byrow=TRUE) > M [,1] [,2] [1,] 1 2 [2,] 4 3 [3,] 1 2 I would like to have a matrix which counts the identical rows and places the counts into its third column. I tried with ftable(): > as.data.frame(ftable(M[,1], M[,2])) Var1 Var2 Freq 1 1 2
2009 May 18
1
Barchart in lattice - wrong order of groups, data labels on top of each other, and a legend question
Hello! I have a question about my lattice barchart that I am trying to build in Section 3 below. I can't figure out a couple of things: 1. When I look at the dataframe "test" that I am trying to plot, it looks right to me (the group "Total" is always the first out of 5). However, in the chart it is the last. Why? 2. How can I make sure the value labels (on y) are not
2012 Jun 12
4
How to index a matrix with different row-number for each column?
here's my question: suppose I have a matrix: mt<-matrix(1:12,ncol=6) now I have a vector vt<-c(1,2,2,2,1,2) which means I want to get: the 1st row for column1; the 2nd row for column2; the 2nd row for column3; the 2nd row for column4; ... that what I want is this vector: 1,4,6,8,9,12 Does anyone know how to do this fast? I know I can use for-loop to travel all columns,but
2011 Apr 10
3
count number of TRUEs in each row
Hi all, I have a huge matrix of TRUE/FALSE table like following, and I want to count the number of TRUEs in each row. Instead of looping through each row and do length(Z[Z==TRUE]), I am wondering if there is an easier way of doing this. [,1] [,2] [,3] [1,]TRUE FALSE FALSE [2,]FALSE TRUE TRUE Thank you in advance. Wendy -- View this message in context:
2011 Mar 26
1
bwplot [lattice]: how to get different y-axis scales for each row?
Dear expeRts, How can I get ... (1) different y-axis scales for each row (2) while having the same y-axis scales for different columns? I coulnd't manage to do this with relation="free" [which gives (1) but not (2)]. I also tried relation="sliced", but it did not give the same y-axis scales within each row (see the fourth row). Further, it "separates" the
2024 Dec 02
1
Identify first row of each ID within a data frame, create a variable first =1 for the first row and first=0 of all other rows
OK. (Note: I am ccing this to the list so that others can correct any mistakes, misunderstandings, or misstatements that I may make; and also give you more and better advice about how to proceed. For example, there may be environmental packages ( see the environmetrics task view, https://CRAN.R-project.org/view=Environmetrics) that already do everything you want from your data source that someone
2010 May 26
2
reading in table with different number of elements in each row
HI all, This is probably simple, but I haven't been able to locate the answer either in the Import Manual or from searching the listserve. I have tab-delimited data with different numbers of elements in each row. I want to read it into R, such that R fills in "NA" in elements that have no data. How do I accomplish this? Example: DATA on disk: 1 -0.068191 -0.050729