search for: unique

Displaying 20 results from an estimated 11267 matches for "unique".

2012 Jun 28
2
Aggregate weights for a unique set of rows
Hi, all together. I have - a maybe trivial - problem with aggregating a list of weights. Here is the problem: - At first I have set of nodes (X/Y-coordinates) and associated weights, where the set of nodes is typically not unique - I want to get a set of unique nodes and the sum of associated weights I am grateful for any help See for example: # weights: w <- c(1, 1, 1, 1, 1) # not unique set of nodes (X/Y-coordinates): nodes <- matrix(c(1,2,3,4,5,6,1,2,1,4),ncol=2, byrow=T) desired Result: #nodes [...
2014 Dec 27
1
[Bug 87775] New: [ALL] WARNING: value %x not uniquely defined
https://bugs.freedesktop.org/show_bug.cgi?id=87775 Bug ID: 87775 Summary: [ALL] WARNING: value %x not uniquely defined Product: Mesa Version: git Hardware: Other OS: All Status: NEW Severity: normal Priority: medium Component: Drivers/DRI/nouveau Assignee: nouveau at lists.freedesktop.org Reporter:...
2011 Dec 15
1
S4 NAMESPACE method imports and exports do not include (promoted?) generics
...exporting methods on a generic in the namespace will also export the generic, and exporting a generic in the namespace will also export its methods. and Note that importMethodsFrom will also import any generics defined in the namespace on those methods However, if PkgA promotes 'unique' to a generic and exports that DESCRIPTION: Imports: methods R/f.R: setGeneric("unique") NAMESPACE: export(unique) and PkgB creates and exports a method on unique DESCRIPTION Imports: methods, PkgA R/f.R: setClass("B", representation(b=&qu...
2004 Jun 29
1
RE: [S] Different behaviour of unique(), R vs. Splus.
The source of the incompatibility: In S-PLUS 6.2: > methods("unique") splus splus menu splus "unique.data.frame" "unique.default" "unique.name" "unique.rowcol.names" In R-1.9.1: > methods("unique") [1] unique.array unique.data.frame unique.default...
2008 Dec 05
1
Yet another set of codes to optimize
...e.size = 100000 seems to take eternity. My actual sample.size is 15000000 i.e. 15 million. sample.size <- 10000 m <- data.frame(Name=sample(1:100000, sample.size, T), Type=sample(1:1000, sample.size, T), Predictor=sample(LETTERS[1:10], sample.size, T)) res <- function(m) { m.12.unique <- unique(m[,1:2]) m.12.unique <- m.12.unique[order(m.12.unique[,1], m.12.unique[,2]),] v1 <- paste(m.12.unique[,1], m.12.unique[,2], sep=".") v2 <- c(sort(unique(m[,3]))) res <- matrix(0, nr=length(v1), nc=length(v2), dimnames=list(v1, v2)) m.ids <-...
2010 Jan 26
1
splitting a factor column into binary columns for each factor
...=============== Hello -- I would like to know of a more efficient way of writing the following piece of code. Thanks. options(stringsAsFactors=FALSE) orig <- c(rep('11111111',100000),rep('22222222',200000),rep('33333333' ,300000),rep('44444444',400000)) orig.unique <- unique(orig) system.time(df <- as.data.frame(sapply(orig.unique, function(x) ifelse(orig==x, 1, 0)))) ============================================ I received a response via e-mail which was **extremely** useful. =================answer====================== Using sapply instead of lapp...
2012 Dec 27
4
Finding (swapped) repetitions of numbers pairs across two columns
...I'm using the following solution, which is quite horrible: v1 = c(0,1,2,3,4) v2 = c(5,3,2,1,0) ft <- cbind(v1, v2) direction = apply( ft, 1, function(x) return(x[1]>x[2])) ft.tmp = ft ft[which(direction),1] = ft.tmp[which(direction),2] ft[which(direction),2] = ft.tmp[which(direction),1] uniques = apply( ft, 1, function(x) paste(x, collapse="%") ) uniques = unique(uniques) ft.unique = matrix(unlist(strsplit(uniques,"%")), ncol=2, byrow=TRUE) Any better solution would be very welcome! All the best, Emmanuel
2005 Aug 22
2
Symbols as Parameters
..., experimenting, and looking through some of the Rails API but I can''t put this simple thing together. I want to create a method that can have zero or more parameters and some of those are symbols. A very simple example would look something like this: find(options = {}) if options[:unique] puts ''Do the unique operation'' else puts ''Not-unique operation'' end end And I want to be able to call this method as "find()" or "find(:unique)". The above definition works fine if I do "find()" or "find(:unique...
2018 Jul 02
1
MARGIN in base::unique.matrix() and base::unique.array()
Hi, The man page for base::unique.matrix() and base::unique.array() says that MARGIN is expected to be a single integer. OTOH the code in charge of checking the user supplied MARGIN is: if (length(MARGIN) > ndim || any(MARGIN > ndim)) stop(gettextf("MARGIN = %d is invalid for dim = %d", M...
2010 Jun 13
5
Count of unique factors within another factor
I have a data frame with two factors (sampling 'unit', 'species'). I want to calculate the number of unique 'species' per 'unit.' I can calculate the number of unique values for each variable separately, but can't get a count for each ?unit?. > data=read.csv("C:/Desktop/sr_sort_practice.csv") > attach(data) > data[1:10,] unit species 1 123 ACMA 2 123...
2012 Aug 28
5
return first index for each unique value in a vector
I would like to efficiently find the first index of each unique value in a very large vector. For example, if I have a vector A<-c(9,2,9,5) I would like to return not only the unique values (2,5,9) but also their first indices (2,4,1). I tried using a for loop with which(A==unique(A)[i])[1] to find the first index of each unique value but it is very slow...
2009 Jun 29
2
How to select partially (not completely) unique rows?
Dear R-helpers, I know how to use unique to select unique rows, e.g. unique.rows<-unique(dataframe) but I would like to select those rows that are unique only only TWO of my dataframe's columns (so, two rows with the same value on these two columns would not be kept, even if they had different values in other columns). For examp...
2005 Jan 29
3
unique rows
Dear list, I would like to extract from a matrix all those rows, that are unique. By unique, I don't mean the unique that is accomplished by the function unique(), though... Consider the following example: > h [,1] [,2] [1,] 4 4 [2,] 1 4 [3,] 4 1 Now unique(h) returns exactly the same - because 1 4 and 4 1 is not the same for that function. W...
2006 Apr 20
2
Count Unique Rows/Values
...haracter values with dupllicates. For example: 155 A 138 A 138 B 126 C 126 D 123 A 103 A 103 B 143 D 111 C 111 D 156 C How can I count the number of unqiue entries without counting duplicate entries. Also can I extract the list in a object. What I mean is Col1 unique count = 8 Unique Elements are : 103,111,123,126,138,143,155,156 Col2 unique count = 4 Unique Elements are : A,B,C,D. Any pointers would be of great help. TIA Sachin --------------------------------- [[alternative HTML version deleted]]
2004 Aug 19
0
suggesting a new feature for unique()
Dear R-devel, May I suggest that a new feature be added to a couple of unique() methods? Sometimes it's useful to have the indices of the original data that the unique elements come from, so that the original data can be recreated from the unique()ed data. I suggest that an `index' argument be added for unique. Below is a suggested patch against R/src/library/base/...
2009 Feb 22
4
'unique' error message is printed despite silent=TRUE (PR#13547)
In 2.8.0/Windows Vista: When 'unique' gives a type error message, it prints out even if errors are being caught: > try(unique(quote(hello)),silent=TRUE) hello This comes from the .Internal unique routine: > try(.Internal(unique(quote(hello),NULL,NULL)),silent=TRUE) hello I guess it is using the internal equivalent of pri...
2007 Sep 13
3
difference between unique() and !duplicated()
Yesterday I spend the whole day struggling on how to get the maximum value of "y" for every unique value of "x" from the dataframe "test". In the R Book (Crawley, 2007) an example of this can be found on page 121. I tried to do it this way, but I failed. In the end, I figured out how to get it working (first order, and afterwards use !duplicated()). My question is: why...
2012 Dec 08
1
namespace S3 and S4 generic imports cannot both be satisfied:
PkgA wishes to write a method for 'unique' on S4 class 'A'. ?Methods indicates that one should setGeneric("unique") setClass("A") unique.A <- function(x, incomparables=FALSE, ...) {} setMethod(unique, "A", unique.A) Both S3 and S4 methods need to be exported in the NAMESPACE...
2004 Sep 01
3
Unique lists from a list
Hi I have a list. Two of the elements of this list are "Name" and "Address", both of which are character vectors. Name and Address are linked, so that the same "Name" always associates with the same "Address". What I want to do is pull out the unique values, as a new list of the same format (ie two elements of character vectors). Now I've worked out that unique(list$Name) will give me a list of the unique names, but how do I then go and link those to the correct (unique) addresses so I end up with a new list which is the same format as the...
2010 Jun 08
2
duplicated() and unique() problems
...sample(1:20, replace=TRUE) ex duplicated(ex) ex=order(ex) duplicated(ex) Why does duplicated() not work after order() has been applied but it works fine after sort() ? Is this an error or is there something I don't understand. I have been getting very strage results from duplicated() and unique() in a dataset I am analysing. Her is a little sample of my real life problem > str(Masechaba$PROPDESC) Factor w/ 24545 levels " 06"," 71Hemilton str",..: 14527 8043 16113 16054 13875 15780 12522 7771 14824 12314 ... > # Create a indicator if the PROPDESC is unique...