search for: id2

Displaying 20 results from an estimated 217 matches for "id2".

Did you mean: id
2010 Apr 29
3
Simple loop code
...or example, wanting to change an ID code from alphanumeric to numeric. The example below works, but takes ages, given I have a lot of IDs, to do manually! Any thoughts on how to create a loop to go through each ID and give them a unique number would be most welcome! Cheers, Ross levels(dat.ID$ID2)[levels(dat.ID$ID2)=='A1']<-1 levels(dat.ID$ID2)[levels(dat.ID$ID2)=='A2']<-2 levels(dat.ID$ID2)[levels(dat.ID$ID2)=='D1']<-3 levels(dat.ID$ID2)[levels(dat.ID$ID2)=='D2']<-4 levels(dat.ID$ID2)[levels(dat.ID$ID2)=='D4']<-5 levels(dat.ID$ID2)[lev...
2012 Apr 14
3
Choose between duplicated rows
Dear r experts, Sorry for this basic question, but I can't seem to find a solution? I have this data frame: df <- data.frame(id = c("id1", "id1", "id1", "id2", "id2", "id2"), A = c(11905, 11907, 11907, 11829, 11829, 11829), v1 = c(NA, 3, NA,1,2,NA), v2 = c(NA,2,NA, 2, NA,NA), v3 = c(NA,1,NA,1,NA,NA), v4 = c("N", "Y", "N", "Y", "N","N"), v5 = c(0,0,0,1,0,0), numMiss=c(3,...
2008 Apr 02
1
Quickest way to access data.frame?
...around this forum for the best way to access a data.frame.. i got the feeling that "no partial match" is the way to make it fast.... so I convert everything to factor.. but I'm still not 100% sure if the following code will do it... is this the fastest way to do something foreach (ID, ID2) pair? Thanks! data <- data.frame(ID = floor(runif(n = 40000, min=0, max=20)), ID2 = floor(runif(n = 40000, min=0, max=1000)), DATA1 = rnorm(n = 40000)) data$ID <- as.factor(data$ID) data$ID2 <- as.factor(data$ID2) res <- lapply(attr(data$ID, "levels"),...
2006 Jan 24
9
Number of replications of a term
Hello, Is there a simple and fast function that returns a vector of the number of replications for each object of a vector ? For example : I have a vector of IDs : ids <- c( "ID1", "ID2", "ID2", "ID3", "ID3","ID3", "ID5") I want the function returns the following vector where each term is the number of replicates for the given id : c( 1, 2, 2, 3,3,3,1 ) Of course I have a vector of more than 40 000 ID and the function I w...
2006 Jan 14
3
In place editing and external control
...below code but without success: <span id="id1">My text</span> <script type="text/javascript"> new Ajax.InPlaceEditor(''id1'', ''/object/o2499548.html?ajaxRequest&ajaxInPlaceEditing'', {externalControl:''id2''}) </script> <img id="id2" src="/img/buttonEdit.gif"> Thanks Janko
2006 Sep 13
3
group bunch of lines in a data.frame, an additional requirement
Thanks for pointing me out "aggregate", that works fine! There is one complication though: I have mixed types (numerical and character), So the matrix is of the form: A 1.0 200 ID1 A 3.0 800 ID1 A 2.0 200 ID1 B 0.5 20 ID2 B 0.9 50 ID2 C 5.0 70 ID1 One letter always has the same ID but one ID can be shared by many letters (like ID1) I just want to keep track of the ID, and get a matrix like: A 2.0 400 ID1 B 0.7 35 ID2 C 5.0 70 ID1 Any idea on how to do that without a loop? Many thanks, Emmanuel On 9...
2013 Apr 12
1
Removing rows that are duplicates but column values are in reversed order
Hi, From your example data, dat1<- read.table(text=" id1?? id2?? value a????? b?????? 10 c????? d??????? 11 b???? a???????? 10 c????? e???????? 12 ",sep="",header=TRUE,stringsAsFactors=FALSE) #it is easier to get the output you wanted dat1[!duplicated(dat1$value),] #? id1 id2 value #1?? a?? b??? 10 #2?? c?? d??? 11 #4?? c?? e??? 12 But, if you...
2011 Aug 02
2
Data frame to matrix - revisited
Hi, I've tried to look through all the previous related Threads/posts but can't find a solution to what's probably a simple question. ? I have a data frame comprised of three columns e.g.: ? ID1?ID2?Value a?b?1 b?d?1 c?a?2 c?e?1 d?a?1 e?d?2 ? I'd like to convert the data to a matrix i.e.: ? ?a b c d e a n/a 1 2 1 n/a b 1 n/a n/a 1 n/a? c 2 n/a n/a n/a 1 d 1 1 n/a n/a 2 e n/a n/a 1 2 n/a ? Any help is much appreciated, ? Jagz
2011 Apr 25
2
Problem with ddply in the plyr-package: surprising output of a date-column
...m with the plyr package - more precisely with the ddply function - and would be very grateful for any help. I hope the example here is precise enough for someone to identify the problem. Basically, in this step I want to identify observations that are identical in terms of certain identifiers (ID1, ID2, ID3) and just want to save those observations (in this step, without deleting any rows or manipulating any data) in a separate data.frame. However, I get the warning message below and the column with dates is messed up. Interestingly, the value column (the type is factor here, but if you change th...
2008 Jul 09
2
Parsing
Dear R users, I have a big text file formatted like this: x x_string y y_string id1 id1_string id2 id2_string z z_string w w_string stuff stuff stuff stuff stuff stuff stuff stuff stuff // x x_string1 y y_string1 z z_string1 w w_string1 stuff stuff stuff stuff stuff stuff stuff stuff stuff // x x_string2 y y_string2 id1 id1_string1 id2...
2007 Apr 20
2
Fastest way to repeatedly subset a data frame?
Hi - I have a data frame with a large number of observations (62,000 rows, but only 2 columns - a character ID and a result list). Sample: > my.df <- data.frame(id=c("ID1", "ID2", "ID3"), result=1:3) > my.df id result 1 ID1 1 2 ID2 2 3 ID3 3 I have a list of ID vectors. This list will have anywhere from 100 to 1000 members, and each member will have anywhere from 10 to 5000 id entries. Sample: > my.idlist[["List1"]] &...
2005 Aug 10
1
Why only a "" string for heading for row.names with write.csv with a matrix?
Consider: > x <- matrix(1:6, 2,3) > rownames(x) <- c("ID1", "ID2") > colnames(x) <- c("Attr1", "Attr2", "Attr3") > x Attr1 Attr2 Attr3 ID1 1 3 5 ID2 2 4 6 > write.csv(x,file="x.csv") "","Attr1","Attr2","Attr3" "ID1",1,3,5 &quot...
2010 Jun 03
2
deduplication
...one. IDs for de-duplication (names, sex, lab number...) are patchy. In a first step, I am using Andreas Borg's excellent record linkage package (), that leaves me with a list of 'pairs' looking very much like this: id1<-c(4,17,9,1,1,1,3,3,6,15,1,1,1,1,3,3,3,3,4,4,4,5,5,12,9,9,10,10) id2<-c(8,18,10,3,6,7,6,7,7,16,4,5,12,18,4,5,12,18,5,12,18,12,18,18,15,16,15,16) id<-data.frame(cbind(id1,id2)) where a pair means that the records belong to the same individual (e.g., record 4 and record 8; 17 and 18...). My problem now is to get a list with all records that belong to the same pe...
2009 Feb 12
3
get top 50 correlated item from a correlation matrix for each item
Hi, I have a correlation matrix of about 3000 items, i.e., a 3000*3000 matrix. For each of the 3000 items, I want to get the top 50 items that have the highest correlation with it (excluding itself) and generate a data frame with 3 columns like ("ID", "ID2", "cor"), where ID is those 3000 items each repeat 50 times, and ID2 is the top 50 correlated items with ID, and cor is the correlation of ID and ID2. I know I can use two for loops to do it but it is very time consuming considering the correlation matrix is generated for each month...
2006 Feb 09
1
List Conversion
Hello, I have a list (mode and class are list) in R that is many elements long and of the form: >length(list) [1] 5778 >list[1:4] $ID1 [1] "num1" $ID2 [1] "num2" "num3" $ID3 [1] "num4" $ID4 [1] NA I'd like to convert the $ID2 value to be in one element rather than in two.?? It shows up as c(\"num2\", \"num3\") if I try to use paste(list[2], collapse=""). I need to do this over the...
2012 Aug 03
3
all duplicated wanted
Hi, Has anyone been able to figure out how to print all duplicated observations? I have a dataset, with patients ID, and other lab records. Some patients have multiple lab records, but 'duplicated' ID will only show me the duplicates, not the original observation. How can I print both the original one and the duplicates? Thanks
2005 Nov 09
3
dataframe without repetition
Hello, with a data.frame like this : > toto <- data.frame(id=c("id1","id1","id2","id3","id3","id3"),dpt=c("13","13","34","30","30","30")) > toto id dpt 1 id1 13 2 id1 13 3 id2 34 4 id3 30 5 id3 30 6 id3 30 what is the most efficient ways to obtain : id dpt 1 id1 13...
2010 Sep 07
1
average columns of data frame corresponding to replicates
...a frame so that the repeated ids are averaged. For example, in the new data frame, columns 1, 3, and 5 of the original will be replaced by 1 new column that is the mean of these three. Thanks for any suggestions. Juliet myData <- data.frame("sample1.id1" =rep(1,10), "sample1.id2"=rep(2,10), "sample2.id1" = rep(2,10), "sample1.id3" = 1:10, "sample3.id1" = rep(1,10), "sample1.id4" = 1:10, "sample2.id2" = rep(1,10)) repeat_ids <- c("id1","id2")
2012 Feb 22
1
Lattice and horizontally stacked density plots
Hello, I am try to make a density plot where plots are stacked like the one found here: http://dsarkar.fhcrc.org/lattice/book/images/Figure_14_03_stdBW.png I am facing problems, however. Using the code example below, I'd like to generate a separate panel for each val of id2. Within each panel, I'd like to have individual histograms each on separate lines based on the value of id1. ?Note that the code example works fine if I use "boxplot" instead of "densityplot". Any pointers would be much appreciated. library(lattice) val<-rep(rnorm(10),1...
2012 Sep 15
5
create new variable with ifelse? (reproducible example)
Dear R users, I have a reproducible data and try to create new variable "clo" is 1 if know variable is equal to "very well" or "fairly well" and getalong is 4 or 5 otherwise it is 0. rep_data<- read.table(header=TRUE, text=" id1 id2 know getalong 100000016_a1 100000016_a2 very well 4 100000035_a1 100000035_a2 fairly well NA 100000036_a1 100000036_a2 very well 3 100000039_a1 100000039_a2 very well 5 100000067_a1 100000067_a2 very well 5 100000076_a1 100000076_a2...