我想要一个SO问题的最小可重现代码。我一直在使用dput(droplevels(head(df,50)))
。但是,df
大约有4k条记录,看起来dput
正在为每条记录打印一些内容。我需要在问题中显示两个不同的df,并且SO不会让我超过30,000个字符。
例如:
na.action = structure(c(1L, 2L, 3L, 4L, 5L, 6L...
dput
每行打印一个,当不超过50时。还有.Names
打印所有行名称(?)。
如何让dput
更简洁?
注意我已尝试droplevels
dput(droplevels(head(df,50)))
的输出:
structure(list(Date = structure(c(13248, 13253, 13253, 13251, 13254, 13251, 13254, 13249, 13252, 13251, 13253, 13251, 13253, 13253, 13250, 13252, 13249, 13254, 13254, 13252, 13250, 13254, 13250, 13252, 13249, 13251, 13249, 13250, 13250, 13251, 13250, 13254, 13252, 13250, 13253, 13252, 13251, 13248, 13253, 13249, 13251, 13248, 13248, 13251, 13253, 13251, 13250, 13248, 13249, 13248), class = "Date"), Day = c(2L, 7L, 7L, 5L, 1L, 5L, 1L, 3L, 6L, 5L, 7L, 5L, 7L, 7L, 4L, 6L, 3L, 1L, 1L, 6L, 4L, 1L, 4L, 6L, 3L, 5L, 3L, 4L, 4L, 5L, 4L, 1L, 6L, 4L, 7L, 6L, 5L, 2L, 7L, 3L, 5L, 2L, 2L, 5L, 7L, 5L, 4L, 2L, 3L, 2L), Hour = c(14L, 8L, 10L, 13L, 12L, 15L, 15L, 17L, 12L, 10L, 15L, 16L, 17L, 13L, 20L, 19L, 16L, 8L, 13L, 8L, 18L, 10L, 20L, 13L, 17L, 11L, 15L, 10L, 12L, 15L, 17L, 18L, 15L, 16L, 14L, 21L, 17L, 17L, 16L, 21L, 15L, 15L, 19L, 12L, 18L, 17L, 8L, 18L, 20L, 13L), Quantity = c(28L, 26L, 16L, 6L, 4L, 8L, 6L, 9L, 7L, 13L, 21L, 16L, 18L, 11L, 21L, 54L, 32L, 22L, 15L, 6L, 17L, 3L, 10L, 4L, 14L, 11L, 9L, 9L, 14L, 8L, 10L, 10L, 15L, 10L, 10L, 4L, 32L, 6L, 27L, 3L, 18L, 14L, 21L, 5L, 32L, 43L, 11L, 10L, 23L, 16L), Spend = c(38.83, 35.71, 18.09, 12.09, 7.94, 18.13, 7.27, 7.74, 11.71, 9.13, 22.62, 24.52, 44.74, 16.05, 32.09, 73.63, 39.28, 22.93, 21.02, 8.09, 21.99, 9.06, 9.54, 12.22, 20.48, 12.45, 8.79, 12.75, 15.32, 10.47, 12.21, 14.61, 21.56, 16.22, 11.7, 16.92, 34.56, 11.19, 40.22, 7.96, 13.99, 16.38, 30.83, 12.47, 45.66, 37.53, 9.15, 15.18, 33.8, 24.19), C_ID = c("CUST0000001392", "CUST0000001962", "CUST0000003190", "CUST0000003347", "CUST0000003447", "CUST0000004239", "CUST0000004239", "CUST0000006445", "CUST0000009422", "CUST0000009737", "CUST0000010288", "CUST0000010921", "CUST0000011647", "CUST0000011873", "CUST0000013075", "CUST0000016087", "CUST0000016376", "CUST0000019017", "CUST0000022814", "CUST0000023618", "CUST0000025448", "CUST0000026547", "CUST0000027294", "CUST0000027873", "CUST0000027873", "CUST0000027873", "CUST0000028077", "CUST0000029009", "CUST0000029009", "CUST0000029587", "CUST0000029587", "CUST0000029587", "CUST0000030585", "CUST0000031428", "CUST0000032813", "CUST0000032813", "CUST0000033304", "CUST0000033395", "CUST0000035935", "CUST0000038162", "CUST0000038793", "CUST0000040366", "CUST0000041637", "CUST0000041792", "CUST0000041792", "CUST0000043076", "CUST0000044856", "CUST0000046348", "CUST0000046348", "CUST0000047548"), C_Sensitivity = c("LA", "MM", "UM", "MM", "MM", "LA", "LA", "UM", "UM", "MM", "MM", "MM", "UM", "UM", "UM", "UM", "UM", "XX", "UM", "MM", "MM", "LA", "XX", "UM", "UM", "UM", "UM", "LA", "LA", "UM", "UM", "UM", "LA", "MM", "UM", "UM", "MM", "MM", "MM", "MM", "LA", "LA", "MM", "MM", "MM", "MM", "LA", "UM", "UM", "UM"), C_Lifestage = c("OT", "OT", "OA", "OA", "OT", "OT", "OT", "YA", "PE", "OA", "OT", "YA", "YF", "OT", "YF", "OF", "OT", "OT", "OT", "YA", "YF", "OT", "OF", "PE", "PE", "PE", "OT", "YA", "YA", "YA", "YA", "YA", "OT", "YA", "OT", "OT", "OA", "OT", "OT", "YA", "YA", "YA", "YA", "OF", "OF", "OT", "OA", "YF", "YF", "YA"), B_ID = c(994100100153442, 994100100153740, 994100100154465, 994100100154551, 994100100154610, 994100100155062, 994100100155064, 994100100156481, 994100100158309, 994100100158496, 994100100158831, 994100100159200, 994100100159652, 994100100159814, 994100100160597, 994100100162377, 994100100162557, 994100100164185, 994100100166444, 994100100166936, 994100100168008, 994100100168734, 994100100169197, 994100100169576, 994100100169578, 994100100169579, 994100100169665, 994100100170188, 994100100170189, 994100100170554, 994100100170557, 994100100170559, 994100100171157, 994100100171727, 994100100172528, 994100100172529, 994100100172826, 994100100172874, 994100100174388, 994100100175780, 994100100176153, 994100100177137, 994100100177942, 994100100178033, 994100100178034, 994100100178875, 994100100179951, 994100100180832, 994100100180833, 994100100181547), B_Size = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("L", "M"), class = "factor"), B_Sensitivity = structure(c(2L, 2L, 3L, 2L, 1L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 2L, 3L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 2L, 3L, 3L, 2L, 1L, 3L, 3L, 2L, 3L, 2L, 3L, 1L, 1L, 3L, 2L, 3L, 2L, 1L, 3L, 3L, 3L), .Label = c("LA", "MM", "UM"), class = "factor"), B_Type = structure(c(1L, 1L, 1L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 1L, 3L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 2L, 1L, 3L, 1L, 2L, 1L, 3L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 3L), .Label = c("Full Shop", "Small Shop", "Top Up" ), class = "factor"), B_Mission = structure(c(1L, 1L, 3L, 3L, 2L, 1L, 1L, 1L, 1L, 3L, 1L, 3L, 2L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 1L, 1L, 1L, 3L, 1L, 1L, 2L, 3L, 1L, 3L, 1L, 1L, 3L, 1L, 3L, 2L, 3L, 3L, 1L, 3L, 3L, 3L, 1L, 1L, 3L, 1L), .Label = c("Fresh", "Grocery", "Mixed"), class = "factor"), S_Code = structure(c(26L, 14L, 25L, 15L, 29L, 32L, 32L, 6L, 37L, 9L, 41L, 40L, 28L, 30L, 17L, 2L, 22L, 9L, 13L, 11L, 1L, 35L, 5L, 36L, 36L, 36L, 8L, 4L, 4L, 27L, 27L, 27L, 19L, 23L, 3L, 3L, 24L, 10L, 12L, 34L, 20L, 16L, 38L, 31L, 31L, 18L, 39L, 7L, 21L, 33L), .Label = c("00065", "00076", "00432", "00441", "00488", "00496", "00604", "00615", "00648", "00696", "00714", "00894", "00936", "01163", "01232", "01243", "01316", "01375", "01379", "01390", "01419", "01441", "01528", "01567", "01573", "01616", "01672", "01708", "01847", "01892", "01970", "01978", "02003", "02007", "02074", "02163", "02245", "02282", "02603", "02685", "02872"), class = "factor"), S_Format = structure(c(1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 3L, 3L, 3L, 1L, 1L, 2L, 2L, 1L, 4L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 4L, 1L, 4L, 1L, 1L), .Label = c("LS", "MS", "SS", "XLS"), class = "factor"), S_Region = structure(c(5L, 3L, 3L, 2L, 8L, 5L, 5L, 9L, 9L, 2L, 7L, 6L, 2L, 7L, 7L, 5L, 3L, 2L, 4L, 4L, 10L, 6L, 6L, 2L, 2L, 2L, 9L, 4L, 4L, 2L, 2L, 2L, 7L, 10L, 1L, 1L, 1L, 3L, 8L, 2L, 6L, 7L, 6L, 6L, 6L, 2L, 8L, 6L, 4L, 2L), .Label = c("E01", "E02", "E03", "N01", "N02", "N03", "S01", "W01", "W02", "W03" ), class = "factor"), Class = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "H", class = "factor")), .Names = c("Date", "Day", "Hour", "Quantity", "Spend", "C_ID", "C_Sensitivity", "C_Lifestage", "B_ID", "B_Size", "B_Sensitivity", "B_Type", "B_Mission", "S_Code", "S_Format", "S_Region", "Class"), na.action = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 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, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 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, 123L, 124L, 125L, 126L, 127L, 128L, 129L, 130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L, 161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L, 183L, 184L, 185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L, 193L, 194L, 195L, 196L, 197L, 198L, 199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 218L, 219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L, 229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 239L, 240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L, 249L, 250L, 251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 260L, 261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L, 270L, 271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L, 288L, 289L, 290L, 291L, 292L, 293L, 294L, 295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 305L, 306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, 315L, 316L, 317L, 318L, 319L, 320L, 321L, 322L, 323L, 324L, 325L, 326L, 327L, 328L, 329L, 330L, 331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, 341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 349L, 350L, 351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L, 359L, 360L, 361L, 362L, 363L, 364L, 365L, 366L, 367L, 368L, 369L, 370L, 371L, 372L, 373L, 374L, 375L, 376L, 377L, 378L, 379L, 380L, 381L, 382L, 383L, 384L, 385L, 386L, 387L, 388L, 389L, 390L, 391L, 392L, 393L, 394L, 395L, 396L, 397L, 398L, 399L, 400L, 401L, 402L, 403L, 404L, 405L, 406L, 407L, 408L, 409L, 410L, 411L, 412L, 413L, 414L, 415L, 416L, 417L, 418L, 419L, 420L, 421L, 422L, 423L, 424L, 425L, 426L, 427L, 428L, 429L, 430L, 431L, 432L, 433L, 434L, 435L, 436L, 437L, 438L, 439L, 440L, 441L, 442L, 443L, 444L, 445L, 446L, 447L, 448L, 449L, 450L, 451L, 452L, 453L, 454L, 455L, 456L, 457L, 458L, 459L, 460L, 461L, 462L, 463L, 464L, 465L, 466L, 467L, 468L, 469L, 470L, 471L, 472L, 473L, 474L, 475L, 476L, 477L, 478L, 479L, 480L, 481L, 482L, 483L, 484L, 485L, 486L, 487L, 488L, 489L, 490L, 491L, 492L, 493L, 494L, 495L, 496L, 497L, 498L, 499L, 500L, 501L, 502L, 503L, 504L, 505L, 506L, 507L, 508L, 509L, 510L, 511L, 512L, 513L, 514L, 515L, 516L, 517L, 518L, 519L, 520L, 521L, 522L, 523L, 524L, 525L, 526L, 527L, 528L, 529L, 530L, 531L, 532L, 533L, 534L, 535L, 536L, 537L, 538L, 539L, 540L, 541L, 542L, 543L, 544L, 545L, 546L, 547L, 548L, 549L, 550L, 551L, 552L, 553L, 554L, 555L, 556L, 557L, 558L, 559L, 560L, 561L, 562L, 563L, 564L, 565L, 566L, 567L, 568L, 569L, 570L, 571L, 572L, 573L, 574L, 575L, 576L, 577L, 578L, 579L, 580L, 581L, 582L, 583L, 584L, 585L, 586L, 587L, 588L, 589L, 590L, 591L, 592L, 593L, 594L, 595L, 596L, 597L, 598L, 599L, 600L, 601L, 602L, 603L, 604L, 605L, 606L, 607L, 608L, 609L, 610L, 611L, 612L, 613L, 614L, 615L, 616L, 617L, 618L, 619L, 620L, 621L, 622L, 623L, 624L, 625L, 626L, 627L, 628L, 629L, 630L, 631L, 632L, 633L, 634L, 635L, 636L, 637L, 638L, 639L, 640L, 641L, 642L, 643L, 644L, 645L, 646L, 647L, 648L, 649L, 650L, 651L, 652L, 653L, 654L, 655L, 656L, 657L, 658L, 659L, 660L, 661L, 662L, 663L, 664L, 665L, 666L, 667L, 668L, 669L, 670L, 671L, 672L, 673L, 674L, 675L, 676L, 677L, 678L, 679L, 680L, 681L, 682L, 683L, 684L, 685L, 686L, 687L, 688L, 689L, 690L, 691L, 692L, 693L, 694L, 695L, 696L, 697L, 698L, 699L, 700L, 701L, 702L, 703L, 704L, 705L, 706L, 707L, 708L, 709L, 710L, 711L, 712L, 713L, 714L, 715L, 716L, 717L, 718L, 719L, 720L, 721L, 722L, 723L, 724L, 725L, 726L, 727L, 728L, 729L, 730L, 731L, 732L, 733L, 734L, 735L, 736L, 737L, 738L, 739L, 740L, 741L, 742L, 743L, 744L, 745L, 746L, 747L, 748L, 749L, 750L, 751L, 752L, 753L, 754L, 755L, 756L, 757L, 758L, 759L, 760L, 761L, 762L, 763L, 764L, 765L, 766L, 767L, 768L, 769L, 770L, 771L, 772L, 773L, 777L, 778L, 792L, 793L, 794L, 795L, 796L, 797L, 805L, 806L, 807L, 830L, 834L, 863L, 864L, 865L, 876L, 877L, 878L, 879L, 886L, 887L, 891L, 910L, 911L, 921L, 923L, 930L, 939L, 940L, 941L, 942L, 949L, 955L, 964L, 986L, 994L, 995L, 996L, 997L, 1036L, 1037L, 1044L, 1047L, 1055L, 1056L, 1066L, 1067L, 1068L, 1069L, 1070L, 1071L, 1072L, 1091L, 1113L, 1122L, 1123L, 1124L, 1133L, 1141L, 1152L, 1157L, 1158L, 1159L, 1160L, 1171L, 1172L, 1181L, 1213L, 1236L, 1237L, 1238L, 1239L, 1240L, 1241L, 1242L, 1249L, 1273L, 1307L, 1308L, 1309L, 1335L, 1336L, 1353L, 1354L, 1355L, 1356L, 1358L, 1364L, 1374L, 1379L, 1392L, 1393L, 1407L, 1409L, 1410L, 1411L, 1412L, 1413L, 1414L, 1418L, 1419L, 1420L, 1431L, 1450L, 1453L, 1479L, 1480L, 1481L, 1492L, 1493L, 1495L, 1496L, 1497L, 1498L, 1522L, 1538L, 1564L, 1565L, 1566L, 1567L, 1570L, 1571L, 1580L, 1581L, 1582L, 1584L, 1585L, 1593L, 1594L, 1595L, 1614L, 1620L, 1625L, 1626L, 1644L, 1660L, 1679L, 1682L, 1683L, 1684L, 1685L, 1689L, 1690L, 1698L, 1707L, 1713L, 1751L, 1752L, 1760L, 1761L, 1764L, 1765L, 1782L, 1783L, 1794L, 1803L, 1806L, 1807L, 1811L, 1812L, 1813L, 1814L, 1815L, 1816L, 1821L, 1822L, 1849L, 1850L, 1854L, 1865L, 1866L, 1867L, 1868L, 1875L, 1886L, 1895L, 1898L, 1899L, 1902L, 1904L, 1915L, 1916L, 1917L, 1918L, 1920L, 1921L, 1946L, 1947L, 1990L, 1995L, 1996L, 2003L, 2012L, 2013L, 2015L, 2016L, 2017L, 2018L, 2019L, 2068L, 2071L, 2072L, 2121L, 2122L, 2127L, 2142L, 2166L, 2167L, 2168L, 2169L, 2178L, 2179L, 2180L, 2181L, 2182L, 2236L, 2282L, 2283L, 2284L, 2309L, 2310L, 2317L, 2319L, 2334L, 2364L, 2365L, 2366L, 2376L, 2377L, 2384L, 2409L, 2419L, 2435L, 2436L, 2437L, 2438L, 2439L, 2440L, 2445L, 2446L, 2482L, 2502L, 2503L, 2510L, 2511L, 2513L, 2514L, 2515L, 2558L, 2575L, 2576L, 2580L, 2611L, 2612L, 2613L, 2622L, 2623L, 2633L, 2653L, 2659L, 2672L, 2686L, 2687L, 2697L, 2707L, 2708L, 2718L, 2757L, 2758L, 2763L, 2764L, 2777L, 2783L, 2784L, 2791L, 2808L, 2833L, 2834L, 2835L, 2840L, 2862L, 2863L, 2880L, 2881L, 2882L, 2883L, 2884L, 2898L, 2908L, 2948L, 2952L, 2953L, 2969L, 2970L, 2971L, 2972L, 2973L, 2974L, 3028L, 3043L, 3044L, 3045L, 3046L, 3057L, 3058L, 3061L, 3071L, 3072L, 3089L, 3099L, 3129L, 3130L, 3131L, 3132L, 3133L, 3136L, 3144L, 3145L, 3158L, 3175L, 3207L, 3208L, 3209L, 3212L, 3217L, 3218L, 3219L, 3220L, 3221L, 3222L, 3235L, 3236L, 3237L, 3253L, 3254L, 3255L, 3257L, 3272L, 3273L, 3279L, 3291L, 3292L, 3318L, 3319L, 3320L, 3321L, 3380L, 3415L, 3422L, 3423L, 3424L, 3425L, 3426L, 3457L, 3458L, 3474L, 3521L, 3522L, 3523L, 3537L, 3568L, 3569L, 3576L, 3577L, 3578L, 3583L, 3598L, 3599L, 3600L, 3612L, 3613L, 3621L, 3622L, 3632L, 3633L, 3638L, 3639L, 3640L, 3650L, 3669L, 3670L, 3675L, 3676L, 3697L, 3708L, 3712L, 3713L, 3714L, 3732L, 3733L, 3734L, 3735L, 3744L, 3745L, 3767L, 3768L, 3769L, 3783L, 3784L, 3785L), .Names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121", "122", "123", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "140", "141", "142", "143", "144", "145", "146", "147", "148", "149", "150", "151", "152", "153", "154", "155", "156", "157", "158", "159", "160", "161", "162", "163", "164", "165", "166", "167", "168", "169", "170", "171", "172", "173", "174", "175", "176", "177", "178", "179", "180", "181", "182", "183", "184", "185", "186", "187", "188", "189", "190", "191", "192", "193", "194", "195", "196", "197", "198", "199", "200", "201", "202", "203", "204", "205", "206", "207", "208", "209", "210", "211", "212", "213", "214", "215", "216", "217", "218", "219", "220", "221", "222", "223", "224", "225", "226", "227", "228", "229", "230", "231", "232", "233", "234", "235", "236", "237", "238", "239", "240", "241", "242", "243", "244", "245", "246", "247", "248", "249", "250", "251", "252", "253", "254", "255", "256", "257", "258", "259", "260", "261", "262", "263", "264", "265", "266", "267", "268", "269", "270", "271", "272", "273", "274", "275", "276", "277", "278", "279", "280", "281", "282", "283", "284", "285", "286", "287", "288", "289", "290", "291", "292", "293", "294", "295", "296", "297", "298", "299", "300", "301", "302", "303", "304", "305", "306", "307", "308", "309", "310", "311", "312", "313", "314", "315", "316", "317", "318", "319", "320", "321", "322", "323", "324", "325", "326", "327", "328", "329", "330", "331", "332", "333", "334", "335", "336", "337", "338", "339", "340", "341", "342", "343", "344", "345", "346", "347", "348", "349", "350", "351", "352", "353", "354", "355", "356", "357", "358", "359", "360", "361", "362", "363", "364", "365", "366", "367", "368", "369", "370", "371", "372", "373", "374", "375", "376", "377", "378", "379", "380", "381", "382", "383", "384", "385", "386", "387", "388", "389", "390", "391", "392", "393", "394", "395", "396", "397", "398", "399", "400", "401", "402", "403", "404", "405", "406", "407", "408", "409", "410", "411", "412", "413", "414", "415", "416", "417", "418", "419", "420", "421", "422", "423", "424", "425", "426", "427", "428", "429", "430", "431", "432", "433", "434", "435", "436", "437", "438", "439", "440", "441", "442", "443", "444", "445", "446", "447", "448", "449", "450", "451", "452", "453", "454", "455", "456", "457", "458", "459", "460", "461", "462", "463", "464", "465", "466", "467", "468", "469", "470", "471", "472", "473", "474", "475", "476", "477", "478", "479", "480", "481", "482", "483", "484", "485", "486", "487", "488", "489", "490", "491", "492", "493", "494", "495", "496", "497", "498", "499", "500", "501", "502", "503", "504", "505", "506", "507", "508", "509", "510", "511", "512", "513", "514", "515", "516", "517", "518", "519", "520", "521", "522", "523", "524", "525", "526", "527", "528", "529", "530", "531", "532", "533", "534", "535", "536", "537", "538", "539", "540", "541", "542", "543", "544", "545", "546", "547", "548", "549", "550", "551", "552", "553", "554", "555", "556", "557", "558", "559", "560", "561", "562", "563", "564", "565", "566", "567", "568", "569", "570", "571", "572", "573", "574", "575", "576", "577", "578", "579", "580", "581", "582", "583", "584", "585", "586", "587", "588", "589", "590", "591", "592", "593", "594", "595", "596", "597", "598", "599", "600", "601", "602", "603", "604", "605", "606", "607", "608", "609", "610", "611", "612", "613", "614", "615", "616", "617", "618", "619", "620", "621", "622", "623", "624", "625", "626", "627", "628", "629", "630", "631", "632", "633", "634", "635", "636", "637", "638", "639", "640", "641", "642", "643", "644", "645", "646", "647", "648", "649", "650", "651", "652", "653", "654", "655", "656", "657", "658", "659", "660", "661", "662", "663", "664", "665", "666", "667", "668", "669", "670", "671", "672", "673", "674", "675", "676", "677", "678", "679", "680", "681", "682", "683", "684", "685", "686", "687", "688", "689", "690", "691", "692", "693", "694", "695", "696", "697", "698", "699", "700", "701", "702", "703", "704", "705", "706", "707", "708", "709", "710", "711", "712", "713", "714", "715", "716", "717", "718", "719", "720", "721", "722", "723", "724", "725", "726", "727", "728", "729", "730", "731", "732", "733", "734", "735", "736", "737", "738", "739", "740", "741", "742", "743", "744", "745", "746", "747", "748", "749", "750", "751", "752", "753", "754", "755", "756", "757", "758", "759", "760", "761", "762", "763", "764", "765", "766", "767", "768", "769", "770", "771", "772", "773", "777", "778", "792", "793", "794", "795", "796", "797", "805", "806", "807", "830", "834", "863", "864", "865", "876", "877", "878", "879", "886", "887", "891", "910", "911", "921", "923", "930", "939", "940", "941", "942", "949", "955", "964", "986", "994", "995", "996", "997", "1036", "1037", "1044", "1047", "1055", "1056", "1066", "1067", "1068", "1069", "1070", "1071", "1072", "1091", "1113", "1122", "1123", "1124", "1133", "1141", "1152", "1157", "1158", "1159", "1160", "1171", "1172", "1181", "1213", "1236", "1237", "1238", "1239", "1240", "1241", "1242", "1249", "1273", "1307", "1308", "1309", "1335", "1336", "1353", "1354", "1355", "1356", "1358", "1364", "1374", "1379", "1392", "1393", "1407", "1409", "1410", "1411", "1412", "1413", "1414", "1418", "1419", "1420", "1431", "1450", "1453", "1479", "1480", "1481", "1492", "1493", "1495", "1496", "1497", "1498", "1522", "1538", "1564", "1565", "1566", "1567", "1570", "1571", "1580", "1581", "1582", "1584", "1585", "1593", "1594", "1595", "1614", "1620", "1625", "1626", "1644", "1660", "1679", "1682", "1683", "1684", "1685", "1689", "1690", "1698", "1707", "1713", "1751", "1752", "1760", "1761", "1764", "1765", "1782", "1783", "1794", "1803", "1806", "1807", "1811", "1812", "1813", "1814", "1815", "1816", "1821", "1822", "1849", "1850", "1854", "1865", "1866", "1867", "1868", "1875", "1886", "1895", "1898", "1899", "1902", "1904", "1915", "1916", "1917", "1918", "1920", "1921", "1946", "1947", "1990", "1995", "1996", "2003", "2012", "2013", "2015", "2016", "2017", "2018", "2019", "2068", "2071", "2072", "2121", "2122", "2127", "2142", "2166", "2167", "2168", "2169", "2178", "2179", "2180", "2181", "2182", "2236", "2282", "2283", "2284", "2309", "2310", "2317", "2319", "2334", "2364", "2365", "2366", "2376", "2377", "2384", "2409", "2419", "2435", "2436", "2437", "2438", "2439", "2440", "2445", "2446", "2482", "2502", "2503", "2510", "2511", "2513", "2514", "2515", "2558", "2575", "2576", "2580", "2611", "2612", "2613", "2622", "2623", "2633", "2653", "2659", "2672", "2686", "2687", "2697", "2707", "2708", "2718", "2757", "2758", "2763", "2764", "2777", "2783", "2784", "2791", "2808", "2833", "2834", "2835", "2840", "2862", "2863", "2880", "2881", "2882", "2883", "2884", "2898", "2908", "2948", "2952", "2953", "2969", "2970", "2971", "2972", "2973", "2974", "3028", "3043", "3044", "3045", "3046", "3057", "3058", "3061", "3071", "3072", "3089", "3099", "3129", "3130", "3131", "3132", "3133", "3136", "3144", "3145", "3158", "3175", "3207", "3208", "3209", "3212", "3217", "3218", "3219", "3220", "3221", "3222", "3235", "3236", "3237", "3253", "3254", "3255", "3257", "3272", "3273", "3279", "3291", "3292", "3318", "3319", "3320", "3321", "3380", "3415", "3422", "3423", "3424", "3425", "3426", "3457", "3458", "3474", "3521", "3522", "3523", "3537", "3568", "3569", "3576", "3577", "3578", "3583", "3598", "3599", "3600", "3612", "3613", "3621", "3622", "3632", "3633", "3638", "3639", "3640", "3650", "3669", "3670", "3675", "3676", "3697", "3708", "3712", "3713", "3714", "3732", "3733", "3734", "3735", "3744", "3745", "3767", "3768", "3769", "3783", "3784", "3785"), class = "omit"), row.names = c(1L, 4L, 6L, 8L, 9L, 11L, 13L, 19L, 23L, 24L, 28L, 31L, 36L, 37L, 38L, 46L, 47L, 49L, 54L, 56L, 57L, 58L, 60L, 61L, 63L, 64L, 65L, 67L, 68L, 69L, 72L, 74L, 77L, 80L, 82L, 83L, 84L, 85L, 86L, 88L, 91L, 95L, 96L, 97L, 98L, 104L, 107L, 112L, 113L, 115L), class = "data.frame")
答案 0 :(得分:1)
你有一个很大的na.action
属性,head()
没有截断(尽管可能应该):str(dd)
的尾端({{1}你上面粘贴的对象是:
dd
也许你想要这样的东西:
- attr(*, "na.action")=Class 'omit' Named int [1:1174] 1 2 3 4 5 6 7 8 9 10 ...
.. ..- attr(*, "names")= chr [1:1174] "1" "2" "3" "4" ...
我不是百分百肯定这是对的 - 如果您有一个例子,其中丢弃的NA值很重要,您可能需要仔细检查......
应用于您的示例,shorthead <- function(x,n) {
r <- head(x,n)
if (!is.null(navals <- attr(x,"na.action"))) {
navals <- navals[navals<n]
attr(r,"na.action") <- navals
}
return(r)
}
给出:
shorthead(dd,4)