2016-12-04 5 views
-1

変数を使用してデータフレームの行にアクセスするにはどうすればよいですか?私がデータフレームteを持っていて、列のすべての行を取得したいのですが、それらにアクセスするために変数を使用する必要があります。どのようにすればいいですか?どのように各係数に等しい行数を動的に取得するのですか?

structure(list(SHOP_DATE = c(20060410L, 20060410L, 20060411L, 20060415L, 20060413L, 20060415L, 20060414L, 20060413L, 20060416L, 20060414L, 20060413L, 20060415L, 20060416L, 20060413L, 20060415L, 20060411L, 20060416L, 20060415L, 20060411L, 20060410L), SHOP_WEEKDAY = c(2L, 2L, 3L, 7L, 5L, 7L, 6L, 5L, 1L, 6L, 5L, 7L, 1L, 5L, 7L, 3L, 1L, 7L, 3L, 2L), SHOP_HOUR = c(14L, 13L, 13L, 8L, 14L, 10L, 13L, 13L, 12L, 15L, 15L, 13L, 15L, 18L, 11L, 11L, 15L, 14L, 17L, 20L), QUANTITY = c(28L, 2L, 1L, 26L, 14L, 16L, 6L, 6L, 4L, 3L, 8L, 3L, 6L, 1L, 4L, 2L, 7L, 3L, 9L, 2L), SPEND = c(38.83, 1.9, 0.85, 35.71, 4.02, 18.09, 5.43, 12.09, 7.94, 2.37, 18.13, 3.7, 7.27, 0.67, 1.69, 1.6, 6.73, 1.9, 7.74, 0.84), PROD_CODE = c(70, 590, 231, 81, 587, 887, 894, 405, 677, 635, 93, 433, 81, 528, 289, 935, 680, 471, 471, 254), PROD_CODE_10 = c(163, 171, 1, 130, 196, 70, 160, 34, 16, 82, 52, 22, 130, 84, 68, 160, 152, 195, 195, 85), PROD_CODE_20 = c(10, 14, 1, 70, 28, 49, 10, 40, 35, 53, 43, 36, 70, 54, 34, 10, 7, 28, 28, 54), PROD_CODE_30 = c(26, 27, 1, 23, 3, 11, 26, 7, 5, 13, 8, 5, 23, 14, 22, 26, 26, 3, 3, 14), PROD_CODE_40 = c(2, 2, 1, 2, 3, 5, 2, 3, 3, 5, 3, 3, 2, 5, 1, 2, 2, 3, 3, 5), CUST_CODE = c(1, 1, 650, 761, 872, 983, 1094, 1094, 1205, 1316, 1316, 1316, 1316, 1316, 1427, 1427, 2, 113, 113, 224), CUST_PRICE_SENSITIVITY = c(1, 1, 2, 2, 1, 3, 2, 2, 2, 1, 1, 1, 1, 1, 3, 3, 1, 3, 3, 1), CUST_LIFESTAGE = c(3, 3, 1, 3, 4, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 1, 5, 5, 2), BASKET_ID = c(1, 1112, 1864, 1975, 2086, 2197, 2308, 2419, 2530, 2, 113, 224, 335, 446, 557, 668, 779, 890, 1001, 1113), BASKET_SIZE = c(1, 3, 3, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 2, 2, 2, 3), BASKET_PRICE_SENSITIVITY = c(2, 2, 2, 2, 2, 3, 2, 2, 1, 2, 2, 1, 2, 2, 1, 1, 1, 3, 3, 1), BASKET_TYPE = c(1, 2, 2, 1, 3, 1, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2), BASKET_DOMINANT_MISSION = c(1, 1, 1, 1, 1, 3, 3, 3, 2, 1, 1, 2, 1, 4, 1, 3, 1, 2, 1, 3), STORE_CODE = c(278, 278, 11, 169, 533, 271, 185, 185, 333, 358, 358, 358, 358, 358, 432, 355, 528, 22, 22, 96), STORE_FORMAT = c(1, 1, 2, 1, 3, 1, 2, 2, 1, 1, 1, 1, 1, 1, 4, 1, 1, 2, 2, 4), STORE_REGION = c(5, 5, 9, 3, 7, 3, 2, 2, 10, 5, 5, 5, 5, 5, 2, 6, 4, 11, 11, 9)), .Names = c("SHOP_DATE", "SHOP_WEEKDAY", "SHOP_HOUR", "QUANTITY", "SPEND", "PROD_CODE", "PROD_CODE_10", "PROD_CODE_20", "PROD_CODE_30", "PROD_CODE_40", "CUST_CODE", "CUST_PRICE_SENSITIVITY", "CUST_LIFESTAGE", "BASKET_ID", "BASKET_SIZE", "BASKET_PRICE_SENSITIVITY", "BASKET_TYPE", "BASKET_DOMINANT_MISSION", "STORE_CODE", "STORE_FORMAT", "STORE_REGION"), 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(774L, 775L, 776L, 779L, 780L, 781L, 782L, 783L, 784L, 785L, 786L, 787L, 788L, 789L, 790L, 791L, 798L, 799L, 800L, 801L), class = "data.frame") 
+0

私はあなたの 'te'で読むことを試みましたが、何かが見当たりません。また、少しあなたの問題に困惑。 'te [、" column_name "]'のようなカラム名を使ってデータを取得することを単に暗示していますか?基本的に 'var_name =" column_name "となります。 te [、var_name] ' –

+0

これはうまくいった!基本的には、 '=='を括弧の外側に置かなければなりませんでした: 'te [、target] == x'。 –

答えて

0
te[,target]==x 

は私の質問に直接答えですが、私が代わりにforsapplyを使用して終了:

target<-"BASKET_SIZE" 
for(x in levels(te[target])) 
    te[target==x] 

はここteだ:私はこのような何かをしたいです。

df$Toats<-sapply[levels(te[,target]), function(x) length(te[,target]==x)] 

@GeneBurinskyが回答を投稿した場合、私はそれを受け入れます。

関連する問題