在R中合并大量数据框
我有 2008 年 9 月丹麦议会所有投票的数据。问题是每个投票都记录在其自己的 .txt 文件中,格式如下(请参阅帖子的附录,了解 R 中三票的转储):
Name Party Vote
Anders Samuelsen LA For
Rasmus Prehn S Imod
... ... ...
我想将所有文件合并到一个数据帧中,格式如下格式:(
Name Party Vote1 Vote2 Vote3
Anders Samuelsen LA For Imod Imod
Rasmus Prehn S Imod For Fraværende
丹麦语翻译:For = yes,imod = no,Fravérende =absent)
总共我有超过200个文件,所以问题是:如何编写一个循环将所有数据帧合并到所需的结构中多于?
附录:
投票1:
structure(list(V1 = structure(c(2L, 3L, 4L, 7L, 8L, 5L, 6L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,
36L, 37L, 38L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 39L, 54L, 55L, 56L, 60L, 61L, 62L, 63L, 64L,
65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 57L, 58L, 59L,
75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L,
88L, 89L, 90L, 91L, 92L, 93L, 94L, 96L, 97L, 98L, 95L, 99L, 100L,
101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L,
112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L, 121L, 122L,
123L, 125L, 126L, 127L, 124L, 128L, 129L, 130L, 131L, 132L, 133L,
134L, 135L, 136L, 137L, 139L, 140L, 141L, 138L, 142L, 143L, 144L,
145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L, 155L,
160L, 161L, 162L, 163L, 164L, 156L, 157L, 158L, 159L, 165L, 166L,
167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L,
178L, 179L, 1L), .Label = c("Özlem Sara Cekic", "Anders Samuelsen",
"Anita Christensen", "Anita Knakkergaard", "Anne-Marie Meldgaard",
"Anne-Mette Winther Christians", "Anne Baastrup", "Anne Grete Holmsgaard",
"Annette Lilja Vilhelmsen", "Benny Engelbrecht", "Bent Bøgsted",
"Bente Dahl", "Bertel Haarder", "Birgitte Josefsen", "Birthe Rønn Hornbech",
"Bjarne Laustsen", "Brian Mikkelsen", "Britta Schall Holberg",
"Carina Christensen", "Carsten Hansen", "Charlotte Dyremose",
"Christine Antorini", "Claus Hjort Frederiksen", "Colette L. Brix",
"Connie Hedegaard", "Dennis Flydtkjær", "Edmund Joensen", "Eigil Andersen",
"Ellen Trane Nørby", "Erling Bonnesen", "Eva Kjer Hansen", "Eyvind Vesselbo",
"Flemming Bonne", "Flemming Damgaard Larsen", "Flemming Møller",
"Flemming Møller Mortensen", "Frank Aaen", "Gitte Lillelund Bech",
"Høgni Hoydal", "Hanne Agersnap", "Hans Christian Schmidt",
"Hans Christian Thoning", "Hans Kristian Skibby", "Helge Adam Møller",
"Helge Sander", "Helle Sjelle", "Helle Thorning-Schmidt", "Henriette Kjær",
"Henrik Brodersen", "Henrik Dam Kristensen", "Henrik Høegh",
"Henrik Sass Larsen", "Holger K. Nielsen", "Ib Poulsen", "Ida Auken",
"Inger Støjberg", "Jørgen Poulsen", "Jørgen S. Lundsgaard",
"Jørn Dohrmann", "Jacob Jensen", "Jakob Axel Nielsen", "Jens Christian Lund",
"Jens Kirk", "Jens Peter Vernersen", "Jens Vibjerg", "Jeppe Kofod",
"Jesper Langballe", "Jesper Petersen", "Johanne Schmidt-Nielsen",
"John Dyrby Paulsen", "Johs. Poulsen", "Jonas Dahl", "Juliane Henningsen",
"Julie Rademacher", "Kamal Qureshi", "Karen Ellemann", "Karen Hækkerup",
"Karen J. Klint", "Karen Jespersen", "Karin Nødgaard", "Karina Lorentzen Dehnhardt",
"Karl H. Bornhøft", "Karsten Lauritzen", "Karsten Nonbo", "Kim Andersen",
"Kim Christiansen", "Kim Mortensen", "Kirsten Brosbøl", "Klaus Hækkerup",
"Knud Kristensen", "Kristen Touborg", "Kristian Jensen", "Kristian Pihl Lorentzen",
"Kristian Thulesen Dahl", "Lars-Emil Johansen", "Lars Barfoed",
"Lars Christian Lilleholt", "Lars Løkke Rasmussen", "Leif Lahn Jensen",
"Lene Espersen", "Lene Hansen", "Lennart Damsbo-Andersen", "Line Barfod",
"Lise von Seelen", "Liselott Blixt", "Lone Dybkjær", "Lone Møller",
"Louise Schack Elholm", "Magnus Heunicke", "Malou Aamund", "Margrethe Vestager",
"Marianne Jelved", "Marion Pedersen", "Marlene Harpsøe", "Martin Henriksen",
"Meta Fuglsang", "Mette Frederiksen", "Mette Gjerskov", "Michael Aastrup Jensen",
"Mike Legarth", "Mikkel Dencker", "Mogens Jensen", "Mogens Lykketoft",
"Morten Østergaard", "Morten Bødskov", "Morten Helveg Petersen",
"Morten Messerschmidt", "Nanna Westerby", "Naser Khader", "Nick Hækkerup",
"Niels Christian Nielsen", "Niels Helveg Petersen", "Niels Sindal",
"Ole Hækkerup", "Ole Sohn", "Ole Vagn Christensen", "Orla Hav",
"Per Ørum Jørgensen", "Per Bisgaard", "Per Clausen", "Per Stig Møller",
"Pernille Frahm", "Pernille Vigsø Bagge", "Peter Christensen",
"Peter Juel Jensen", "Peter Skaarup", "Pia Adelsteen", "Pia Christmas-Møller",
"Pia Kjærsgaard", "Pia Olsen Dyhr", "Poul Andersen", "Preben Rudiengaard",
"Rasmus Prehn", "René Christensen", "René Skau Björnsson",
"Søren Espersen", "Søren Gade", "Søren Krarup", "Søren Pind",
"Simon Emil Ammitzbøll", "Sophie Hæstorp Andersen", "Sophie Løhde",
"Steen Gade", "Svend Auken", "Thomas Adelskov", "Thomas Jensen",
"Thor Pedersen", "Tina Nedergaard", "Tina Petersen", "Tom Behnke",
"Torben Hansen", "Torsten Schack Pedersen", "Troels Christensen",
"Troels Lund Poulsen", "Ulla Tørnæs", "Villum Christensen",
"Villy Søvndal", "Vivi Kier", "Yildiz Akdogan"), class = "factor"),
V2 = structure(c(5L, 1L, 1L, 8L, 8L, 7L, 13L, 8L, 7L, 1L,
6L, 13L, 13L, 13L, 7L, 4L, 13L, 4L, 7L, 4L, 7L, 13L, 1L,
4L, 1L, 10L, 8L, 13L, 13L, 13L, 13L, 8L, 13L, 13L, 7L, 2L,
13L, 8L, 13L, 13L, 1L, 4L, 13L, 4L, 7L, 4L, 1L, 7L, 13L,
7L, 8L, 11L, 1L, 8L, 13L, 13L, 4L, 7L, 13L, 7L, 13L, 7L,
1L, 8L, 2L, 7L, 6L, 8L, 3L, 7L, 6L, 4L, 1L, 8L, 13L, 7L,
7L, 13L, 1L, 8L, 8L, 13L, 13L, 13L, 1L, 7L, 7L, 7L, 4L, 8L,
13L, 13L, 1L, 4L, 13L, 13L, 9L, 7L, 4L, 7L, 7L, 2L, 7L, 1L,
6L, 7L, 13L, 7L, 13L, 6L, 6L, 13L, 1L, 1L, 8L, 7L, 7L, 13L,
4L, 1L, 7L, 7L, 7L, 6L, 1L, 6L, 8L, 4L, 7L, 7L, 6L, 7L, 7L,
8L, 7L, 7L, 13L, 2L, 4L, 4L, 8L, 8L, 13L, 13L, 1L, 1L, 12L,
1L, 8L, 7L, 13L, 7L, 1L, 7L, 12L, 7L, 13L, 8L, 7L, 1L, 13L,
1L, 13L, 7L, 7L, 13L, 13L, 1L, 4L, 7L, 13L, 13L, 13L, 13L,
5L, 8L, 4L, 7L, 8L), .Label = c("DF", "EL", "IA", "KF", "LA",
"RV", "S", "SF", "SIU", "SP", "TF", "UFG", "V"), class = "factor"),
V3 = structure(c(1L, 1L, 1L, 3L, 3L, 2L, 1L, 3L, 3L, 1L,
3L, 1L, 1L, 2L, 3L, 1L, 1L, 2L, 2L, 1L, 3L, 2L, 2L, 2L, 1L,
2L, 3L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 3L, 2L, 1L, 3L, 2L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 3L, 1L, 2L, 2L, 2L, 1L, 2L, 2L,
1L, 1L, 3L, 1L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 2L, 3L,
2L, 1L, 2L, 2L, 2L, 3L, 2L, 1L, 1L, 3L, 3L, 2L, 1L, 1L, 2L,
3L, 2L, 3L, 2L, 3L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 3L, 2L, 3L,
3L, 3L, 3L, 1L, 3L, 3L, 1L, 3L, 2L, 2L, 3L, 1L, 1L, 1L, 3L,
3L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 1L, 3L, 3L,
3L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 1L, 2L,
1L, 2L, 2L, 2L, 3L, 1L, 3L, 1L, 2L, 1L, 3L, 1L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 3L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 2L,
2L, 1L, 3L, 2L), .Label = c("For", "Fraværende", "Imod"), class = "factor")), .Names = c("V1",
"V2", "V3"), class = "data.frame", row.names = c(NA, -179L))
投票2:
structure(list(V1 = structure(c(2L, 3L, 4L, 7L, 8L, 5L, 6L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,
36L, 37L, 38L, 39L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 54L, 40L, 55L, 56L, 59L, 60L, 61L, 62L, 63L,
64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 57L, 58L, 74L,
75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L,
88L, 89L, 90L, 91L, 92L, 93L, 95L, 96L, 97L, 94L, 98L, 99L, 100L,
101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L,
112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L, 121L, 122L,
124L, 125L, 126L, 123L, 127L, 128L, 129L, 130L, 131L, 132L, 133L,
134L, 135L, 137L, 138L, 139L, 140L, 136L, 141L, 142L, 143L, 144L,
145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L, 159L,
160L, 161L, 162L, 163L, 155L, 156L, 157L, 158L, 164L, 165L, 166L,
167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L,
178L, 179L, 1L), .Label = c("Özlem Sara Cekic", "Anders Samuelsen",
"Anita Christensen", "Anita Knakkergaard", "Anne-Marie Meldgaard",
"Anne-Mette Winther Christians", "Anne Baastrup", "Anne Grete Holmsgaard",
"Annette Lilja Vilhelmsen", "Bendt Bendtsen", "Benny Engelbrecht",
"Bent Bøgsted", "Bente Dahl", "Bertel Haarder", "Birgitte Josefsen",
"Birthe Rønn Hornbech", "Bjarne Laustsen", "Brian Mikkelsen",
"Britta Schall Holberg", "Carina Christensen", "Carsten Hansen",
"Charlotte Dyremose", "Christine Antorini", "Claus Hjort Frederiksen",
"Colette L. Brix", "Connie Hedegaard", "Dennis Flydtkjær", "Edmund Joensen",
"Eigil Andersen", "Ellen Trane Nørby", "Erling Bonnesen", "Eva Kjer Hansen",
"Eyvind Vesselbo", "Flemming Bonne", "Flemming Damgaard Larsen",
"Flemming Møller", "Flemming Møller Mortensen", "Frank Aaen",
"Gitte Lillelund Bech", "Høgni Hoydal", "Hanne Agersnap", "Hans Christian Schmidt",
"Hans Christian Thoning", "Hans Kristian Skibby", "Helge Adam Møller",
"Helge Sander", "Helle Sjelle", "Helle Thorning-Schmidt", "Henriette Kjær",
"Henrik Brodersen", "Henrik Dam Kristensen", "Henrik Høegh",
"Henrik Sass Larsen", "Holger K. Nielsen", "Ib Poulsen", "Inger Støjberg",
"Jørgen Poulsen", "Jørn Dohrmann", "Jacob Jensen", "Jakob Axel Nielsen",
"Jens Christian Lund", "Jens Kirk", "Jens Peter Vernersen", "Jens Vibjerg",
"Jeppe Kofod", "Jesper Langballe", "Jesper Petersen", "Johanne Schmidt-Nielsen",
"John Dyrby Paulsen", "Johs. Poulsen", "Jonas Dahl", "Juliane Henningsen",
"Julie Rademacher", "Kamal Qureshi", "Karen Ellemann", "Karen Hækkerup",
"Karen J. Klint", "Karen Jespersen", "Karin Nødgaard", "Karina Lorentzen Dehnhardt",
"Karl H. Bornhøft", "Karsten Lauritzen", "Karsten Nonbo", "Kim Andersen",
"Kim Christiansen", "Kim Mortensen", "Kirsten Brosbøl", "Klaus Hækkerup",
"Knud Kristensen", "Kristen Touborg", "Kristian Jensen", "Kristian Pihl Lorentzen",
"Kristian Thulesen Dahl", "Lars-Emil Johansen", "Lars Barfoed",
"Lars Christian Lilleholt", "Lars Løkke Rasmussen", "Leif Lahn Jensen",
"Lene Espersen", "Lene Hansen", "Lennart Damsbo-Andersen", "Line Barfod",
"Lise von Seelen", "Liselott Blixt", "Lone Dybkjær", "Lone Møller",
"Louise Schack Elholm", "Magnus Heunicke", "Malou Aamund", "Margrethe Vestager",
"Marianne Jelved", "Marion Pedersen", "Marlene Harpsøe", "Martin Henriksen",
"Meta Fuglsang", "Mette Frederiksen", "Mette Gjerskov", "Michael Aastrup Jensen",
"Mike Legarth", "Mikkel Dencker", "Mogens Jensen", "Mogens Lykketoft",
"Morten Østergaard", "Morten Bødskov", "Morten Helveg Petersen",
"Morten Messerschmidt", "Nanna Westerby", "Naser Khader", "Nick Hækkerup",
"Niels Christian Nielsen", "Niels Helveg Petersen", "Niels Sindal",
"Ole Hækkerup", "Ole Sohn", "Ole Vagn Christensen", "Per Ørum Jørgensen",
"Per Bisgaard", "Per Clausen", "Per Husted", "Per Stig Møller",
"Pernille Frahm", "Pernille Vigsø Bagge", "Peter Christensen",
"Peter Juel Jensen", "Peter Skaarup", "Pia Adelsteen", "Pia Christmas-Møller",
"Pia Kjærsgaard", "Pia Olsen Dyhr", "Poul Andersen", "Preben Rudiengaard",
"Rasmus Prehn", "René Christensen", "René Skau Björnsson",
"Søren Espersen", "Søren Gade", "Søren Krarup", "Søren Pind",
"Simon Emil Ammitzbøll", "Sophie Hæstorp Andersen", "Sophie Løhde",
"Steen Gade", "Svend Auken", "Thomas Adelskov", "Thomas Jensen",
"Thor Pedersen", "Tina Nedergaard", "Tina Petersen", "Tom Behnke",
"Torben Hansen", "Torsten Schack Pedersen", "Trine Mach", "Troels Christensen",
"Troels Lund Poulsen", "Ulla Tørnæs", "Villum Christensen",
"Villy Søvndal", "Vivi Kier", "Yildiz Akdogan"), class = "factor"),
V2 = structure(c(5L, 1L, 1L, 8L, 8L, 7L, 13L, 8L, 4L, 7L,
1L, 6L, 13L, 13L, 13L, 7L, 4L, 13L, 4L, 7L, 4L, 7L, 13L,
1L, 4L, 1L, 10L, 8L, 13L, 13L, 13L, 13L, 8L, 13L, 13L, 7L,
2L, 13L, 8L, 13L, 13L, 1L, 4L, 13L, 4L, 7L, 4L, 1L, 7L, 13L,
7L, 8L, 11L, 1L, 13L, 13L, 4L, 7L, 13L, 7L, 13L, 7L, 1L,
8L, 2L, 7L, 6L, 8L, 3L, 7L, 6L, 1L, 8L, 13L, 7L, 7L, 13L,
1L, 8L, 8L, 13L, 13L, 13L, 1L, 7L, 7L, 7L, 4L, 8L, 13L, 13L,
1L, 4L, 13L, 13L, 9L, 7L, 4L, 7L, 7L, 2L, 7L, 1L, 6L, 7L,
13L, 7L, 13L, 6L, 6L, 13L, 1L, 1L, 8L, 7L, 7L, 13L, 4L, 1L,
7L, 7L, 7L, 6L, 1L, 6L, 8L, 4L, 7L, 7L, 6L, 7L, 7L, 8L, 7L,
13L, 2L, 7L, 4L, 4L, 8L, 8L, 13L, 13L, 1L, 1L, 12L, 1L, 8L,
7L, 13L, 7L, 1L, 7L, 12L, 7L, 13L, 8L, 7L, 1L, 13L, 1L, 13L,
7L, 7L, 13L, 13L, 1L, 4L, 7L, 13L, 8L, 13L, 13L, 13L, 5L,
8L, 4L, 7L, 8L), .Label = c("DF", "EL", "IA", "KF", "LA",
"RV", "S", "SF", "SIU", "SP", "TF", "UFG", "V"), class = "factor"),
V3 = structure(c(3L, 1L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 3L,
1L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 2L,
1L, 2L, 3L, 2L, 2L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L,
3L, 1L, 3L, 3L, 3L, 2L, 2L, 1L, 2L, 3L, 2L, 3L, 2L, 1L, 2L,
3L, 3L, 3L, 3L, 3L, 2L, 3L, 1L, 3L, 2L, 2L, 2L, 3L, 2L, 3L,
2L, 1L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 2L, 3L, 1L, 2L,
3L, 3L, 2L, 2L, 3L, 3L, 1L, 3L, 3L, 2L, 2L, 3L, 2L, 3L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 1L, 1L, 3L, 2L,
2L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 2L, 3L,
2L, 2L, 2L, 2L, 2L, 3L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 1L,
2L, 2L, 3L, 2L, 3L, 3L, 1L, 2L, 3L, 3L, 3L, 3L, 3L, 1L, 2L,
1L, 2L, 3L, 3L, 3L, 2L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L,
2L, 3L, 3L, 2L), .Label = c("For", "Fraværende", "Imod"), class = "factor")), .Names = c("V1",
"V2", "V3"), class = "data.frame", row.names = c(NA, -179L))
投票3:
structure(list(V1 = structure(c(2L, 3L, 4L, 7L, 8L, 5L, 6L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,
36L, 37L, 38L, 39L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 54L, 40L, 55L, 56L, 59L, 60L, 61L, 62L, 63L,
64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 57L, 58L, 74L,
75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L,
88L, 89L, 90L, 91L, 92L, 93L, 95L, 96L, 97L, 94L, 98L, 99L, 100L,
101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L,
112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L, 121L, 122L,
124L, 125L, 126L, 123L, 127L, 128L, 129L, 130L, 131L, 132L, 133L,
134L, 135L, 137L, 138L, 139L, 140L, 136L, 141L, 142L, 143L, 144L,
145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L, 159L,
160L, 161L, 162L, 163L, 155L, 156L, 157L, 158L, 164L, 165L, 166L,
167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L,
178L, 179L, 1L), .Label = c("Özlem Sara Cekic", "Anders Samuelsen",
"Anita Christensen", "Anita Knakkergaard", "Anne-Marie Meldgaard",
"Anne-Mette Winther Christians", "Anne Baastrup", "Anne Grete Holmsgaard",
"Annette Lilja Vilhelmsen", "Bendt Bendtsen", "Benny Engelbrecht",
"Bent Bøgsted", "Bente Dahl", "Bertel Haarder", "Birgitte Josefsen",
"Birthe Rønn Hornbech", "Bjarne Laustsen", "Brian Mikkelsen",
"Britta Schall Holberg", "Carina Christensen", "Carsten Hansen",
"Charlotte Dyremose", "Christine Antorini", "Claus Hjort Frederiksen",
"Colette L. Brix", "Connie Hedegaard", "Dennis Flydtkjær", "Edmund Joensen",
"Eigil Andersen", "Ellen Trane Nørby", "Erling Bonnesen", "Eva Kjer Hansen",
"Eyvind Vesselbo", "Flemming Bonne", "Flemming Damgaard Larsen",
"Flemming Møller", "Flemming Møller Mortensen", "Frank Aaen",
"Gitte Lillelund Bech", "Høgni Hoydal", "Hanne Agersnap", "Hans Christian Schmidt",
"Hans Christian Thoning", "Hans Kristian Skibby", "Helge Adam Møller",
"Helge Sander", "Helle Sjelle", "Helle Thorning-Schmidt", "Henriette Kjær",
"Henrik Brodersen", "Henrik Dam Kristensen", "Henrik Høegh",
"Henrik Sass Larsen", "Holger K. Nielsen", "Ib Poulsen", "Inger Støjberg",
"Jørgen Poulsen", "Jørn Dohrmann", "Jacob Jensen", "Jakob Axel Nielsen",
"Jens Christian Lund", "Jens Kirk", "Jens Peter Vernersen", "Jens Vibjerg",
"Jeppe Kofod", "Jesper Langballe", "Jesper Petersen", "Johanne Schmidt-Nielsen",
"John Dyrby Paulsen", "Johs. Poulsen", "Jonas Dahl", "Juliane Henningsen",
"Julie Rademacher", "Kamal Qureshi", "Karen Ellemann", "Karen Hækkerup",
"Karen J. Klint", "Karen Jespersen", "Karin Nødgaard", "Karina Lorentzen Dehnhardt",
"Karl H. Bornhøft", "Karsten Lauritzen", "Karsten Nonbo", "Kim Andersen",
"Kim Christiansen", "Kim Mortensen", "Kirsten Brosbøl", "Klaus Hækkerup",
"Knud Kristensen", "Kristen Touborg", "Kristian Jensen", "Kristian Pihl Lorentzen",
"Kristian Thulesen Dahl", "Lars-Emil Johansen", "Lars Barfoed",
"Lars Christian Lilleholt", "Lars Løkke Rasmussen", "Leif Lahn Jensen",
"Lene Espersen", "Lene Hansen", "Lennart Damsbo-Andersen", "Line Barfod",
"Lise von Seelen", "Liselott Blixt", "Lone Dybkjær", "Lone Møller",
"Louise Schack Elholm", "Magnus Heunicke", "Malou Aamund", "Margrethe Vestager",
"Marianne Jelved", "Marion Pedersen", "Marlene Harpsøe", "Martin Henriksen",
"Meta Fuglsang", "Mette Frederiksen", "Mette Gjerskov", "Michael Aastrup Jensen",
"Mike Legarth", "Mikkel Dencker", "Mogens Jensen", "Mogens Lykketoft",
"Morten Østergaard", "Morten Bødskov", "Morten Helveg Petersen",
"Morten Messerschmidt", "Nanna Westerby", "Naser Khader", "Nick Hækkerup",
"Niels Christian Nielsen", "Niels Helveg Petersen", "Niels Sindal",
"Ole Hækkerup", "Ole Sohn", "Ole Vagn Christensen", "Per Ørum Jørgensen",
"Per Bisgaard", "Per Clausen", "Per Husted", "Per Stig Møller",
"Pernille Frahm", "Pernille Vigsø Bagge", "Peter Christensen",
"Peter Juel Jensen", "Peter Skaarup", "Pia Adelsteen", "Pia Christmas-Møller",
"Pia Kjærsgaard", "Pia Olsen Dyhr", "Poul Andersen", "Preben Rudiengaard",
"Rasmus Prehn", "René Christensen", "René Skau Björnsson",
"Søren Espersen", "Søren Gade", "Søren Krarup", "Søren Pind",
"Simon Emil Ammitzbøll", "Sophie Hæstorp Andersen", "Sophie Løhde",
"Steen Gade", "Svend Auken", "Thomas Adelskov", "Thomas Jensen",
"Thor Pedersen", "Tina Nedergaard", "Tina Petersen", "Tom Behnke",
"Torben Hansen", "Torsten Schack Pedersen", "Trine Mach", "Troels Christensen",
"Troels Lund Poulsen", "Ulla Tørnæs", "Villum Christensen",
"Villy Søvndal", "Vivi Kier", "Yildiz Akdogan"), class = "factor"),
V2 = structure(c(5L, 1L, 1L, 8L, 8L, 7L, 13L, 8L, 4L, 7L,
1L, 6L, 13L, 13L, 13L, 7L, 4L, 13L, 4L, 7L, 4L, 7L, 13L,
1L, 4L, 1L, 10L, 8L, 13L, 13L, 13L, 13L, 8L, 13L, 13L, 7L,
2L, 13L, 8L, 13L, 13L, 1L, 4L, 13L, 4L, 7L, 4L, 1L, 7L, 13L,
7L, 8L, 11L, 1L, 13L, 13L, 4L, 7L, 13L, 7L, 13L, 7L, 1L,
8L, 2L, 7L, 6L, 8L, 3L, 7L, 6L, 1L, 8L, 13L, 7L, 7L, 13L,
1L, 8L, 8L, 13L, 13L, 13L, 1L, 7L, 7L, 7L, 4L, 8L, 13L, 13L,
1L, 4L, 13L, 13L, 9L, 7L, 4L, 7L, 7L, 2L, 7L, 1L, 6L, 7L,
13L, 7L, 13L, 6L, 6L, 13L, 1L, 1L, 8L, 7L, 7L, 13L, 4L, 1L,
7L, 7L, 7L, 6L, 1L, 6L, 8L, 4L, 7L, 7L, 6L, 7L, 7L, 8L, 7L,
13L, 2L, 7L, 4L, 4L, 8L, 8L, 13L, 13L, 1L, 1L, 12L, 1L, 8L,
7L, 13L, 7L, 1L, 7L, 12L, 7L, 13L, 8L, 7L, 1L, 13L, 1L, 13L,
7L, 7L, 13L, 13L, 1L, 4L, 7L, 13L, 8L, 13L, 13L, 13L, 5L,
8L, 4L, 7L, 8L), .Label = c("DF", "EL", "IA", "KF", "LA",
"RV", "S", "SF", "SIU", "SP", "TF", "UFG", "V"), class = "factor"),
V3 = structure(c(3L, 3L, 3L, 2L, 2L, 1L, 2L, 2L, 2L, 1L,
3L, 2L, 3L, 3L, 2L, 1L, 3L, 3L, 3L, 2L, 2L, 1L, 2L, 2L, 2L,
3L, 2L, 3L, 2L, 2L, 2L, 3L, 2L, 3L, 3L, 1L, 3L, 3L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L,
3L, 2L, 1L, 3L, 1L, 2L, 1L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 1L,
2L, 3L, 3L, 2L, 1L, 2L, 3L, 2L, 1L, 2L, 3L, 2L, 3L, 3L, 2L,
1L, 1L, 2L, 2L, 3L, 3L, 2L, 3L, 3L, 2L, 2L, 1L, 2L, 1L, 2L,
2L, 2L, 2L, 2L, 1L, 3L, 1L, 3L, 1L, 2L, 2L, 3L, 3L, 3L, 2L,
1L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 1L, 2L, 1L,
2L, 1L, 2L, 2L, 2L, 3L, 1L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 3L,
2L, 2L, 3L, 2L, 3L, 1L, 3L, 2L, 2L, 1L, 3L, 3L, 2L, 2L, 2L,
3L, 2L, 1L, 1L, 3L, 2L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 2L, 2L,
2L, 3L, 1L, 2L), .Label = c("For", "Fraværende", "Imod"), class = "factor")), .Names = c("V1",
"V2", "V3"), class = "data.frame", row.names = c(NA, -179L))
I have data on a all of the votes in the Danish Parliament in 2008-9. The problem is that each vote is recorded in its own .txt file with the following format (see the appendix of the post for a dump of three votes from R):
Name Party Vote
Anders Samuelsen LA For
Rasmus Prehn S Imod
... ... ...
I would like to merge all the file to one data frame with the following format:
Name Party Vote1 Vote2 Vote3
Anders Samuelsen LA For Imod Imod
Rasmus Prehn S Imod For Fraværende
(Danish translation:For = yes, imod = no, Fraværende = absent)
In total I have more than 200 files, so the question is: how can I write a loop that merges all the data frames into the desired structure above?
Appendix:
Vote1:
structure(list(V1 = structure(c(2L, 3L, 4L, 7L, 8L, 5L, 6L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,
36L, 37L, 38L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 39L, 54L, 55L, 56L, 60L, 61L, 62L, 63L, 64L,
65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 57L, 58L, 59L,
75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L,
88L, 89L, 90L, 91L, 92L, 93L, 94L, 96L, 97L, 98L, 95L, 99L, 100L,
101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L,
112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L, 121L, 122L,
123L, 125L, 126L, 127L, 124L, 128L, 129L, 130L, 131L, 132L, 133L,
134L, 135L, 136L, 137L, 139L, 140L, 141L, 138L, 142L, 143L, 144L,
145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L, 155L,
160L, 161L, 162L, 163L, 164L, 156L, 157L, 158L, 159L, 165L, 166L,
167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L,
178L, 179L, 1L), .Label = c("Özlem Sara Cekic", "Anders Samuelsen",
"Anita Christensen", "Anita Knakkergaard", "Anne-Marie Meldgaard",
"Anne-Mette Winther Christians", "Anne Baastrup", "Anne Grete Holmsgaard",
"Annette Lilja Vilhelmsen", "Benny Engelbrecht", "Bent Bøgsted",
"Bente Dahl", "Bertel Haarder", "Birgitte Josefsen", "Birthe Rønn Hornbech",
"Bjarne Laustsen", "Brian Mikkelsen", "Britta Schall Holberg",
"Carina Christensen", "Carsten Hansen", "Charlotte Dyremose",
"Christine Antorini", "Claus Hjort Frederiksen", "Colette L. Brix",
"Connie Hedegaard", "Dennis Flydtkjær", "Edmund Joensen", "Eigil Andersen",
"Ellen Trane Nørby", "Erling Bonnesen", "Eva Kjer Hansen", "Eyvind Vesselbo",
"Flemming Bonne", "Flemming Damgaard Larsen", "Flemming Møller",
"Flemming Møller Mortensen", "Frank Aaen", "Gitte Lillelund Bech",
"Høgni Hoydal", "Hanne Agersnap", "Hans Christian Schmidt",
"Hans Christian Thoning", "Hans Kristian Skibby", "Helge Adam Møller",
"Helge Sander", "Helle Sjelle", "Helle Thorning-Schmidt", "Henriette Kjær",
"Henrik Brodersen", "Henrik Dam Kristensen", "Henrik Høegh",
"Henrik Sass Larsen", "Holger K. Nielsen", "Ib Poulsen", "Ida Auken",
"Inger Støjberg", "Jørgen Poulsen", "Jørgen S. Lundsgaard",
"Jørn Dohrmann", "Jacob Jensen", "Jakob Axel Nielsen", "Jens Christian Lund",
"Jens Kirk", "Jens Peter Vernersen", "Jens Vibjerg", "Jeppe Kofod",
"Jesper Langballe", "Jesper Petersen", "Johanne Schmidt-Nielsen",
"John Dyrby Paulsen", "Johs. Poulsen", "Jonas Dahl", "Juliane Henningsen",
"Julie Rademacher", "Kamal Qureshi", "Karen Ellemann", "Karen Hækkerup",
"Karen J. Klint", "Karen Jespersen", "Karin Nødgaard", "Karina Lorentzen Dehnhardt",
"Karl H. Bornhøft", "Karsten Lauritzen", "Karsten Nonbo", "Kim Andersen",
"Kim Christiansen", "Kim Mortensen", "Kirsten Brosbøl", "Klaus Hækkerup",
"Knud Kristensen", "Kristen Touborg", "Kristian Jensen", "Kristian Pihl Lorentzen",
"Kristian Thulesen Dahl", "Lars-Emil Johansen", "Lars Barfoed",
"Lars Christian Lilleholt", "Lars Løkke Rasmussen", "Leif Lahn Jensen",
"Lene Espersen", "Lene Hansen", "Lennart Damsbo-Andersen", "Line Barfod",
"Lise von Seelen", "Liselott Blixt", "Lone Dybkjær", "Lone Møller",
"Louise Schack Elholm", "Magnus Heunicke", "Malou Aamund", "Margrethe Vestager",
"Marianne Jelved", "Marion Pedersen", "Marlene Harpsøe", "Martin Henriksen",
"Meta Fuglsang", "Mette Frederiksen", "Mette Gjerskov", "Michael Aastrup Jensen",
"Mike Legarth", "Mikkel Dencker", "Mogens Jensen", "Mogens Lykketoft",
"Morten Østergaard", "Morten Bødskov", "Morten Helveg Petersen",
"Morten Messerschmidt", "Nanna Westerby", "Naser Khader", "Nick Hækkerup",
"Niels Christian Nielsen", "Niels Helveg Petersen", "Niels Sindal",
"Ole Hækkerup", "Ole Sohn", "Ole Vagn Christensen", "Orla Hav",
"Per Ørum Jørgensen", "Per Bisgaard", "Per Clausen", "Per Stig Møller",
"Pernille Frahm", "Pernille Vigsø Bagge", "Peter Christensen",
"Peter Juel Jensen", "Peter Skaarup", "Pia Adelsteen", "Pia Christmas-Møller",
"Pia Kjærsgaard", "Pia Olsen Dyhr", "Poul Andersen", "Preben Rudiengaard",
"Rasmus Prehn", "René Christensen", "René Skau Björnsson",
"Søren Espersen", "Søren Gade", "Søren Krarup", "Søren Pind",
"Simon Emil Ammitzbøll", "Sophie Hæstorp Andersen", "Sophie Løhde",
"Steen Gade", "Svend Auken", "Thomas Adelskov", "Thomas Jensen",
"Thor Pedersen", "Tina Nedergaard", "Tina Petersen", "Tom Behnke",
"Torben Hansen", "Torsten Schack Pedersen", "Troels Christensen",
"Troels Lund Poulsen", "Ulla Tørnæs", "Villum Christensen",
"Villy Søvndal", "Vivi Kier", "Yildiz Akdogan"), class = "factor"),
V2 = structure(c(5L, 1L, 1L, 8L, 8L, 7L, 13L, 8L, 7L, 1L,
6L, 13L, 13L, 13L, 7L, 4L, 13L, 4L, 7L, 4L, 7L, 13L, 1L,
4L, 1L, 10L, 8L, 13L, 13L, 13L, 13L, 8L, 13L, 13L, 7L, 2L,
13L, 8L, 13L, 13L, 1L, 4L, 13L, 4L, 7L, 4L, 1L, 7L, 13L,
7L, 8L, 11L, 1L, 8L, 13L, 13L, 4L, 7L, 13L, 7L, 13L, 7L,
1L, 8L, 2L, 7L, 6L, 8L, 3L, 7L, 6L, 4L, 1L, 8L, 13L, 7L,
7L, 13L, 1L, 8L, 8L, 13L, 13L, 13L, 1L, 7L, 7L, 7L, 4L, 8L,
13L, 13L, 1L, 4L, 13L, 13L, 9L, 7L, 4L, 7L, 7L, 2L, 7L, 1L,
6L, 7L, 13L, 7L, 13L, 6L, 6L, 13L, 1L, 1L, 8L, 7L, 7L, 13L,
4L, 1L, 7L, 7L, 7L, 6L, 1L, 6L, 8L, 4L, 7L, 7L, 6L, 7L, 7L,
8L, 7L, 7L, 13L, 2L, 4L, 4L, 8L, 8L, 13L, 13L, 1L, 1L, 12L,
1L, 8L, 7L, 13L, 7L, 1L, 7L, 12L, 7L, 13L, 8L, 7L, 1L, 13L,
1L, 13L, 7L, 7L, 13L, 13L, 1L, 4L, 7L, 13L, 13L, 13L, 13L,
5L, 8L, 4L, 7L, 8L), .Label = c("DF", "EL", "IA", "KF", "LA",
"RV", "S", "SF", "SIU", "SP", "TF", "UFG", "V"), class = "factor"),
V3 = structure(c(1L, 1L, 1L, 3L, 3L, 2L, 1L, 3L, 3L, 1L,
3L, 1L, 1L, 2L, 3L, 1L, 1L, 2L, 2L, 1L, 3L, 2L, 2L, 2L, 1L,
2L, 3L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 3L, 2L, 1L, 3L, 2L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 3L, 1L, 2L, 2L, 2L, 1L, 2L, 2L,
1L, 1L, 3L, 1L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 2L, 3L,
2L, 1L, 2L, 2L, 2L, 3L, 2L, 1L, 1L, 3L, 3L, 2L, 1L, 1L, 2L,
3L, 2L, 3L, 2L, 3L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 3L, 2L, 3L,
3L, 3L, 3L, 1L, 3L, 3L, 1L, 3L, 2L, 2L, 3L, 1L, 1L, 1L, 3L,
3L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 1L, 3L, 3L,
3L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 1L, 2L,
1L, 2L, 2L, 2L, 3L, 1L, 3L, 1L, 2L, 1L, 3L, 1L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 3L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 2L,
2L, 1L, 3L, 2L), .Label = c("For", "Fraværende", "Imod"), class = "factor")), .Names = c("V1",
"V2", "V3"), class = "data.frame", row.names = c(NA, -179L))
Vote2:
structure(list(V1 = structure(c(2L, 3L, 4L, 7L, 8L, 5L, 6L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,
36L, 37L, 38L, 39L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 54L, 40L, 55L, 56L, 59L, 60L, 61L, 62L, 63L,
64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 57L, 58L, 74L,
75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L,
88L, 89L, 90L, 91L, 92L, 93L, 95L, 96L, 97L, 94L, 98L, 99L, 100L,
101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L,
112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L, 121L, 122L,
124L, 125L, 126L, 123L, 127L, 128L, 129L, 130L, 131L, 132L, 133L,
134L, 135L, 137L, 138L, 139L, 140L, 136L, 141L, 142L, 143L, 144L,
145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L, 159L,
160L, 161L, 162L, 163L, 155L, 156L, 157L, 158L, 164L, 165L, 166L,
167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L,
178L, 179L, 1L), .Label = c("Özlem Sara Cekic", "Anders Samuelsen",
"Anita Christensen", "Anita Knakkergaard", "Anne-Marie Meldgaard",
"Anne-Mette Winther Christians", "Anne Baastrup", "Anne Grete Holmsgaard",
"Annette Lilja Vilhelmsen", "Bendt Bendtsen", "Benny Engelbrecht",
"Bent Bøgsted", "Bente Dahl", "Bertel Haarder", "Birgitte Josefsen",
"Birthe Rønn Hornbech", "Bjarne Laustsen", "Brian Mikkelsen",
"Britta Schall Holberg", "Carina Christensen", "Carsten Hansen",
"Charlotte Dyremose", "Christine Antorini", "Claus Hjort Frederiksen",
"Colette L. Brix", "Connie Hedegaard", "Dennis Flydtkjær", "Edmund Joensen",
"Eigil Andersen", "Ellen Trane Nørby", "Erling Bonnesen", "Eva Kjer Hansen",
"Eyvind Vesselbo", "Flemming Bonne", "Flemming Damgaard Larsen",
"Flemming Møller", "Flemming Møller Mortensen", "Frank Aaen",
"Gitte Lillelund Bech", "Høgni Hoydal", "Hanne Agersnap", "Hans Christian Schmidt",
"Hans Christian Thoning", "Hans Kristian Skibby", "Helge Adam Møller",
"Helge Sander", "Helle Sjelle", "Helle Thorning-Schmidt", "Henriette Kjær",
"Henrik Brodersen", "Henrik Dam Kristensen", "Henrik Høegh",
"Henrik Sass Larsen", "Holger K. Nielsen", "Ib Poulsen", "Inger Støjberg",
"Jørgen Poulsen", "Jørn Dohrmann", "Jacob Jensen", "Jakob Axel Nielsen",
"Jens Christian Lund", "Jens Kirk", "Jens Peter Vernersen", "Jens Vibjerg",
"Jeppe Kofod", "Jesper Langballe", "Jesper Petersen", "Johanne Schmidt-Nielsen",
"John Dyrby Paulsen", "Johs. Poulsen", "Jonas Dahl", "Juliane Henningsen",
"Julie Rademacher", "Kamal Qureshi", "Karen Ellemann", "Karen Hækkerup",
"Karen J. Klint", "Karen Jespersen", "Karin Nødgaard", "Karina Lorentzen Dehnhardt",
"Karl H. Bornhøft", "Karsten Lauritzen", "Karsten Nonbo", "Kim Andersen",
"Kim Christiansen", "Kim Mortensen", "Kirsten Brosbøl", "Klaus Hækkerup",
"Knud Kristensen", "Kristen Touborg", "Kristian Jensen", "Kristian Pihl Lorentzen",
"Kristian Thulesen Dahl", "Lars-Emil Johansen", "Lars Barfoed",
"Lars Christian Lilleholt", "Lars Løkke Rasmussen", "Leif Lahn Jensen",
"Lene Espersen", "Lene Hansen", "Lennart Damsbo-Andersen", "Line Barfod",
"Lise von Seelen", "Liselott Blixt", "Lone Dybkjær", "Lone Møller",
"Louise Schack Elholm", "Magnus Heunicke", "Malou Aamund", "Margrethe Vestager",
"Marianne Jelved", "Marion Pedersen", "Marlene Harpsøe", "Martin Henriksen",
"Meta Fuglsang", "Mette Frederiksen", "Mette Gjerskov", "Michael Aastrup Jensen",
"Mike Legarth", "Mikkel Dencker", "Mogens Jensen", "Mogens Lykketoft",
"Morten Østergaard", "Morten Bødskov", "Morten Helveg Petersen",
"Morten Messerschmidt", "Nanna Westerby", "Naser Khader", "Nick Hækkerup",
"Niels Christian Nielsen", "Niels Helveg Petersen", "Niels Sindal",
"Ole Hækkerup", "Ole Sohn", "Ole Vagn Christensen", "Per Ørum Jørgensen",
"Per Bisgaard", "Per Clausen", "Per Husted", "Per Stig Møller",
"Pernille Frahm", "Pernille Vigsø Bagge", "Peter Christensen",
"Peter Juel Jensen", "Peter Skaarup", "Pia Adelsteen", "Pia Christmas-Møller",
"Pia Kjærsgaard", "Pia Olsen Dyhr", "Poul Andersen", "Preben Rudiengaard",
"Rasmus Prehn", "René Christensen", "René Skau Björnsson",
"Søren Espersen", "Søren Gade", "Søren Krarup", "Søren Pind",
"Simon Emil Ammitzbøll", "Sophie Hæstorp Andersen", "Sophie Løhde",
"Steen Gade", "Svend Auken", "Thomas Adelskov", "Thomas Jensen",
"Thor Pedersen", "Tina Nedergaard", "Tina Petersen", "Tom Behnke",
"Torben Hansen", "Torsten Schack Pedersen", "Trine Mach", "Troels Christensen",
"Troels Lund Poulsen", "Ulla Tørnæs", "Villum Christensen",
"Villy Søvndal", "Vivi Kier", "Yildiz Akdogan"), class = "factor"),
V2 = structure(c(5L, 1L, 1L, 8L, 8L, 7L, 13L, 8L, 4L, 7L,
1L, 6L, 13L, 13L, 13L, 7L, 4L, 13L, 4L, 7L, 4L, 7L, 13L,
1L, 4L, 1L, 10L, 8L, 13L, 13L, 13L, 13L, 8L, 13L, 13L, 7L,
2L, 13L, 8L, 13L, 13L, 1L, 4L, 13L, 4L, 7L, 4L, 1L, 7L, 13L,
7L, 8L, 11L, 1L, 13L, 13L, 4L, 7L, 13L, 7L, 13L, 7L, 1L,
8L, 2L, 7L, 6L, 8L, 3L, 7L, 6L, 1L, 8L, 13L, 7L, 7L, 13L,
1L, 8L, 8L, 13L, 13L, 13L, 1L, 7L, 7L, 7L, 4L, 8L, 13L, 13L,
1L, 4L, 13L, 13L, 9L, 7L, 4L, 7L, 7L, 2L, 7L, 1L, 6L, 7L,
13L, 7L, 13L, 6L, 6L, 13L, 1L, 1L, 8L, 7L, 7L, 13L, 4L, 1L,
7L, 7L, 7L, 6L, 1L, 6L, 8L, 4L, 7L, 7L, 6L, 7L, 7L, 8L, 7L,
13L, 2L, 7L, 4L, 4L, 8L, 8L, 13L, 13L, 1L, 1L, 12L, 1L, 8L,
7L, 13L, 7L, 1L, 7L, 12L, 7L, 13L, 8L, 7L, 1L, 13L, 1L, 13L,
7L, 7L, 13L, 13L, 1L, 4L, 7L, 13L, 8L, 13L, 13L, 13L, 5L,
8L, 4L, 7L, 8L), .Label = c("DF", "EL", "IA", "KF", "LA",
"RV", "S", "SF", "SIU", "SP", "TF", "UFG", "V"), class = "factor"),
V3 = structure(c(3L, 1L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 3L,
1L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 2L,
1L, 2L, 3L, 2L, 2L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L,
3L, 1L, 3L, 3L, 3L, 2L, 2L, 1L, 2L, 3L, 2L, 3L, 2L, 1L, 2L,
3L, 3L, 3L, 3L, 3L, 2L, 3L, 1L, 3L, 2L, 2L, 2L, 3L, 2L, 3L,
2L, 1L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 2L, 3L, 1L, 2L,
3L, 3L, 2L, 2L, 3L, 3L, 1L, 3L, 3L, 2L, 2L, 3L, 2L, 3L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 1L, 1L, 3L, 2L,
2L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 2L, 3L,
2L, 2L, 2L, 2L, 2L, 3L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 1L,
2L, 2L, 3L, 2L, 3L, 3L, 1L, 2L, 3L, 3L, 3L, 3L, 3L, 1L, 2L,
1L, 2L, 3L, 3L, 3L, 2L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L,
2L, 3L, 3L, 2L), .Label = c("For", "Fraværende", "Imod"), class = "factor")), .Names = c("V1",
"V2", "V3"), class = "data.frame", row.names = c(NA, -179L))
Vote3:
structure(list(V1 = structure(c(2L, 3L, 4L, 7L, 8L, 5L, 6L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,
36L, 37L, 38L, 39L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 54L, 40L, 55L, 56L, 59L, 60L, 61L, 62L, 63L,
64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 57L, 58L, 74L,
75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L,
88L, 89L, 90L, 91L, 92L, 93L, 95L, 96L, 97L, 94L, 98L, 99L, 100L,
101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L,
112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L, 121L, 122L,
124L, 125L, 126L, 123L, 127L, 128L, 129L, 130L, 131L, 132L, 133L,
134L, 135L, 137L, 138L, 139L, 140L, 136L, 141L, 142L, 143L, 144L,
145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L, 159L,
160L, 161L, 162L, 163L, 155L, 156L, 157L, 158L, 164L, 165L, 166L,
167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L,
178L, 179L, 1L), .Label = c("Özlem Sara Cekic", "Anders Samuelsen",
"Anita Christensen", "Anita Knakkergaard", "Anne-Marie Meldgaard",
"Anne-Mette Winther Christians", "Anne Baastrup", "Anne Grete Holmsgaard",
"Annette Lilja Vilhelmsen", "Bendt Bendtsen", "Benny Engelbrecht",
"Bent Bøgsted", "Bente Dahl", "Bertel Haarder", "Birgitte Josefsen",
"Birthe Rønn Hornbech", "Bjarne Laustsen", "Brian Mikkelsen",
"Britta Schall Holberg", "Carina Christensen", "Carsten Hansen",
"Charlotte Dyremose", "Christine Antorini", "Claus Hjort Frederiksen",
"Colette L. Brix", "Connie Hedegaard", "Dennis Flydtkjær", "Edmund Joensen",
"Eigil Andersen", "Ellen Trane Nørby", "Erling Bonnesen", "Eva Kjer Hansen",
"Eyvind Vesselbo", "Flemming Bonne", "Flemming Damgaard Larsen",
"Flemming Møller", "Flemming Møller Mortensen", "Frank Aaen",
"Gitte Lillelund Bech", "Høgni Hoydal", "Hanne Agersnap", "Hans Christian Schmidt",
"Hans Christian Thoning", "Hans Kristian Skibby", "Helge Adam Møller",
"Helge Sander", "Helle Sjelle", "Helle Thorning-Schmidt", "Henriette Kjær",
"Henrik Brodersen", "Henrik Dam Kristensen", "Henrik Høegh",
"Henrik Sass Larsen", "Holger K. Nielsen", "Ib Poulsen", "Inger Støjberg",
"Jørgen Poulsen", "Jørn Dohrmann", "Jacob Jensen", "Jakob Axel Nielsen",
"Jens Christian Lund", "Jens Kirk", "Jens Peter Vernersen", "Jens Vibjerg",
"Jeppe Kofod", "Jesper Langballe", "Jesper Petersen", "Johanne Schmidt-Nielsen",
"John Dyrby Paulsen", "Johs. Poulsen", "Jonas Dahl", "Juliane Henningsen",
"Julie Rademacher", "Kamal Qureshi", "Karen Ellemann", "Karen Hækkerup",
"Karen J. Klint", "Karen Jespersen", "Karin Nødgaard", "Karina Lorentzen Dehnhardt",
"Karl H. Bornhøft", "Karsten Lauritzen", "Karsten Nonbo", "Kim Andersen",
"Kim Christiansen", "Kim Mortensen", "Kirsten Brosbøl", "Klaus Hækkerup",
"Knud Kristensen", "Kristen Touborg", "Kristian Jensen", "Kristian Pihl Lorentzen",
"Kristian Thulesen Dahl", "Lars-Emil Johansen", "Lars Barfoed",
"Lars Christian Lilleholt", "Lars Løkke Rasmussen", "Leif Lahn Jensen",
"Lene Espersen", "Lene Hansen", "Lennart Damsbo-Andersen", "Line Barfod",
"Lise von Seelen", "Liselott Blixt", "Lone Dybkjær", "Lone Møller",
"Louise Schack Elholm", "Magnus Heunicke", "Malou Aamund", "Margrethe Vestager",
"Marianne Jelved", "Marion Pedersen", "Marlene Harpsøe", "Martin Henriksen",
"Meta Fuglsang", "Mette Frederiksen", "Mette Gjerskov", "Michael Aastrup Jensen",
"Mike Legarth", "Mikkel Dencker", "Mogens Jensen", "Mogens Lykketoft",
"Morten Østergaard", "Morten Bødskov", "Morten Helveg Petersen",
"Morten Messerschmidt", "Nanna Westerby", "Naser Khader", "Nick Hækkerup",
"Niels Christian Nielsen", "Niels Helveg Petersen", "Niels Sindal",
"Ole Hækkerup", "Ole Sohn", "Ole Vagn Christensen", "Per Ørum Jørgensen",
"Per Bisgaard", "Per Clausen", "Per Husted", "Per Stig Møller",
"Pernille Frahm", "Pernille Vigsø Bagge", "Peter Christensen",
"Peter Juel Jensen", "Peter Skaarup", "Pia Adelsteen", "Pia Christmas-Møller",
"Pia Kjærsgaard", "Pia Olsen Dyhr", "Poul Andersen", "Preben Rudiengaard",
"Rasmus Prehn", "René Christensen", "René Skau Björnsson",
"Søren Espersen", "Søren Gade", "Søren Krarup", "Søren Pind",
"Simon Emil Ammitzbøll", "Sophie Hæstorp Andersen", "Sophie Løhde",
"Steen Gade", "Svend Auken", "Thomas Adelskov", "Thomas Jensen",
"Thor Pedersen", "Tina Nedergaard", "Tina Petersen", "Tom Behnke",
"Torben Hansen", "Torsten Schack Pedersen", "Trine Mach", "Troels Christensen",
"Troels Lund Poulsen", "Ulla Tørnæs", "Villum Christensen",
"Villy Søvndal", "Vivi Kier", "Yildiz Akdogan"), class = "factor"),
V2 = structure(c(5L, 1L, 1L, 8L, 8L, 7L, 13L, 8L, 4L, 7L,
1L, 6L, 13L, 13L, 13L, 7L, 4L, 13L, 4L, 7L, 4L, 7L, 13L,
1L, 4L, 1L, 10L, 8L, 13L, 13L, 13L, 13L, 8L, 13L, 13L, 7L,
2L, 13L, 8L, 13L, 13L, 1L, 4L, 13L, 4L, 7L, 4L, 1L, 7L, 13L,
7L, 8L, 11L, 1L, 13L, 13L, 4L, 7L, 13L, 7L, 13L, 7L, 1L,
8L, 2L, 7L, 6L, 8L, 3L, 7L, 6L, 1L, 8L, 13L, 7L, 7L, 13L,
1L, 8L, 8L, 13L, 13L, 13L, 1L, 7L, 7L, 7L, 4L, 8L, 13L, 13L,
1L, 4L, 13L, 13L, 9L, 7L, 4L, 7L, 7L, 2L, 7L, 1L, 6L, 7L,
13L, 7L, 13L, 6L, 6L, 13L, 1L, 1L, 8L, 7L, 7L, 13L, 4L, 1L,
7L, 7L, 7L, 6L, 1L, 6L, 8L, 4L, 7L, 7L, 6L, 7L, 7L, 8L, 7L,
13L, 2L, 7L, 4L, 4L, 8L, 8L, 13L, 13L, 1L, 1L, 12L, 1L, 8L,
7L, 13L, 7L, 1L, 7L, 12L, 7L, 13L, 8L, 7L, 1L, 13L, 1L, 13L,
7L, 7L, 13L, 13L, 1L, 4L, 7L, 13L, 8L, 13L, 13L, 13L, 5L,
8L, 4L, 7L, 8L), .Label = c("DF", "EL", "IA", "KF", "LA",
"RV", "S", "SF", "SIU", "SP", "TF", "UFG", "V"), class = "factor"),
V3 = structure(c(3L, 3L, 3L, 2L, 2L, 1L, 2L, 2L, 2L, 1L,
3L, 2L, 3L, 3L, 2L, 1L, 3L, 3L, 3L, 2L, 2L, 1L, 2L, 2L, 2L,
3L, 2L, 3L, 2L, 2L, 2L, 3L, 2L, 3L, 3L, 1L, 3L, 3L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 2L,
3L, 2L, 1L, 3L, 1L, 2L, 1L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 1L,
2L, 3L, 3L, 2L, 1L, 2L, 3L, 2L, 1L, 2L, 3L, 2L, 3L, 3L, 2L,
1L, 1L, 2L, 2L, 3L, 3L, 2L, 3L, 3L, 2L, 2L, 1L, 2L, 1L, 2L,
2L, 2L, 2L, 2L, 1L, 3L, 1L, 3L, 1L, 2L, 2L, 3L, 3L, 3L, 2L,
1L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 1L, 2L, 1L,
2L, 1L, 2L, 2L, 2L, 3L, 1L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 3L,
2L, 2L, 3L, 2L, 3L, 1L, 3L, 2L, 2L, 1L, 3L, 3L, 2L, 2L, 2L,
3L, 2L, 1L, 1L, 3L, 2L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 2L, 2L,
2L, 3L, 1L, 2L), .Label = c("For", "Fraværende", "Imod"), class = "factor")), .Names = c("V1",
"V2", "V3"), class = "data.frame", row.names = c(NA, -179L))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是使用 hadley 的 plyr 和 reshape 包的稍微不同的方法。
here is a slightly different approach using plyr and reshape packages by hadley.
这就是我处理多个导入的方式。我希望我的例子能够满足您的需求。
您要做的就是读取目录中的所有文件名,将每个文件作为列表元素导入,并将整个列表
rbind
到一个data.frame中。我假设您的文件以voting_results_*
开头。This is how I handle multiple imports. I hope my example suits your needs.
What you do is you read all the filenames in the directory, import each file as a list element and
rbind
the whole list into one data.frame. I assume your files begin withvoting_results_*
.如果您假设 Party 始终相同,则只需按名称合并(两次)(==结构中的“V1”):
我希望 SO Interface 可以轻松指定非比例字体,例如 Courier。当粘贴到文本部分时,它似乎占用了 R 提供的用于排列表格输出的间距。
If you assume that Party is always the same, then just merge (twice) by the Names (== "V1" in your structures):
I wish the SO Interface made it easy to specify non-proportional fonts such as Courier. It seems to be eating the spacing that R offers to line up tabular output when pasted into text sections.
将 read.csv 调整为您要拉入的任何类型的文件。此示例假定文件的命名法如下:
Vote1.csv
投票2.csv
...
投票200.csv
Adjust read.csv to whatever type of file it is that you're pulling in. This example assumes that the nomenclature of the files follows:
Vote1.csv
Vote2.csv
...
Vote200.csv