Question

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

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]))))
{
}
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!

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?