Question
Asked 20th Nov, 2014

How can I find unique entries in Table, in "R"?

Suppose I have a table, T3. I would like to find unique values by removing repeated rows (with reversed entries, e.g. row 1 and 4). The final table I need should look like T4. Simply using "unique()" does not solve the problem. Does anyone, know how to solve this problem in R?
x1<- c("a","b","c","e")
y1<- c("e","f","g","a")
T3 <- as.data.frame(cbind(x1,y1))
unique(T3)
x1 y1
1 a e
2 b f
3 c g
4 e a
The table I need should look like T4 below (without 4th row), this is because rows 1 and 4 are considered similar in my graph analysis:
T4
x1 y1
1 a e
2 b f
3 c g

All Answers (3)

20th Nov, 2014
Wietze Pasma
University Medical Center Utrecht
I would use the appoach of sorting the values of each row alphabetically. Combinations of the same letters will have the same result. Rebuild the dataframe with these rows, and then use unique().
x1<- c("e","f","c","a")
y1<- c("a","b","g","e")
T3 <- as.data.frame(cbind(x1,y1))
T4 <- as.data.frame(sort(t(T3)[,1]))
for(i in seq(2,length(t(T3[,1]))))
{
  addT <- sort(t(T3)[,i])
  T4 <- cbind(T4,addT)
}
T4 <- t(T4)
rownames(T4) <- NULL
unique(T3)
unique(T4)
1 Recommendation
20th Nov, 2014
Jimmy Omony
Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH)
Thanks Wietze, I also just realized that something like: " unique(t(apply(T3,1,sort))) " solves the problem!
1 Recommendation
20th Nov, 2014
Wietze Pasma
University Medical Center Utrecht
Thanks, that is a much quicker way, with use of the same concept!

Similar questions and discussions

BEAGLE 4.1 for an imputation run.Can anyone please help me out?
Question
5 answers
  • Nisha K AbilashNisha K Abilash
I am running this command for Imputation
java -Xmx4g -jar beagle.28Jun21.220.jar gt=snp_vcf.vcf map=plink.chr1.GRCh38.map out=out iterations=12 ref=chr1.1kg.phase3.v5a.b37.bref3 chrom=1 impute=TRUE [1:01 PM] I am getting this error ERROR: REF field is not a sequence of A, C, T, G, or N characters at 1:1273381 [I] ERROR: REF field is not a sequence of A, C, T, G, or N characters at 1:2338020 [I] please suggest solution

Related Publications

Conference Paper
Full-text available
El objetivo fue evaluar el comportamiento agronómico de ocho variedades de trigo en Yguazú-Paraguay. La siembra se realizó el 12/05/2017. Los tratamientos fueron T1: CD150; T2: Itapúa-80; T3: IPR-Catuara-TM; T4: IPR-Taquarí; T5: IPR-Potipora; T6: Canindé-21; T7: Itapúa-85; T8: TBIO-Toruk, distribuidos bajo un DBCA con 4 repeticiones. La unidad expe...
Article
Full-text available
300 ‫ابتدائي‬ ‫وزن‬ ‫وبمعدل‬ ‫احد‬ ‫و‬ ‫يوم‬ ‫بعمر‬ ‫روز)‬ ‫(ساللة‬ ‫من‬ ‫لحم)‬ ‫(فروج‬ ‫طير‬ 37 ‫ر‬ ‫غم.‬ ‫ﹸ‬ ‫داخل‬ ‫اجن‬ ‫الدو‬ ‫قاعة‬ ‫في‬ ‫اخ‬ ‫االفر‬ ‫بيت‬ ‫قفص‬ ‫كل‬ ‫مساحة‬ ‫اقفاص‬ 1.5 ‫م‬ 2 ‫عمى‬ ً ‫ائيا‬ ‫عشو‬ ‫عت‬ ُ ‫وز‬ 4 ‫اقع‬ ‫بو‬ ‫معامالت‬ 75 ‫لكل‬ ‫طير‬ ً ‫ائيا‬ ‫عشو‬ ‫اخ‬ ‫االفر‬ ‫وقسمت‬ ‫معاممة‬ (‫ات‬ ‫مكرر‬ ‫ثالثة‬ ‫عمى‬ 25 ‫ة‬ ‫...
Got a technical question?
Get high-quality answers from experts.