R - Как объединить столбцы в кадре данных на основе значения в первой строке - PullRequest
1 голос
/ 06 марта 2019

У меня есть этот фрейм данных (см. Dput ниже), где есть разные столбцы, каждый из которых имеет идентификатор / имя в первой строке. Я хотел бы объединить все столбцы с одинаковым значением в первой строке в один столбец. Таким образом, конечным результатом будет кадр данных с двенадцатью столбцами (уникальные значения из первой строки), содержащий все значения с одинаковым именем в строке 1.

Я пробовал group_by и сбор, но оба не совсем то, что я ищу.

structure(list(V1 = structure(c(13L, 10L, 2L, 12L, 1L, 6L, 11L, 
7L, 8L, 5L, 4L, 3L, 9L), .Label = c("146", "173", "213", "422", 
"44,75", "528", "538", "558", "585", "61,41", "656", "90,8", 
"A. fumigatus"), class = "factor"), V2 = structure(c(13L, 3L, 
10L, 11L, 12L, 7L, 8L, 4L, 6L, 5L, 9L, 1L, 2L), .Label = c("129", 
"141", "15,42", "153", "16,33", "171", "177", "306", "374", "42,69", 
"80,58", "89,28", "A. fumigatus"), class = "factor"), V3 = structure(c(13L, 
8L, 1L, 5L, 6L, 2L, 4L, 11L, 10L, 12L, 3L, 9L, 7L), .Label = c("11,93", 
"115", "159", "164", "22,83", "22,84", "39,84", "4,27", "43,91", 
"53,33", "54,78", "6,75", "A. fumigatus"), class = "factor"), 
    V4 = structure(c(4L, 3L, 1L, 1L, 5L, 5L, 5L, 5L, 5L, 2L, 
    5L, 5L, 5L), .Label = c("10000", "1930", "5238", "A. fumigatus", 
    "NaN"), class = "factor"), V5 = structure(c(5L, 4L, 2L, 1L, 
    6L, 6L, 6L, 6L, 6L, 3L, 6L, 6L, 6L), .Label = c("4315", "4324", 
    "7650", "7842", "A. fumigatus", "NaN"), class = "factor"), 
    V6 = structure(c(5L, 2L, 3L, 4L, 6L, 6L, 6L, 6L, 6L, 1L, 
    6L, 6L, 6L), .Label = c("28,52", "3,20", "380", "399", "A. fumigatus", 
    "NaN"), class = "factor"), V7 = structure(c(13L, 12L, 9L, 
    11L, 6L, 2L, 5L, 1L, 3L, 4L, 8L, 10L, 7L), .Label = c("1088", 
    "1281", "1327", "167", "1897", "1985", "2143", "2467", "654", 
    "664", "806", "97,88", "A. fumigatus"), class = "factor"), 
    V8 = structure(c(9L, 10L, 10L, 10L, 8L, 7L, 1L, 4L, 5L, 10L, 
    3L, 2L, 6L), .Label = c("110", "143", "169", "23,89", "31,04", 
    "39,72", "63,82", "81,02", "A. fumigatus", "NaN"), class = "factor"), 
    V9 = structure(c(8L, 9L, 9L, 9L, 2L, 7L, 1L, 5L, 6L, 9L, 
    3L, 4L, 1L), .Label = c("1119", "2100", "2210", "2370", "2595", 
    "4020", "4238", "A. fumigatus", "NaN"), class = "factor"), 
    V10 = structure(c(13L, 2L, 3L, 9L, 8L, 12L, 7L, 4L, 11L, 
    1L, 10L, 5L, 6L), .Label = c("132,00", "172", "1997", "2022", 
    "2379", "248", "253", "2850", "31,57", "6589", "7977", "819", 
    "C. albicans"), class = "factor"), V11 = structure(c(13L, 
    11L, 8L, 1L, 7L, 12L, 4L, 2L, 3L, 10L, 5L, 9L, 6L), .Label = c("10,89", 
    "1022", "1334", "1351", "2262", "241", "254", "4102", "421", 
    "56,59", "657", "832", "C. albicans"), class = "factor"), 
    V12 = structure(c(13L, 10L, 4L, 5L, 7L, 1L, 3L, 2L, 11L, 
    6L, 8L, 12L, 9L), .Label = c("16,11", "17,53", "27,32", "27,64", 
    "3,2", "3,20", "3,26", "39,65", "4,33", "6,75", "72,23", 
    "9,99", "C. albicans"), class = "factor"), V13 = structure(c(5L, 
    2L, 1L, 3L, 6L, 6L, 6L, 6L, 6L, 4L, 6L, 6L, 6L), .Label = c("10000", 
    "10000,00", "119", "1671", "C. albicans", "NaN"), class = "factor"), 
    V14 = structure(c(5L, 3L, 1L, 4L, 6L, 6L, 6L, 6L, 6L, 2L, 
    6L, 6L, 6L), .Label = c("10000", "382", "6777", "91,11", 
    "C. albicans", "NaN"), class = "factor"), V15 = structure(c(5L, 
    2L, 1L, 3L, 6L, 6L, 6L, 6L, 6L, 4L, 6L, 6L, 6L), .Label = c("10000", 
    "10000,00", "28,32", "462", "C. albicans", "NaN"), class = "factor"), 
    V16 = structure(c(13L, 1L, 3L, 12L, 10L, 2L, 8L, 7L, 9L, 
    11L, 4L, 5L, 6L), .Label = c("1008", "1015", "1133", "1440", 
    "225", "232", "362", "364", "615", "729", "89,83", "9,22", 
    "C. albicans"), class = "factor"), V17 = structure(c(9L, 
    10L, 10L, 10L, 4L, 2L, 1L, 3L, 7L, 10L, 6L, 5L, 8L), .Label = c("2007", 
    "2036", "2747", "3834", "4732", "5255", "6358", "811", "C. albicans", 
    "NaN"), class = "factor"), V18 = structure(c(9L, 10L, 10L, 
    10L, 8L, 2L, 6L, 7L, 3L, 10L, 1L, 5L, 4L), .Label = c("1077", 
    "1620", "2022", "314", "616", "684", "931", "951", "C. albicans", 
    "NaN"), class = "factor"), V19 = structure(c(13L, 6L, 4L, 
    1L, 8L, 5L, 2L, 11L, 3L, 10L, 9L, 7L, 12L), .Label = c("11,36", 
    "164", "34,33", "34,47", "37,79", "4,42", "40,84", "57,47", 
    "66,61", "7,91", "71,86", "9,45", "CpG"), class = "factor"), 
    V20 = structure(c(13L, 4L, 2L, 3L, 12L, 7L, 10L, 5L, 6L, 
    9L, 11L, 1L, 8L), .Label = c("110", "137", "14,79", "15,81", 
    "156", "161", "165", "17,84", "21,65", "545", "588", "82,52", 
    "CpG"), class = "factor"), V21 = structure(c(7L, 6L, 5L, 
    5L, 3L, 2L, 4L, 1L, 1L, 6L, 1L, 1L, 1L), .Label = c("1,28", 
    "1,69", "1,71", "2,97", "3,2", "3,20", "CpG"), class = "factor"), 
    V22 = structure(c(6L, 5L, 2L, 4L, 1L, 1L, 1L, 1L, 1L, 3L, 
    7L, 1L, 1L), .Label = c(" NaN", "10000", "1064", "307", "5867", 
    "CpG", "NaN"), class = "factor"), V23 = structure(c(6L, 2L, 
    5L, 3L, 1L, 1L, 1L, 1L, 1L, 4L, 7L, 1L, 1L), .Label = c(" NaN", 
    "2251", "452", "671", "9386", "CpG", "NaN"), class = "factor"), 
    V24 = structure(c(6L, 4L, 2L, 3L, 1L, 1L, 1L, 1L, 1L, 5L, 
    7L, 1L, 1L), .Label = c(" NaN", "1144", "115", "193", "405", 
    "CpG", "NaN"), class = "factor"), V25 = structure(c(13L, 
    4L, 8L, 9L, 7L, 11L, 12L, 5L, 6L, 2L, 10L, 3L, 1L), .Label = c("118", 
    "133", "150", "179", "256", "287", "373", "418", "45,24", 
    "545", "547", "564", "CpG"), class = "factor"), V26 = structure(c(9L, 
    10L, 10L, 10L, 7L, 1L, 5L, 6L, 3L, 10L, 4L, 2L, 8L), .Label = c("104", 
    "1080", "124", "126", "148", "179", "181", "43,52", "CpG", 
    "NaN"), class = "factor"), V27 = structure(c(9L, 10L, 10L, 
    10L, 1L, 8L, 6L, 7L, 4L, 10L, 5L, 2L, 3L), .Label = c("1054", 
    "1177", "142", "1539", "346", "473", "884", "987", "CpG", 
    "NaN"), class = "factor"), V28 = structure(c(13L, 12L, 10L, 
    7L, 8L, 2L, 5L, 3L, 6L, 11L, 4L, 9L, 1L), .Label = c("118", 
    "1237", "1520", "1648", "2489", "2695", "274", "3114", "436", 
    "548", "83,46", "97,20", "E. coli"), class = "factor"), V29 = structure(c(13L, 
    10L, 1L, 4L, 6L, 7L, 9L, 8L, 11L, 2L, 12L, 5L, 3L), .Label = c("10000", 
    "1385", "1461", "2535", "3678", "5256", "6255", "6798", "6908", 
    "7937", "8708", "9588", "E. coli"), class = "factor"), V30 = structure(c(13L, 
    6L, 5L, 10L, 2L, 9L, 8L, 3L, 7L, 11L, 4L, 12L, 1L), .Label = c("145", 
    "242", "303", "310", "334", "361", "495", "528", "666", "77,9", 
    "80,37", "85,47", "E. coli"), class = "factor"), V31 = structure(c(4L, 
    3L, 1L, 1L, 5L, 5L, 5L, 5L, 5L, 2L, 5L, 5L, 5L), .Label = c("10000", 
    "10000,00", "7558", "E. coli", "NaN"), class = "factor"), 
    V32 = structure(c(5L, 1L, 4L, 3L, 6L, 6L, 6L, 6L, 6L, 2L, 
    6L, 6L, 6L), .Label = c("1217", "291", "609", "831", "E. coli", 
    "NaN"), class = "factor"), V33 = structure(c(4L, 2L, 1L, 
    3L, 5L, 5L, 5L, 5L, 5L, 2L, 5L, 5L, 5L), .Label = c("10000", 
    "10000,00", "4330", "E. coli", "NaN"), class = "factor"), 
    V34 = structure(c(13L, 4L, 1L, 9L, 7L, 6L, 2L, 12L, 5L, 8L, 
    3L, 11L, 10L), .Label = c("1189", "1383", "2285", "2303", 
    "2306", "2395", "3289", "430", "494", "500", "673", "990", 
    "E. coli"), class = "factor"), V35 = structure(c(9L, 10L, 
    10L, 10L, 1L, 7L, 4L, 5L, 8L, 10L, 6L, 3L, 2L), .Label = c("11068", 
    "1322", "14182", "2563", "3037", "3212", "3689", "9362", 
    "E. coli", "NaN"), class = "factor"), V36 = structure(c(9L, 
    10L, 10L, 10L, 4L, 7L, 2L, 5L, 8L, 10L, 6L, 3L, 1L), .Label = c("123", 
    "257", "260", "396", "421", "451", "574", "671", "E. coli", 
    "NaN"), class = "factor"), V37 = structure(c(13L, 2L, 7L, 
    1L, 12L, 10L, 11L, 9L, 6L, 4L, 5L, 8L, 3L), .Label = c("191", 
    "196", "2061", "27,23", "276", "3449", "4321", "462", "4907", 
    "4924", "5840", "7721", "Flageline"), class = "factor"), 
    V38 = structure(c(12L, 11L, 1L, 1L, 5L, 4L, 2L, 6L, 3L, 10L, 
    7L, 8L, 9L), .Label = c("10000", "13509", "13527", "13667", 
    "14936", "16159", "17250", "17338", "4902", "7514", "8689", 
    "Flageline"), class = "factor"), V39 = structure(c(13L, 4L, 
    6L, 3L, 7L, 1L, 11L, 10L, 8L, 12L, 5L, 2L, 9L), .Label = c("1590", 
    "204", "3,55", "303", "306", "405", "433", "593", "600", 
    "648", "890", "96,57", "Flageline"), class = "factor"), V40 = structure(c(3L, 
    2L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 2L, 4L, 4L, 4L), .Label = c("10000", 
    "10000,00", "Flageline", "NaN"), class = "factor"), V41 = structure(c(5L, 
    3L, 2L, 4L, 6L, 6L, 6L, 6L, 6L, 1L, 6L, 6L, 6L), .Label = c("1121", 
    "7277", "7302", "9543", "Flageline", "NaN"), class = "factor"), 
    V42 = structure(c(3L, 2L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 2L, 
    4L, 4L, 4L), .Label = c("10000", "10000,00", "Flageline", 
    "NaN"), class = "factor"), V43 = structure(c(13L, 7L, 4L, 
    10L, 12L, 11L, 6L, 3L, 9L, 1L, 8L, 5L, 2L), .Label = c("1375", 
    "2178", "3518", "3571", "3609", "3671", "3809", "4808", "6172", 
    "7112", "7713", "9811", "Flageline"), class = "factor"), 
    V44 = structure(c(9L, 10L, 10L, 10L, 4L, 1L, 6L, 5L, 8L, 
    10L, 7L, 2L, 3L), .Label = c("10558", "12843", "1484", "19709", 
    "4070", "4815", "5085", "5479", "Flageline", "NaN"), class = "factor"), 
    V45 = structure(c(9L, 10L, 10L, 10L, 7L, 2L, 6L, 1L, 4L, 
    10L, 3L, 8L, 5L), .Label = c("1048", "1074", "1160", "1743", 
    "304", "487", "798", "992", "Flageline", "NaN"), class = "factor"), 
    V46 = structure(c(13L, 9L, 1L, 12L, 7L, 6L, 11L, 4L, 5L, 
    2L, 10L, 3L, 8L), .Label = c("106", "12,62", "146", "164", 
    "204", "21,84", "242", "29,55", "41,18", "58,41", "611", 
    "79,36", "LPS"), class = "factor"), V47 = structure(c(13L, 
    4L, 12L, 11L, 6L, 3L, 1L, 7L, 8L, 9L, 2L, 10L, 5L), .Label = c("1089", 
    "1185", "154", "1758", "206", "210", "257", "291", "3,73", 
    "419", "57,8", "938", "LPS"), class = "factor"), V48 = structure(c(12L, 
    5L, 11L, 6L, 2L, 1L, 4L, 9L, 10L, 7L, 8L, 3L, 10L), .Label = c("1,28", 
    "1,32", "2,18", "24,36", "26,87", "3,2", "3,20", "3,5", "3,6", 
    "5,74", "7,26", "LPS"), class = "factor"), V49 = structure(c(6L, 
    3L, 2L, 4L, 1L, 1L, 1L, 1L, 1L, 5L, 7L, 1L, 1L), .Label = c(" NaN", 
    "10000", "10000,00", "518", "612", "LPS", "NaN"), class = "factor"), 
    V50 = structure(c(6L, 2L, 5L, 3L, 1L, 1L, 1L, 1L, 1L, 4L, 
    7L, 1L, 1L), .Label = c(" NaN", "1518", "175", "501", "8780", 
    "LPS", "NaN"), class = "factor"), V51 = structure(c(6L, 2L, 
    4L, 3L, 1L, 1L, 1L, 1L, 1L, 5L, 7L, 1L, 1L), .Label = c(" NaN", 
    "10000,00", "116", "3674", "93,31", "LPS", "NaN"), class = "factor"), 
    V52 = structure(c(13L, 1L, 7L, 8L, 12L, 6L, 11L, 4L, 3L, 
    9L, 10L, 2L, 5L), .Label = c("1315", "211", "239", "249", 
    "262", "357", "519", "52,46", "54,83", "574", "658", "698", 
    "LPS"), class = "factor"), V53 = structure(c(9L, 10L, 10L, 
    10L, 3L, 5L, 2L, 8L, 7L, 10L, 1L, 6L, 4L), .Label = c("128", 
    "137", "382", "50,49", "52,52", "797", "80,12", "81,83", 
    "LPS", "NaN"), class = "factor"), V54 = structure(c(9L, 10L, 
    10L, 10L, 6L, 1L, 7L, 8L, 3L, 10L, 2L, 5L, 4L), .Label = c("1029", 
    "1084", "1375", "278", "355", "573", "624", "871", "LPS", 
    "NaN"), class = "factor"), V55 = structure(c(13L, 9L, 3L, 
    11L, 4L, 2L, 10L, 5L, 6L, 1L, 7L, 8L, 12L), .Label = c("11,89", 
    "1127", "1321", "1372", "1471", "1857", "240", "283", "3,20", 
    "603", "62,13", "90,54", "P. auruginosa"), class = "factor"), 
    V56 = structure(c(13L, 10L, 1L, 4L, 3L, 9L, 7L, 6L, 8L, 5L, 
    2L, 11L, 12L), .Label = c("10000", "11816", "1304", "253", 
    "38", "4044", "4225", "4743", "4927", "54,67", "821", "914", 
    "P. auruginosa"), class = "factor"), V57 = structure(c(12L, 
    7L, 4L, 9L, 5L, 6L, 1L, 11L, 2L, 7L, 10L, 8L, 3L), .Label = c("128", 
    "156", "17,93", "170", "22,84", "233", "3,20", "3,6", "4,14", 
    "66,17", "90,11", "P. auruginosa"), class = "factor"), V58 = structure(c(7L, 
    3L, 2L, 4L, 1L, 1L, 1L, 1L, 1L, 5L, 6L, 1L, 1L), .Label = c(" NaN", 
    "10000", "10000,00", "2475", "3430", "NaN", "P. auruginosa"
    ), class = "factor"), V59 = structure(c(7L, 2L, 5L, 3L, 1L, 
    1L, 1L, 1L, 1L, 4L, 6L, 1L, 1L), .Label = c(" NaN", "1533", 
    "285", "425", "8239", "NaN", "P. auruginosa"), class = "factor"), 
    V60 = structure(c(7L, 3L, 2L, 4L, 1L, 1L, 1L, 1L, 1L, 5L, 
    6L, 1L, 1L), .Label = c(" NaN", "10000", "240", "389", "569", 
    "NaN", "P. auruginosa"), class = "factor"), V61 = structure(c(13L, 
    5L, 7L, 3L, 4L, 8L, 1L, 11L, 12L, 2L, 6L, 9L, 10L), .Label = c("1002", 
    "106", "112", "1284", "156", "1821", "1915", "2369", "237", 
    "323", "719", "924", "P. auruginosa"), class = "factor"), 
    V62 = structure(c(10L, 9L, 9L, 9L, 8L, 4L, 1L, 3L, 5L, 9L, 
    2L, 7L, 6L), .Label = c("1429", "2348", "3008", "3123", "5573", 
    "619", "7243", "7329", "NaN", "P. auruginosa"), class = "factor"), 
    V63 = structure(c(10L, 9L, 9L, 9L, 6L, 8L, 4L, 5L, 7L, 9L, 
    1L, 3L, 2L), .Label = c("1002", "162", "250", "279", "509", 
    "527", "894", "930", "NaN", "P. auruginosa"), class = "factor"), 
    V64 = structure(c(13L, 8L, 7L, 4L, 12L, 10L, 3L, 11L, 1L, 
    5L, 2L, 9L, 6L), .Label = c("1009", "134", "1379", "155", 
    "29,03", "32,4", "394", "41,93", "447", "548", "575", "996", 
    "Pam3Cys"), class = "factor"), V65 = structure(c(13L, 2L, 
    9L, 10L, 11L, 5L, 8L, 1L, 3L, 6L, 7L, 4L, 12L), .Label = c("1298", 
    "1371", "1536", "1570", "1953", "203", "2553", "2569", "3362", 
    "625", "715", "875", "Pam3Cys"), class = "factor"), V66 = structure(c(13L, 
    9L, 10L, 2L, 8L, 12L, 1L, 7L, 11L, 6L, 4L, 5L, 3L), .Label = c("139", 
    "14,91", "22,98", "23,44", "26,77", "3,20", "30,46", "31,13", 
    "36,86", "43,14", "51,03", "72,29", "Pam3Cys"), class = "factor"), 
    V67 = structure(c(5L, 2L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 3L, 
    4L, 4L, 4L), .Label = c("10000", "10000,00", "7909", "NaN", 
    "Pam3Cys"), class = "factor"), V68 = structure(c(6L, 2L, 
    4L, 1L, 5L, 5L, 5L, 5L, 5L, 3L, 5L, 5L, 5L), .Label = c("1973", 
    "5314", "873", "8807", "NaN", "Pam3Cys"), class = "factor"), 
    V69 = structure(c(6L, 2L, 1L, 4L, 5L, 5L, 5L, 5L, 5L, 3L, 
    5L, 5L, 5L), .Label = c("10000", "10000,00", "1556", "634", 
    "NaN", "Pam3Cys"), class = "factor"), V70 = structure(c(12L, 
    9L, 8L, 1L, 10L, 2L, 11L, 5L, 6L, 4L, 7L, 3L, 5L), .Label = c("109", 
    "1333", "180", "253", "341", "342", "444", "548", "570", 
    "580", "590", "Pam3Cys"), class = "factor"), V71 = structure(c(10L, 
    9L, 9L, 9L, 3L, 5L, 1L, 2L, 4L, 9L, 6L, 7L, 8L), .Label = c("1228", 
    "2119", "2654", "2940", "3115", "3696", "6276", "656", "NaN", 
    "Pam3Cys"), class = "factor"), V72 = structure(c(10L, 9L, 
    9L, 9L, 5L, 1L, 4L, 7L, 8L, 9L, 6L, 3L, 2L), .Label = c("1409", 
    "296", "407", "417", "521", "853", "868", "978", "NaN", "Pam3Cys"
    ), class = "factor"), V73 = structure(c(13L, 3L, 7L, 8L, 
    1L, 11L, 4L, 5L, 12L, 9L, 6L, 10L, 2L), .Label = c("108", 
    "14,96", "15,88", "153", "212", "22,9", "25,8", "3,2", "35,02", 
    "44,25", "51,56", "83,88", "Poly:IC"), class = "factor"), 
    V74 = structure(c(13L, 10L, 1L, 7L, 11L, 2L, 6L, 4L, 12L, 
    8L, 5L, 3L, 9L), .Label = c("130", "147", "161", "164", "236", 
    "256", "3,2", "376", "43,59", "44,45", "70,34", "77,16", 
    "Poly:IC"), class = "factor"), V75 = structure(c(9L, 7L, 
    6L, 6L, 1L, 4L, 8L, 5L, 2L, 3L, 1L, 1L, 1L), .Label = c("1,28", 
    "1,5", "19,30", "2,09", "2,18", "3,2", "3,20", "5,95", "Poly:IC"
    ), class = "factor"), V76 = structure(c(6L, 2L, 3L, 4L, 5L, 
    5L, 5L, 5L, 5L, 1L, 5L, 5L, 5L), .Label = c("10000,00", "3606", 
    "5961", "73,8", "NaN", "Poly:IC"), class = "factor"), V77 = structure(c(6L, 
    2L, 3L, 4L, 5L, 5L, 5L, 5L, 5L, 1L, 5L, 5L, 5L), .Label = c("1208", 
    "5464", "6710", "97,37", "NaN", "Poly:IC"), class = "factor"), 
    V78 = structure(c(6L, 2L, 4L, 1L, 5L, 5L, 5L, 5L, 5L, 3L, 
    5L, 5L, 5L), .Label = c("10,75", "159", "2957", "328", "NaN", 
    "Poly:IC"), class = "factor"), V79 = structure(c(12L, 4L, 
    5L, 11L, 9L, 7L, 10L, 6L, 3L, 4L, 8L, 2L, 1L), .Label = c("120", 
    "131", "133", "144", "223", "250", "303", "343", "361", "388", 
    "7,43", "Poly:IC"), class = "factor"), V80 = structure(c(10L, 
    9L, 9L, 9L, 2L, 8L, 7L, 1L, 6L, 9L, 4L, 3L, 5L), .Label = c("128", 
    "134", "304", "43,05", "43,24", "50,49", "59,48", "61,32", 
    "NaN", "Poly:IC"), class = "factor"), V81 = structure(c(10L, 
    9L, 9L, 9L, 7L, 6L, 2L, 5L, 8L, 9L, 3L, 4L, 1L), .Label = c("192", 
    "401", "417", "506", "787", "809", "845", "940", "NaN", "Poly:IC"
    ), class = "factor"), V82 = structure(c(13L, 3L, 7L, 12L, 
    9L, 2L, 1L, 11L, 4L, 5L, 10L, 6L, 8L), .Label = c("12138", 
    "12932", "157", "17028", "253,00", "2614", "3309", "569", 
    "6479", "7485", "8129", "890", "R848"), class = "factor"), 
    V83 = structure(c(13L, 7L, 11L, 3L, 1L, 4L, 6L, 5L, 8L, 9L, 
    10L, 2L, 12L), .Label = c("1004", "1940", "242", "3462", 
    "3562", "4001", "4420", "4591", "489", "5454", "7932", "867", 
    "R848"), class = "factor"), V84 = structure(c(13L, 11L, 2L, 
    4L, 10L, 12L, 8L, 6L, 9L, 3L, 5L, 1L, 7L), .Label = c("15,09", 
    "17,16", "3,20", "3,43", "35,25", "37,21", "4,33", "44,43", 
    "59,06", "7,71", "9,02", "99,87", "R848"), class = "factor"), 
    V85 = structure(c(6L, 3L, 2L, 1L, 5L, 5L, 5L, 5L, 5L, 4L, 
    5L, 5L, 5L), .Label = c("1910", "3833", "4093", "5607", "NaN", 
    "R848"), class = "factor"), V86 = structure(c(6L, 1L, 3L, 
    4L, 5L, 5L, 5L, 5L, 5L, 2L, 5L, 5L, 5L), .Label = c("4874", 
    "587", "6595", "993", "NaN", "R848"), class = "factor"), 
    V87 = structure(c(6L, 2L, 1L, 4L, 5L, 5L, 5L, 5L, 5L, 3L, 
    5L, 5L, 5L), .Label = c("10000", "10000,00", "2110", "331", 
    "NaN", "R848"), class = "factor"), V88 = structure(c(13L, 
    5L, 2L, 12L, 3L, 7L, 1L, 11L, 6L, 8L, 4L, 9L, 10L), .Label = c("1062", 
    "1072", "1421", "1562", "1701", "1771", "2410", "286", "412", 
    "462", "645", "97,35", "R848"), class = "factor"), V89 = structure(c(9L, 
    8L, 8L, 8L, 1L, 4L, 3L, 2L, 5L, 8L, 7L, 5L, 6L), .Label = c("10241", 
    "14548", "14711", "17571", "20000", "6841", "7971", "NaN", 
    "R848"), class = "factor"), V90 = structure(c(10L, 9L, 9L, 
    9L, 5L, 8L, 2L, 4L, 7L, 9L, 6L, 3L, 1L), .Label = c("148", 
    "203", "250", "304", "359", "373", "545", "628", "NaN", "R848"
    ), class = "factor"), V91 = structure(c(13L, 4L, 10L, 7L, 
    1L, 9L, 2L, 8L, 6L, 5L, 12L, 3L, 11L), .Label = c("12,98", 
    "158", "16,09", "17,08", "19,03", "25,64", "3,2", "32,15", 
    "50,97", "6,51", "8,54", "9,83", "RPMI"), class = "factor"), 
    V92 = structure(c(13L, 11L, 8L, 7L, 1L, 10L, 3L, 2L, 9L, 
    6L, 12L, 4L, 5L), .Label = c("1,82", "116", "181", "19,69", 
    "26,1", "3,20", "4,83", "56,28", "67,82", "75,59", "9,25", 
    "98,17", "RPMI"), class = "factor"), V93 = structure(c(5L, 
    3L, 2L, 2L, 1L, 1L, 4L, 1L, 1L, 3L, 1L, 1L, 1L), .Label = c("1,28", 
    "3,2", "3,20", "9,22", "RPMI"), class = "factor"), V94 = structure(c(7L, 
    4L, 2L, 3L, 1L, 1L, 1L, 1L, 1L, 5L, 6L, 1L, 1L), .Label = c(" NaN", 
    "10000", "220", "5043", "857,00", "NaN", "RPMI"), class = "factor"), 
    V95 = structure(c(7L, 5L, 4L, 3L, 1L, 1L, 1L, 1L, 1L, 2L, 
    6L, 1L, 1L), .Label = c(" NaN", "162", "164", "5724", "737", 
    "NaN", "RPMI"), class = "factor"), V96 = structure(c(7L, 
    5L, 4L, 3L, 1L, 1L, 1L, 1L, 1L, 2L, 6L, 1L, 1L), .Label = c(" NaN", 
    "103", "12,56", "199", "28,16", "NaN", "RPMI"), class = "factor"), 
    V97 = structure(c(13L, 10L, 3L, 12L, 8L, 6L, 7L, 4L, 2L, 
    9L, 5L, 11L, 1L), .Label = c("100", "115", "116", "123", 
    "174", "181", "269", "36,31", "40,43", "66,01", "67,43", 
    "9,22", "RPMI"), class = "factor"), V98 = structure(c(10L, 
    9L, 9L, 9L, 2L, 3L, 5L, 8L, 4L, 9L, 7L, 1L, 6L), .Label = c("173", 
    "21,06", "26,94", "28,46", "37,41", "38,6", "40,86", "43,46", 
    "NaN", "RPMI"), class = "factor"), V99 = structure(c(10L, 
    9L, 9L, 9L, 3L, 7L, 6L, 2L, 1L, 9L, 8L, 5L, 4L), .Label = c("1139", 
    "1151", "218", "286", "504", "575", "866", "916", "NaN", 
    "RPMI"), class = "factor"), V100 = structure(c(13L, 12L, 
    11L, 9L, 7L, 3L, 2L, 6L, 1L, 4L, 10L, 8L, 5L), .Label = c("12410", 
    "1565", "2421", "3,20", "300", "3175", "3185", "503", "53,69", 
    "575", "5890", "7,66", "S. aureus"), class = "factor"), V101 = structure(c(13L, 
    9L, 12L, 2L, 8L, 4L, 5L, 1L, 7L, 6L, 3L, 10L, 11L), .Label = c("1449", 
    "176", "1839", "1879", "2235", "3,38", "3625", "366", "45,57", 
    "598", "670", "8059", "S. aureus"), class = "factor"), V102 = structure(c(12L, 
    8L, 2L, 7L, 3L, 4L, 5L, 9L, 10L, 8L, 1L, 11L, 6L), .Label = c("11,68", 
    "165", "18,11", "208", "221", "29,81", "3,2", "3,20", "49,97", 
    "518", "6,81", "S. aureus"), class = "factor"), V103 = structure(c(6L, 
    2L, 1L, 3L, 5L, 5L, 5L, 5L, 5L, 4L, 5L, 5L, 5L), .Label = c("10000", 
    "10000,00", "1218", "437", "NaN", "S. aureus"), class = "factor"), 
    V104 = structure(c(6L, 1L, 4L, 2L, 5L, 5L, 5L, 5L, 5L, 3L, 
    5L, 5L, 5L), .Label = c("1123", "699", "79,96", "8006", "NaN", 
    "S. aureus"), class = "factor"), V105 = structure(c(6L, 2L, 
    1L, 3L, 5L, 5L, 5L, 5L, 5L, 4L, 5L, 5L, 5L), .Label = c("10000", 
    "130", "191", "41,69", "NaN", "S. aureus"), class = "factor"), 
    V106 = structure(c(13L, 3L, 2L, 11L, 10L, 4L, 12L, 8L, 1L, 
    5L, 9L, 6L, 7L), .Label = c("1291", "1581", "166", "1973", 
    "20,69", "206", "322", "493", "744", "753", "83,29", "958", 
    "S. aureus"), class = "factor"), V107 = structure(c(10L, 
    9L, 9L, 9L, 5L, 8L, 4L, 3L, 1L, 9L, 6L, 7L, 2L), .Label = c("15891", 
    "2079", "3960", "4168", "4974", "609", "7635", "7766", "NaN", 
    "S. aureus"), class = "factor"), V108 = structure(c(10L, 
    9L, 9L, 9L, 7L, 2L, 5L, 8L, 1L, 9L, 6L, 4L, 3L), .Label = c("1397", 
    "1683", "251", "399", "480", "787", "842", "964", "NaN", 
    "S. aureus"), class = "factor")), class = "data.frame", row.names = c(NA, 
-13L))

Спасибо за потраченное время.

1 Ответ

1 голос
/ 06 марта 2019
# set first values as column names
names(df) <- as.character(unlist(df[1,]))
# remove first values
df <- df[-1,]
# convert all columns to numeric (convert to character and remove commas first)
df[] <- lapply(df, function(x) as.numeric(gsub(',', '', x)))
# combine same-name columns to create new data frame
df2 <- as.data.frame(lapply(split.default(df, names(df)), unlist))
rownames(df2) <- NULL
...