similar to: counting the duplicates in an object of list

Displaying 20 results from an estimated 30000 matches similar to: "counting the duplicates in an object of list"

2010 Aug 10
4
matrix problem
Hi, I have a file like this: 1 2 0.1 2 3 0.2 3 1 0.3 And I want to read it to create a matrix like this: [,1] [,2] [,3] [1,] 0 0.1 0 [2,] 0 0 0.2 [3,] 0.3 0 0 How can I do it efficiently? Thanks. -- Best, Zhenjiang [[alternative HTML version deleted]]
2011 Aug 31
3
how to create data.frames from vectors with duplicates
Hi R users, suppose I have two vectors, > x=c(1,2,3,4,5) > y=c('a','b','c','a','c') How can I get a data.frame like this? > xy count a 5 b 2 c 8 I know a few ways to fulfill the task. However, I have a huge number of this kind calculations, so I'd like an efficient solution. Thanks -- Best, Zhenjiang
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 Aug 05
4
a question on list manipulation
Hi R users, I have a list: > x $A [1] "a" "b" "c" $B [1] "b" "c" $C [1] "c" I want to convert it to a lowercase-to-uppercase list like this: > y $a [1] "A" $b [1] "A" "B" $c [1] "A" "B" "C" In a word, I want to reverse the list names and the elements under each
2011 Mar 15
3
how to reshape the data.frame from long to wide in a specific order
Hi, For example, the data.frame like: origdata.long <- read.table(header=T, con <- textConnection(' subject sex condition measurement 1 M control 7.9 1 M first 12.3 1 M second 10.7 2 F control 6.3 2 F first 10.6 2 F second 11.1 3 F control 9.5 3
2011 Aug 02
2
how to control to save plots to which dev
Hi, I have a for loop to make 2 types of plots and I'd like to save one type of plots to a pdf file and the other to another pdf file. How can I control which plot will be saved to which pdf? Thanks -- Best, Zhenjiang
2011 Apr 15
1
how to add two data.frame with the same column but different row numbers
Hi all, Suppose I have 2 data.frame , a and b, how can I add them together to get c? Thanks > a A a 1 b 2 c 3 > b A a 6 c 1 > c A a 7 b 2 c 4 -- Best, Zhenjiang [[alternative HTML version deleted]]
2011 Aug 29
1
sum of two lists
Hi R users, Suppose I have two lists and the names of list 'm' are a subset of those of 'n', how can I sum the two lists with corresponding elements added together to get list 'o'? > n = list("a"=1,"b"=3,"c"=5) > m = list('b'=4) > o $a [1] 1 $b [1] 7 $c [1] 5 Thanks -- Best, Zhenjiang [[alternative HTML version
2010 Nov 10
1
ggplot2 problem in interacting mode
Hi all, When running R interactively, I have the problem as following: > library(ggplot2) Loading required package: reshape Loading required package: plyr Attaching package: 'reshape' The following object(s) are masked from 'package:plyr': round_any Loading required package: grid Loading required package: proto > data(VADeaths) > pg <- ggplot(melt(VADeaths),
2011 Aug 24
1
read.table truncated data?
Hi R users, I was using read.table to read a file. The data.fame looked alright, but I found not all rows are read by the read.table. What's wrong with it? It didn't give me any warning or error messages. Why the data are truncated? Thanks. $ wc -l all/isoform_exp.diff 42847 all/isoform_exp.diff > a=read.table('all/isoform_exp.diff', header=T, sep='\t') > nrow(a)
2009 Jun 02
2
reference counting bug: overwriting for loop 'seq' variable
It looks like the 'seq' variable to 'for' can be altered from within the loop, leading to incorrect answers. E.g., in the following I'd expect 'sum' to be 1+2=3, but R 2.10.0 (svn 48686) gives 44.5. > x = c(1,2); sum = 0; for (i in x) { x[i+1] = i + 42.5; sum = sum + i }; sum [1] 44.5 or, with a debugging cat()s, > x = c(1,2); sum = 0; for (i in x) {
2011 Apr 11
3
sort.int(S3object) strips class but not the is.object flag
If x has an S3 class then sort.int(x) returns a value without an S3 class but which has the is.object flag set, which, I think, causes identical() give a false/misleading report: > x <- structure(1:3, class="unrecognizedClass") > y <- sort.int(x) > t <- 1:3 > identical(y, t) # expect TRUE [1] FALSE > identical(as.vector(y), as.vector(t)) # expect
2009 Apr 23
1
reference counting problem in .Primitive's?
I think the following rather wierd expressions show a problem in how some of the .Primitive functions evaluate their arguments. I haven't yet thought of a way that a nonabusive user might run into this problem. In each case the first argument, x, is modified in the course of evaluating the second argument and then modified x gets used as the first argument: > x<-as.integer(1:5); y
2010 Apr 20
1
the bar width of barchart plot in lattice package
Dear R users, I am trying to use the following code to make a barchar plot. The bars in the plot turn out to be a little narrow. Is there any way to modify the width of the bars? Thank you! library(lattice) scores = gl(2, 5, label=c('Sensitivity', 'PPV'), length = 100) sequences = gl(5, 1, label=c('Lemna minor', 'Dugesia japonica A', 'Gymnosporangium
2010 Jan 22
2
Counting Na values on a time serie only on the past datas
Hello everyone, I have a time serie of n values, some are na's. I want to get a vector of size n whose elements represent on the time t < n the number of missing values between o and t. I know I can do it with a loop but I wanted to know if there was a function or a special syntax to do this. Thanks a lot! -- View this message in context:
2009 Jun 03
2
reference counting bug related to break and next in loops
One of our R users here just showed me the following problem while investigating the return value of a while loop. I added some information on a similar bug in for loops. I think he was using 2.9.0 but I see the same problem on today's development version of 2.10.0 (svn 48703). Should the semantics of while and for loops be changed slightly to avoid the memory buildup that fixing this to
2010 May 18
2
Counting Frequencies in Data Frame
Hi, I am sure there is an easy way to do it, but I can't find it. I have a data frame that has 15 columns and 7000 rows. The only values inside the data.frame are "aa", "ab", "bb" as you can see an example bellow. 1 2 3 1 aa ab ab 2 ab ab ab 3 aa aa aa 4 bb bb bb What I would like to do, is to generate a vector (or another data.frame) with 7000 rows, and 3
2009 Oct 13
4
Counting
*Hi all, * *Assume that I have the following data set with tow variables and I want count the number of observation with identical values * ** *x1 x2* * 1 1 * * 1 0 * * 0 1* * 0 1* * 0 0* * 1 1* * 0 1 * I want the following output ** * * *n1=3 # number of identical observation between x1 and x2 variables* *n2=4 # number of different observation* How do I do it in
2010 Apr 29
1
a question on autocorrelation acf
Hi R users, where can I find the equations used by acf function to calculate autocorrelation? I think I misunderstand acf. Doesn't acf use following equation to calculate autocorrelation? [image: R(\tau) = \frac{\operatorname{E}[(X_t - \mu)(X_{t+\tau} - \mu)]}{\sigma^2}\, ,] If it does, then the autocorrelation of a sine function should give a cosine; however, the following code gives a
2010 Apr 22
1
how to reorder of groups and specify ylim for each row in lattice barchart
R experts, Is there anyway to reorder inside each group? In the following example, the bar of year 1932 is always plotted before the bar of year 1931, may I change the order inside each groups of bars? library(lattice) barchart(yield ~ variety | site,data=barley, groups = year, layout = c(1,6),auto.key = list(points = FALSE, rectangles = TRUE, space = "right"),ylab = "Barley Yield