R删除重复的列

时间:2018-02-23 08:31:44

标签: r unique

我有这样的数据

     X3    X4    X5    X6     X7   X24   X25   X26    X39    X40    X41    X54    X55    X56    X69    X70    X71
1 step1 step2 step3 step4 step10 step2 step3 step4 step10 step10 step10 step10 step10 step10 step10 step10 step10

我希望删除重复的列。所以期望的输出是

  X3    X4    X5    X6     X7
1 step1 step2 step3 step4 step10

2 个答案:

答案 0 :(得分:4)

    //Speichert die aktuellen Angaben in einem Nested-JSON Objekt
function saveBewertung() {
var jsonObj = {};
var kriterien = []; 
var bewertungen = {};

 //Loop
$('input[type=range]').each(function() {


    var id = $(this).attr("id");
    var note = $(this).val();


    bewertungen.id = id;
    bewertungen.note = note;

    kriterien.push(bewertungen);
    jsonObj.Bewertungen = kriterien;

});

jsonObj.Kommentar  = $('textarea#kommentar').val();


//TEST AUSGABE
alert(JSON.stringify(jsonObj));

}

答案 1 :(得分:0)

试试这个:

df <- read.table(text = "X3    X4    X5    X6     X7   X24   X25   X26    X39    X40    X41    X54    X55    X56    X69    X70    X71
1 step1 step2 step3 step4 step10 step2 step3 step4 step10 step10 step10 step10 step10 step10 step10 step10 step10",
                 header = TRUE)

df[!duplicated(lapply(df, summary))]
#Output
#     X3    X4    X5    X6     X7
#1 step1 step2 step3 step4 step10