search for: fromlast

Displaying 20 results from an estimated 64 matches for "fromlast".

2007 Nov 02
0
applying duplicated, unique and match to lists?
...tem.time({z <- lapply(y, md5); match(z,zt)}) system.time({z <- sapply(y, md5); zt <- sapply(y, md5); pos<-match(z,zt); all(sapply(seq(along=pos), function(i)identical(z[i],zt[pos[i]])))}) rm(x) } duplicated.matrix <- duplicated.array <- function (x, incomparables = FALSE, fromLast = FALSE, MARGIN = 1, hashFUN=list, ...) { if (!is.logical(incomparables) || incomparables) .NotYetUsed("incomparables != FALSE") ndim <- length(dim(x)) if (length(MARGIN) > ndim || any(MARGIN > ndim)) stop("MARGIN = ", MARGIN, " is inval...
2012 Jul 23
1
duplicated() variation that goes both ways to capture all duplicates
Dear all The trouble with the current duplicated() function in is that it can report duplicates while searching fromFirst _or_ fromLast, but not both ways. Often users will want to identify and extract all the copies of the item that has duplicates, not only the duplicates themselves. To take the example from the man page: > data(iris) > iris[duplicated(iris), ] ##duplicates while searching "fromFirst" Sepal.L...
2011 Jan 20
6
Identify duplicate numbers and to increase a value
...s duplicated. Example: x=c(1,2,3,5,6,2,8,9,2,2) I want to do this: 1 2 + 0.01 3 5 6 2 + 0.02 8 9 2 + 0.03 2 + 0.04 I am trying to get something like this: 1 2.01 3 5 6 2.02 8 9 2.03 2.04 Actually I just know the way to identify the duplicated numbers rbind(x, duplicated(x) | duplicated(x, fromLast=TRUE)) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] x 1 2 3 5 6 2 8 9 2 2 0 1 0 0 0 1 0 0 1 1 Some advice? Thanks and regards John Ortiz
2010 Feb 05
1
unique function works funny
I have 3 nested functions, the core function goes like this: listx<-function(x,tox) { xt=table(x) wa=sort(unique(x,fromLast=FALSE)) print(xt) print(wa) ...... return(kk) } listx get called in functionB, and functionB get called in functionC. When I test functionB, the listx function works just fine. When I call functionB from functionC, strange thing happened: My result for xt: 0.07 0.17 0.2 1 1 6 My res...
2018 Jul 02
1
MARGIN in base::unique.matrix() and base::unique.array()
...), domain = NA) which doesn't really make sense. As a consequence the user gets an obscure error message when specifying a MARGIN that satisfies the above check but is in fact invalid: > unique(matrix(1:10, ncol=2), MARGIN=1:2) Error in args[[MARGIN]] <- !duplicated.default(temp, fromLast = fromLast, : object of type 'symbol' is not subsettable Also the code used by the above check to generate the error message is broken: > unique(matrix(1:10, ncol=2), MARGIN=1:3) Error in sprintf(gettext(fmt, domain = domain), ...) : arguments cannot be recycled to th...
2011 Oct 05
1
unique possible bug
..., Patrick McCann Here is a simple to reproduce example: > runif(2^29+5)->a > sum(unique(a))->b Error in unique.default(a) : length 536870917 is too large for hashing > traceback() 3: unique.default(a) 2: unique(a) 1: unique(a) > unique.default function (x, incomparables = FALSE, fromLast = FALSE, ...) { z <- .Internal(unique(x, incomparables, fromLast)) if (is.factor(x)) factor(z, levels = seq_len(nlevels(x)), labels = levels(x), ordered = is.ordered(x)) else if (inherits(x, "POSIXct")) structure(z, class = class(x), tzone = attr...
2013 Jun 10
2
please check this
Hi, Try this: which(duplicated(res10Percent)) # [1] 117 125 157 189 213 235 267 275 278 293 301 327 331 335 339 367 369 371 379 #[20] 413 415 417 441 459 461 477 479 505 res10PercentSub1<-subset(res10Percent[which(duplicated(res10Percent)),],dummy==1)? #most of the duplicated are dummy==1 res10PercentSub0<-subset(res10Percent[which(duplicated(res10Percent)),],dummy==0)
2012 Sep 06
3
How to find the non matching vectors among these five, if so how we can find the non matching element of that vectors?
Hello, Say all the below five vectors should have same elements in any situation. How to find the non matching vectors among these five, if so how we can find the non matching elements of those vectors? Can anyone help? a=c(1,2,3) b=c(1,2,3,4) c=c(1,2,3) d=c(1,2,3) e=c(1,4,5) identical(a,b,c,d,e) Visit us at Booth No. 5 at 2012 ChemOutsourcing Conference, 10-13 Sept 2012, Ocean Place Resort -
2012 Sep 10
4
Identifying duplicate rows?
Hi, I am trying to identify duplicate values in a column in a date frame. The duplicated function identifies the duplicate rows in the data frame but it only does this for the second record, not both records. Is there a way to mark both rows in the data frame as TRUE? dfA$dups<-duplicated(dfA$Value) dfA Site State Value dups 929 VA 73 FALSE 929 VA 73 TRUE 930 VA 76 FALSE 930 VA 76 TRUE 931
2012 Sep 27
3
Keep rows in a dataset if one value in a column is duplicated
...so I apologize if the code is really rough. Basically I want to keep all the rows in the data set for which the value of "Pairiddups" is TRUE. How do I do it? And how do I get past the error? Thank you so much, Diana PairID<-c(Health2$pairid) duplicated(PairID, incomparables=TRUE, fromLast=TRUE) PairIDdup=duplicated(PairID) cbind(PairID, PairIDdup) PairID[which(PairIDdup)] PairIDDuplicates<-PairID%in%PairID[which(PairIDdup)] PairIDs<-cbind(PairID, PairIDDuplicates) colnames(PairIDs)<-c("Pairid","Pairiddups") Health2PairsOnly<-PairIDs[ which(PairIDs...
2010 Apr 05
2
find the "next non-NA" value within each row of a data-frame
#I wish to find the "next non-NA" value within each row of a data-frame. #e.g. I have a data frame mydata. Rows 1, 2 & 3 have soem NA values. mydata <- data.frame(matrix(seq(20*6), 20, 6)) mydata[1,3:5] <-  NA mydata[2,2:3] <-  NA mydata[2,5] <-  NA mydata[3,6] <-  NA mydata[1:3,] #this loop accomplishes the task; I am tryign toi learn a "better" way for(i
2010 Jan 16
2
Extracing only Unique Rows based on only 1 Column
...based on what I've read in the help file. A simplified example matrix (designated as "traveltimes"): ID Time1 Time2 1 3 4 1 4 7 2 3 5 2 5 6 3 4 5 3 2 8 When I use a command such as matches <- unique(traveltimes, incomparables = FALSE, fromLast = FALSE) I will end up with a 6-row matrix, exactly what I already have. What I would like to do is to remove the duplicate values in the column labeled "ID" and their associated Time1 and Time2 entries. This will give me a 3x3 matrix which contains only one instance of each "...
2012 Feb 24
1
find difference between data frames
I have one data frame, like below? kind x y 1 1 8 9 2 1 44 3 3 1 25 7 4 1 36 20 5 2 2 14 6 2 36 20 so, I want to find unique coordinates in kind 1 rather than kind 2, ex, row 4 should be excluded, is that possible? -- View this message in
2008 May 08
1
[PATCH] Typo in 'unique' help page (PR#11401)
...ALSE} is a special value, meaning that all values can be - compared, and nay be the only value accepted for methods other than + compared, and may be the only value accepted for methods other than the default. It will be coerced internally to the same type as \code{x}.} \item{fromLast}{logical indicating if duplication should be considered -- 1.5.5.1.99.gf0ec4
2013 Oct 30
1
unique(1:3,nmax=1) freezes R
...ontrasts, and found the argument nmax on function factor. When using nmax=1, R froze completely, and I had to close it from task manager. After some debugging, I found that the problem is actually in unique-function, where the internal unique function is called: .Internal(unique(x, incomparables, fromLast, nmax)) More generally, it looks like unique(x,nmax=k) freezes R the length of x is larger than 2 and k=1, and when nmax<length(x)-1 you get error "Error in unique.default(1:5, nmax = 3) : hash table is full". Of course using nmax=1 doesn't make much sense, but maybe some check w...
2013 Mar 18
2
data.frame with NA
I have this little data.frame http://dl.dropbox.com/u/102669/nanotna.rdata Two column contains NA, so the best thing to do is use na.locf function (with fromLast = T) But locf function doesn't work because NA in my data.frame are not recognized as real NA. Is there a way to substitute fake NA with real NA? In this case na.locf function should work Thank you
2011 Oct 08
1
Filling missing days in xts time series
...#39;m trying to write a function that fillls the missing days. Using a solution suggested by Gabor Grothendieck for zoo, I wrote the following: # FD: Fill missing days FD<-function(ser) {rng<-range(time(ser)) > temp<-merge(ser,xts(,seq(rng[1],rng[2],"day"))) > na.locf(temp,fromLast=TRUE) However,using S&P end-of-day time series, I obtain doubled entries such as: 2011-09-29 00:00:00 1160.40 2011-09-29 02:00:00 1131.42 2011-09-30 00:00:00 1131.42 2011-09-30 02:00:00 1099.23 2011-10-01 02:00:00 1099.23 2011-10-02 02:00:00 1099.23 It looks like it is due to the way xts han...
2013 Sep 09
0
Duplicated genes
Hi, May be you can try this: dat1New<-? dat1[!(duplicated(dat1$gene)|duplicated(dat1$gene,fromLast=TRUE)),] dat2<-dat1[duplicated(dat1$gene)|duplicated(dat1$gene,fromLast=TRUE),] ?lst1<-split(dat2,dat2$gene) dat3<-unsplit(lapply(lst1,function(x) {x1<- sum(apply(x[,6:32],2,function(y) y[1]>=y[2]));x2<- sum(apply(x[,6:32],2, function(y) y[1]<=y[2])); if(x1>x2) x[1,] else x[...
2008 Jan 10
5
Extracting last time value
I have a dataframe as follows: Date time value 20110620 11:18:00 7 20110620 11:39:00 9 20110621 11:41:00 8 20110621 11:40:00 6 20110622 14:05:00 8 20110622 14:06:00 6 For every date, I want to extract the row that has the greatest time. Therefore, ending up like: 20110620 11:39:00 9 20110621 11:41:00 8 20110622 14:07:00 6 I am using for loops (for every date, find largest time value) to do
2012 Oct 23
10
How to pick colums from a ragged array?
I have a large dataset (~1 million rows) of three variables: ID (patient's name), DATE (of appointment) and DIAGNOSIS (given on that date). Patients may have been assigned more than one diagnosis at any one appointment - leading to two rows, same ID and DATE but different DIAGNOSIS. The diagnoses may change between appointments. I want to subset the data in two ways: - define groups