问:
If-Else Statement in R with 3 conditions
I am trying to use an if-else statement to create a column in my data set. I want this if-else statement to create a column called "Surgical" in the df "option1" that displays the value of the column "Duration" subtracted by 20 ONLY IF the value in Duration is above 625, AND the factor "Single" is indicated in the column "Variability".
I have tried the following code:

```<code>option1$Surgical <- ifelse(option1$Variability == "Single", option1$Duration - 20, option1$Duration)
</code>```

Any insight into how to specify the "only if the value is greater than 625" portion is appreciated!!

Df "option 1" for reference.

dput(option1)
      structure(list(Stimulus = structure(c(36L, 37L, 38L, 39L, 40L,
      41L, 42L, 43L, 44L, 45L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 60L,
      61L, 62L, 63L, 64L, 65L, 66L, 67L, 73L, 74L, 75L, 76L, 77L, 78L,
      79L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 46L, 47L,
      48L, 49L, 50L, 51L, 52L, 53L, 57L, 58L, 59L, 60L, 61L, 62L, 63L,
      69L, 70L, 71L, 72L, 73L, 74L, 75L, 36L, 37L, 38L, 39L, 40L, 41L,
      42L, 43L, 44L, 45L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 60L, 61L,
      62L, 63L, 64L, 65L, 66L, 67L, 73L, 74L, 75L, 76L, 77L, 78L, 79L,
      31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 46L, 47L, 48L,
      49L, 50L, 51L, 52L, 53L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 69L,
      70L, 71L, 72L, 73L, 74L, 75L, 7L, 9L, 12L, 18L, 28L, 26L, 51L,
      37L, 3L, 2L, 19L, 14L, 27L, 23L, 65L, 77L, 7L, 9L, 12L, 18L,
      28L, 26L, 51L, 37L, 3L, 2L, 19L, 14L, 27L, 23L, 65L, 77L, 5L,
      11L, 20L, 16L, 30L, 25L, 35L, 33L, 7L, 9L, 12L, 18L, 28L, 26L,
      51L, 37L, 5L, 11L, 20L, 16L, 30L, 25L, 35L, 33L, 7L, 9L, 12L,
      18L, 28L, 26L, 51L, 37L), .Label = c("t1_block2_hoed3.mp3", "t1_block2_whod3.mp3",
      "t1_block2_whod4.mp3", "t1_block2_whod5.mp3", "t1_block3_heed2.mp3",
      "t1_block3_heed5.mp3", "t1_block3_hoed1.mp3", "t1_block3_hoed2.mp3",
      "t1_block3_hoed4.mp3", "t1_block3_whod3.mp3", "t1_block4_heed5.mp3",
      "t2_block1_hoed3.mp3", "t2_block1_whod1.mp3", "t2_block1_whod2.mp3",
      "t2_block1_whod4.mp3", "t2_block2_heed3.mp3", "t2_block2_hoed5.mp3",
      "t2_block3_hoed1.mp3", "t2_block3_whod1.mp3", "t2_block4_heed2.mp3",
      "t2_block4_heed5.mp3", "t3_block1_heed1.mp3", "t3_block1_whod2.mp3",
      "t3_block1_whod5.mp3", "t3_block2_heed5.mp3", "t3_block2_hoed2.mp3",
      "t3_block2_whod5.mp3", "t3_block3_hoed1.mp3", "t3_block3_hoed4.mp3",
      "t3_block4_heed3.mp3", "t4_block1_heed1.mp3", "t4_block1_heed2.mp3",
      "t4_block1_heed3.mp3", "t4_block1_heed4.mp3", "t4_block1_heed5.mp3",
      "t4_block1_hoed1.mp3", "t4_block1_hoed2.mp3", "t4_block1_hoed3.mp3",
      "t4_block1_hoed4.mp3", "t4_block1_hoed5.mp3", "t4_block1_whod1.mp3",
      "t4_block1_whod2.mp3", "t4_block1_whod3.mp3", "t4_block1_whod4.mp3",
      "t4_block1_whod5.mp3", "t4_block2_heed1.mp3", "t4_block2_heed2.mp3",
      "t4_block2_heed4.mp3", "t4_block2_heed5.mp3", "t4_block2_hoed1.mp3",
      "t4_block2_hoed3.mp3", "t4_block2_hoed4.mp3", "t4_block2_hoed5.mp3",
      "t4_block2_whod2.mp3", "t4_block2_whod4.mp3", "t4_block2_whod5.mp3",
      "t4_block3_heed1.mp3", "t4_block3_heed4.mp3", "t4_block3_heed5.mp3",
      "t4_block3_hoed1.mp3", "t4_block3_hoed2.mp3", "t4_block3_hoed4.mp3",
      "t4_block3_hoed5.mp3", "t4_block3_whod1.mp3", "t4_block3_whod2.mp3",
      "t4_block3_whod3.mp3", "t4_block3_whod5.mp3", "t4_block4_heed1.mp3",
      "t4_block4_heed2.mp3", "t4_block4_heed3.mp3", "t4_block4_heed4.mp3",
      "t4_block4_heed5.mp3", "t4_block4_hoed1.mp3", "t4_block4_hoed2.mp3",
      "t4_block4_hoed3.mp3", "t4_block4_whod1.mp3", "t4_block4_whod2.mp3",
      "t4_block4_whod3.mp3", "t4_block4_whod5.mp3"), class = "factor"),
          Duration = c(497L, 517L, 580L, 563L, 569L, 486L, 506L, 536L,
          545L, 554L, 516L, 600L, 607L, 577L, 537L, 583L, 544L, 566L,
          567L, 616L, 652L, 564L, 517L, 612L, 564L, 632L, 662L, 565L,
          594L, 622L, 552L, 542L, 539L, 554L, 600L, 607L, 577L, 497L,
          517L, 580L, 563L, 569L, 594L, 563L, 623L, 602L, 516L, 600L,
          607L, 577L, 531L, 642L, 624L, 566L, 567L, 616L, 652L, 654L,
          576L, 556L, 608L, 632L, 662L, 565L, 497L, 517L, 580L, 563L,
          569L, 486L, 506L, 536L, 545L, 554L, 516L, 600L, 607L, 577L,
          537L, 583L, 544L, 566L, 567L, 616L, 652L, 564L, 517L, 612L,
          564L, 632L, 662L, 565L, 594L, 622L, 552L, 542L, 539L, 554L,
          600L, 607L, 577L, 497L, 517L, 580L, 563L, 569L, 594L, 563L,
          623L, 602L, 516L, 600L, 607L, 577L, 531L, 642L, 624L, 566L,
          567L, 616L, 652L, 654L, 576L, 556L, 608L, 632L, 662L, 565L,
          452L, 547L, 510L, 663L, 470L, 503L, 600L, 517L, 491L, 505L,
          641L, 581L, 520L, 485L, 517L, 622L, 452L, 547L, 510L, 663L,
          470L, 503L, 600L, 517L, 491L, 505L, 641L, 581L, 520L, 485L,
          517L, 622L, 510L, 458L, 558L, 638L, 483L, 538L, 577L, 600L,
          452L, 547L, 510L, 663L, 470L, 503L, 600L, 517L, 510L, 458L,
          558L, 638L, 483L, 538L, 577L, 600L, 452L, 547L, 510L, 663L,
          470L, 503L, 600L, 517L), F0 = c(196L, 204L, 204L, 197L, 203L,
          216L, 208L, 223L, 213L, 219L, 196L, 202L, 205L, 202L, 208L,
          205L, 206L, 197L, 202L, 195L, 200L, 201L, 210L, 202L, 208L,
          195L, 196L, 195L, 205L, 208L, 203L, 203L, 212L, 213L, 210L,
          206L, 204L, 196L, 204L, 204L, 197L, 203L, 201L, 198L, 199L,
          203L, 196L, 202L, 205L, 202L, 193L, 195L, 208L, 197L, 202L,
          195L, 200L, 201L, 195L, 205L, 202L, 195L, 196L, 195L, 196L,
          204L, 204L, 197L, 203L, 216L, 208L, 223L, 213L, 219L, 196L,
          202L, 205L, 202L, 208L, 205L, 206L, 197L, 202L, 195L, 200L,
          201L, 210L, 202L, 208L, 195L, 196L, 195L, 205L, 208L, 203L,
          203L, 212L, 213L, 210L, 206L, 204L, 196L, 204L, 204L, 197L,
          203L, 201L, 198L, 199L, 203L, 196L, 202L, 205L, 202L, 193L,
          195L, 208L, 197L, 202L, 195L, 200L, 201L, 195L, 205L, 202L,
          195L, 196L, 195L, 215L, 219L, 219L, 220L, 199L, 202L, 202L,
          204L, 224L, 231L, 238L, 240L, 217L, 212L, 210L, 208L, 215L,
          219L, 219L, 220L, 199L, 202L, 202L, 204L, 224L, 231L, 238L,
          240L, 217L, 212L, 210L, 208L, 230L, 223L, 219L, 221L, 199L,
          200L, 204L, 210L, 215L, 219L, 219L, 220L, 199L, 202L, 202L,
          204L, 230L, 223L, 219L, 221L, 199L, 200L, 204L, 210L, 215L,
          219L, 219L, 220L, 199L, 202L, 202L, 204L), F1 = c(576L, 553L,
          579L, 586L, 601L, 398L, 390L, 398L, 389L, 404L, 587L, 560L,
          562L, 553L, 393L, 397L, 382L, 553L, 592L, 556L, 571L, 387L,
          392L, 398L, 400L, 580L, 580L, 554L, 403L, 391L, 388L, 393L,
          382L, 375L, 384L, 392L, 388L, 576L, 553L, 579L, 586L, 601L,
          387L, 393L, 402L, 406L, 587L, 560L, 562L, 553L, 388L, 391L,
          412L, 553L, 592L, 556L, 571L, 410L, 404L, 401L, 420L, 580L,
          580L, 554L, 576L, 553L, 579L, 586L, 601L, 398L, 390L, 398L,
          389L, 404L, 587L, 560L, 562L, 553L, 393L, 397L, 382L, 553L,
          592L, 556L, 571L, 387L, 392L, 398L, 400L, 580L, 580L, 554L,
          403L, 391L, 388L, 393L, 382L, 375L, 384L, 392L, 388L, 576L,
          553L, 579L, 586L, 601L, 387L, 393L, 402L, 406L, 587L, 560L,
          562L, 553L, 388L, 391L, 412L, 553L, 592L, 556L, 571L, 410L,
          404L, 401L, 420L, 580L, 580L, 554L, 620L, 630L, 602L, 605L,
          571L, 573L, 560L, 553L, 434L, 417L, 306L, 319L, 414L, 419L,
          392L, 391L, 620L, 630L, 602L, 605L, 571L, 573L, 560L, 553L,
          434L, 417L, 306L, 319L, 414L, 419L, 392L, 391L, 448L, 441L,
          293L, 291L, 420L, 420L, 388L, 384L, 620L, 630L, 602L, 605L,
          571L, 573L, 560L, 553L, 448L, 441L, 293L, 291L, 420L, 420L,
          388L, 384L, 620L, 630L, 602L, 605L, 571L, 573L, 560L, 553L
          ), F2 = c(1339L, 1381L, 1381L, 1347L, 1394L, 1484L, 1521L,
          1539L, 1430L, 1454L, 1353L, 1378L, 1325L, 1357L, 1424L, 1563L,
          1578L, 1350L, 1397L, 1273L, 1319L, 1548L, 1452L, 1499L, 1515L,
          1358L, 1347L, 1248L, 1575L, 1438L, 1414L, 1548L, 3001L, 2916L,
          2948L, 2973L, 2947L, 1339L, 1381L, 1381L, 1347L, 1394L, 2943L,
          2913L, 2987L, 2940L, 1353L, 1378L, 1325L, 1357L, 3010L, 3008L,
          2972L, 1350L, 1397L, 1273L, 1319L, 2963L, 2991L, 3007L, 2989L,
          1358L, 1347L, 1248L, 1339L, 1381L, 1381L, 1347L, 1394L, 1484L,
          1521L, 1539L, 1430L, 1454L, 1353L, 1378L, 1325L, 1357L, 1424L,
          1563L, 1578L, 1350L, 1397L, 1273L, 1319L, 1548L, 1452L, 1499L,
          1515L, 1358L, 1347L, 1248L, 1575L, 1438L, 1414L, 1548L, 3001L,
          2916L, 2948L, 2973L, 2947L, 1339L, 1381L, 1381L, 1347L, 1394L,
          2943L, 2913L, 2987L, 2940L, 1353L, 1378L, 1325L, 1357L, 3010L,
          3008L, 2972L, 1350L, 1397L, 1273L, 1319L, 2963L, 2991L, 3007L,
          2989L, 1358L, 1347L, 1248L, 1247L, 1244L, 1293L, 1264L, 1348L,
          1354L, 1378L, 1381L, 1314L, 1233L, 1190L, 1208L, 1643L, 1659L,
          1452L, 1438L, 1247L, 1244L, 1293L, 1264L, 1348L, 1354L, 1378L,
          1381L, 1314L, 1233L, 1190L, 1208L, 1643L, 1659L, 1452L, 1438L,
          2837L, 2816L, 2780L, 2776L, 2684L, 2718L, 2947L, 2948L, 1247L,
          1244L, 1293L, 1264L, 1348L, 1354L, 1378L, 1381L, 2837L, 2816L,
          2780L, 2776L, 2684L, 2718L, 2947L, 2948L, 1247L, 1244L, 1293L,
          1264L, 1348L, 1354L, 1378L, 1381L), F3 = c(2831L, 2779L,
          2915L, 2875L, 2712L, 2730L, 2793L, 2779L, 2772L, 2692L, 2718L,
          2856L, 2674L, 2659L, 2717L, 2584L, 2829L, 2726L, 2685L, 2866L,
          2793L, 2614L, 2636L, 2907L, 2822L, 2932L, 2882L, 2882L, 2650L,
          2929L, 2809L, 2737L, 3623L, 3607L, 3584L, 3576L, 3680L, 2831L,
          2779L, 2915L, 2875L, 2712L, 3641L, 3590L, 3556L, 3584L, 2718L,
          2856L, 2674L, 2659L, 3640L, 3656L, 3686L, 2726L, 2685L, 2866L,
          2793L, 3516L, 3552L, 3513L, 3579L, 2932L, 2882L, 2882L, 2831L,
          2779L, 2915L, 2875L, 2712L, 2730L, 2793L, 2779L, 2772L, 2692L,
          2718L, 2856L, 2674L, 2659L, 2717L, 2584L, 2829L, 2726L, 2685L,
          2866L, 2793L, 2614L, 2636L, 2907L, 2822L, 2932L, 2882L, 2882L,
          2650L, 2929L, 2809L, 2737L, 3623L, 3607L, 3584L, 3576L, 3680L,
          2831L, 2779L, 2915L, 2875L, 2712L, 3641L, 3590L, 3556L, 3584L,
          2718L, 2856L, 2674L, 2659L, 3640L, 3656L, 3686L, 2726L, 2685L,
          2866L, 2793L, 3516L, 3552L, 3513L, 3579L, 2932L, 2882L, 2882L,
          2711L, 3129L, 2786L, 2833L, 2754L, 2771L, 2856L, 2779L, 2909L,
          2750L, 2866L, 2863L, 2804L, 2704L, 2636L, 2929L, 2711L, 3129L,
          2786L, 2833L, 2754L, 2771L, 2856L, 2779L, 2909L, 2750L, 2866L,
          2863L, 2804L, 2704L, 2636L, 2929L, 3226L, 3121L, 3867L, 3319L,
          3426L, 3269L, 3680L, 3357L, 2711L, 3129L, 2786L, 2833L, 2754L,
          2771L, 2856L, 2779L, 3226L, 3121L, 3867L, 3319L, 3426L, 3269L,
          3680L, 3357L, 2711L, 3129L, 2786L, 2833L, 2754L, 2771L, 2856L,
          2779L), Word = structure(c(2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L,
          4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L,
          4L, 4L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 2L,
          2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
          2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 2L, 2L,
          2L, 2L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 1L, 1L,
          1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
          2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
          3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L), .Label = c("heed", "hoed", "hoed ", "whod"
          ), class = "factor"), Vowel = structure(c(2L, 2L, 2L, 2L,
          2L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 2L, 2L,
          2L, 2L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 1L, 1L,
          1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
          2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L,
          4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 4L, 4L,
          4L, 4L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
          1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
          1L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("i", "o", "o ",
          "u"), class = "factor"), F1.Mean = c(564L, 564L, 564L, 564L,
          564L, 394L, 394L, 394L, 394L, 394L, 564L, 564L, 564L, 564L,
          394L, 394L, 394L, 564L, 564L, 564L, 564L, 394L, 394L, 394L,
          394L, 564L, 564L, 564L, 394L, 394L, 394L, 394L, 398L, 398L,
          398L, 398L, 398L, 564L, 564L, 564L, 564L, 564L, 398L, 398L,
          398L, 398L, 564L, 564L, 564L, 564L, 398L, 398L, 398L, 564L,
          564L, 564L, 564L, 398L, 398L, 398L, 398L, 564L, 564L, 564L,
          564L, 564L, 564L, 564L, 564L, 394L, 394L, 394L, 394L, 394L,
          564L, 564L, 564L, 564L, 394L, 394L, 394L, 564L, 564L, 564L,
          564L, 394L, 394L, 394L, 394L, 564L, 564L, 564L, 394L, 394L,
          394L, 394L, 398L, 398L, 398L, 398L, 398L, 564L, 564L, 564L,
          564L, 564L, 398L, 398L, 398L, 398L, 564L, 564L, 564L, 564L,
          398L, 398L, 398L, 564L, 564L, 564L, 564L, 398L, 398L, 398L,
          398L, 564L, 564L, 564L, 627L, 627L, 614L, 614L, 614L, 614L,
          566L, 566L, 432L, 432L, 327L, 327L, 415L, 415L, 393L, 393L,
          627L, 627L, 614L, 614L, 614L, 614L, 566L, 566L, 432L, 432L,
          327L, 327L, 415L, 415L, 393L, 393L, 397L, 397L, 292L, 292L,
          417L, 417L, 398L, 398L, 627L, 627L, 614L, 614L, 614L, 614L,
          566L, 566L, 397L, 397L, 292L, 292L, 417L, 417L, 398L, 398L,
          627L, 627L, 614L, 614L, 614L, 614L, 566L, 566L), F2.Mean = c(1328L,
          1328L, 1328L, 1328L, 1328L, 1496L, 1496L, 1496L, 1496L, 1496L,
          1328L, 1328L, 1328L, 1328L, 1496L, 1496L, 1496L, 1328L, 1328L,
          1328L, 1328L, 1496L, 1496L, 1496L, 1496L, 1328L, 1328L, 1328L,
          1496L, 1496L, 1496L, 1496L, 2969L, 2969L, 2969L, 2969L, 2969L,
          1328L, 1328L, 1328L, 1328L, 1328L, 2969L, 2969L, 2969L, 2969L,
          1328L, 1328L, 1328L, 1328L, 2969L, 2969L, 2969L, 1328L, 1328L,
          1328L, 1328L, 2969L, 2969L, 2969L, 2969L, 1328L, 1328L, 1328L,
          1328L, 1328L, 1328L, 1328L, 1328L, 1496L, 1496L, 1496L, 1496L,
          1496L, 1328L, 1328L, 1328L, 1328L, 1496L, 1496L, 1496L, 1328L,
          1328L, 1328L, 1328L, 1496L, 1496L, 1496L, 1496L, 1328L, 1328L,
          1328L, 1496L, 1496L, 1496L, 1496L, 2969L, 2969L, 2969L, 2969L,
          2969L, 1328L, 1328L, 1328L, 1328L, 1328L, 2969L, 2969L, 2969L,
          2969L, 1328L, 1328L, 1328L, 1328L, 2969L, 2969L, 2969L, 1328L,
          1328L, 1328L, 1328L, 2969L, 2969L, 2969L, 2969L, 1328L, 1328L,
          1328L, 1250L, 1250L, 1247L, 1247L, 1247L, 1247L, 1357L, 1357L,
          1292L, 1292L, 1157L, 1157L, 1746L, 1746L, 1455L, 1455L, 1250L,
          1250L, 1247L, 1247L, 1247L, 1247L, 1357L, 1357L, 1292L, 1292L,
          1157L, 1157L, 1746L, 1746L, 1455L, 1455L, 2828L, 2828L, 2763L,
          2763L, 2721L, 2721L, 2969L, 2969L, 1250L, 1250L, 1247L, 1247L,
          1247L, 1247L, 1357L, 1357L, 2828L, 2828L, 2763L, 2763L, 2721L,
          2721L, 2969L, 2969L, 1250L, 1250L, 1247L, 1247L, 1247L, 1247L,
          1357L, 1357L), Distance = c(16L, 54L, 55L, 29L, 76L, 13L,
          25L, 43L, 66L, 43L, 34L, 50L, 4L, 31L, 72L, 67L, 83L, 25L,
          74L, 56L, 11L, 52L, 44L, 5L, 20L, 34L, 25L, 81L, 80L, 58L,
          82L, 52L, 36L, 58L, 25L, 7L, 24L, 16L, 54L, 55L, 29L, 76L,
          28L, 56L, 18L, 30L, 34L, 50L, 4L, 31L, 42L, 40L, 14L, 25L,
          74L, 56L, 11L, 13L, 23L, 38L, 30L, 34L, 25L, 81L, 16L, 54L,
          55L, 29L, 76L, 13L, 25L, 43L, 66L, 43L, 34L, 50L, 4L, 31L,
          72L, 67L, 83L, 25L, 74L, 56L, 11L, 52L, 44L, 5L, 20L, 34L,
          25L, 81L, 80L, 58L, 82L, 52L, 36L, 58L, 25L, 7L, 24L, 16L,
          54L, 55L, 29L, 76L, 28L, 56L, 18L, 30L, 34L, 50L, 4L, 31L,
          42L, 40L, 14L, 25L, 74L, 56L, 11L, 13L, 23L, 38L, 30L, 34L,
          25L, 81L, 8L, 7L, 48L, 19L, 110L, 115L, 22L, 27L, 22L, 61L,
          39L, 52L, 103L, 87L, 3L, 17L, 8L, 7L, 48L, 19L, 110L, 115L,
          22L, 27L, 22L, 61L, 39L, 52L, 103L, 87L, 3L, 17L, 52L, 46L,
          17L, 13L, 37L, 4L, 24L, 25L, 8L, 7L, 48L, 19L, 110L, 115L,
          22L, 27L, 52L, 46L, 17L, 13L, 37L, 4L, 24L, 25L, 8L, 7L,
          48L, 19L, 110L, 115L, 22L, 27L), Included = 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, 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, 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, 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 = "Yes", class = "factor"),
          Talker = structure(c(4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L,
          1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L,
          1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L,
          4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L,
          4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L,
          3L, 4L, 4L), .Label = c("T1 ", "T2", "T3", "T4"), class = "factor"),
          Ambiguity = 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, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 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, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 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, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L), .Label = c("High", "Low"), class = "factor"),
          Variability = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
          1L, 1L, 1L, 1L), .Label = c("Mixed", "Single"), class = "factor"),
          Consistency = 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, 1L, 1L, 1L,
          1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
          1L, 1L, 1L, 1L), .Label = c("Consistent", "Inconsistent"), class = "factor"),
          Fake = c(477, 497, 560, 543, 549, 466, 486, 516, 525, 534,
          496, 580, 587, 557, 517, 563, 524, 546, 547, 596, 632, 544,
          497, 592, 544, 612, 642, 545, 574, 602, 532, 522, 519, 534,
          580, 587, 557, 477, 497, 560, 543, 549, 574, 543, 603, 582,
          496, 580, 587, 557, 511, 622, 604, 546, 547, 596, 632, 634,
          556, 536, 588, 612, 642, 545, 477, 497, 560, 543, 549, 466,
          486, 516, 525, 534, 496, 580, 587, 557, 517, 563, 524, 546,
          547, 596, 632, 544, 497, 592, 544, 612, 642, 545, 574, 602,
          532, 522, 519, 534, 580, 587, 557, 477, 497, 560, 543, 549,
          574, 543, 603, 582, 496, 580, 587, 557, 511, 622, 604, 546,
          547, 596, 632, 634, 556, 536, 588, 612, 642, 545, 452, 547,
          510, 663, 470, 503, 600, 517, 491, 505, 641, 581, 520, 485,
          517, 622, 452, 547, 510, 663, 470, 503, 600, 517, 491, 505,
          641, 581, 520, 485, 517, 622, 510, 458, 558, 638, 483, 538,
          577, 600, 452, 547, 510, 663, 470, 503, 600, 517, 510, 458,
          558, 638, 483, 538, 577, 600, 452, 547, 510, 663, 470, 503,
          600, 517), Check = c(20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0)), row.names = c(NA, -192L), class = "data.frame")

答:
You can do this directly without using ifelse :

```<code>option1$Surgical <- with(option1, Duration - (20 *
                                  (Variability == 'Single' & Duration > 625)))
</code>```

Here, we take advantage of the fact that

```<code>20 * TRUE #gives
#[1] 20
</code>```

and

```<code>20 * FALSE #gives
#[1] 0
</code>```

So whenever the condition (Variability == 'Single' & Duration > 625) is TRUE it subtracts 20 from Duration or else 0.

Body:
I am trying to use an if-else statement to create a column in my data set. I want this if-else statement to create a column called "Surgical" in the df "option1" that displays the value of the column "Duration" subtracted by 20 ONLY IF the value in Duration is above 625, AND the factor "Single" is indicated in the column "Variability".
I have tried the following code:

option1$Surgical <- ifelse(option1$Variability == "Single", option1$Duration - 20, option1$Duration)

Any insight into how to specify the "only if the value is greater than 625" portion is appreciated!!

Df "option 1" for reference.

dput(option1)
      structure(list(Stimulus = structure(c(36L, 37L, 38L, 39L, 40L,
      41L, 42L, 43L, 44L, 45L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 60L,
      61L, 62L, 63L, 64L, 65L, 66L, 67L, 73L, 74L, 75L, 76L, 77L, 78L,
      79L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 46L, 47L,
      48L, 49L, 50L, 51L, 52L, 53L, 57L, 58L, 59L, 60L, 61L, 62L, 63L,
      69L, 70L, 71L, 72L, 73L, 74L, 75L, 36L, 37L, 38L, 39L, 40L, 41L,
      42L, 43L, 44L, 45L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 60L, 61L,
      62L, 63L, 64L, 65L, 66L, 67L, 73L, 74L, 75L, 76L, 77L, 78L, 79L,
      31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 46L, 47L, 48L,
      49L, 50L, 51L, 52L, 53L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 69L,
      70L, 71L, 72L, 73L, 74L, 75L, 7L, 9L, 12L, 18L, 28L, 26L, 51L,
      37L, 3L, 2L, 19L, 14L, 27L, 23L, 65L, 77L, 7L, 9L, 12L, 18L,
      28L, 26L, 51L, 37L, 3L, 2L, 19L, 14L, 27L, 23L, 65L, 77L, 5L,
      11L, 20L, 16L, 30L, 25L, 35L, 33L, 7L, 9L, 12L, 18L, 28L, 26L,
      51L, 37L, 5L, 11L, 20L, 16L, 30L, 25L, 35L, 33L, 7L, 9L, 12L,
      18L, 28L, 26L, 51L, 37L), .Label = c("t1_block2_hoed3.mp3", "t1_block2_whod3.mp3",
      "t1_block2_whod4.mp3", "t1_block2_whod5.mp3", "t1_block3_heed2.mp3",
      "t1_block3_heed5.mp3", "t1_block3_hoed1.mp3", "t1_block3_hoed2.mp3",
      "t1_block3_hoed4.mp3", "t1_block3_whod3.mp3", "t1_block4_heed5.mp3",
      "t2_block1_hoed3.mp3", "t2_block1_whod1.mp3", "t2_block1_whod2.mp3",
      "t2_block1_whod4.mp3", "t2_block2_heed3.mp3", "t2_block2_hoed5.mp3",
      "t2_block3_hoed1.mp3", "t2_block3_whod1.mp3", "t2_block4_heed2.mp3",
      "t2_block4_heed5.mp3", "t3_block1_heed1.mp3", "t3_block1_whod2.mp3",
      "t3_block1_whod5.mp3", "t3_block2_heed5.mp3", "t3_block2_hoed2.mp3",
      "t3_block2_whod5.mp3", "t3_block3_hoed1.mp3", "t3_block3_hoed4.mp3",
      "t3_block4_heed3.mp3", "t4_block1_heed1.mp3", "t4_block1_heed2.mp3",
      "t4_block1_heed3.mp3", "t4_block1_heed4.mp3", "t4_block1_heed5.mp3",
      "t4_block1_hoed1.mp3", "t4_block1_hoed2.mp3", "t4_block1_hoed3.mp3",
      "t4_block1_hoed4.mp3", "t4_block1_hoed5.mp3", "t4_block1_whod1.mp3",
      "t4_block1_whod2.mp3", "t4_block1_whod3.mp3", "t4_block1_whod4.mp3",
      "t4_block1_whod5.mp3", "t4_block2_heed1.mp3", "t4_block2_heed2.mp3",
      "t4_block2_heed4.mp3", "t4_block2_heed5.mp3", "t4_block2_hoed1.mp3",
      "t4_block2_hoed3.mp3", "t4_block2_hoed4.mp3", "t4_block2_hoed5.mp3",
      "t4_block2_whod2.mp3", "t4_block2_whod4.mp3", "t4_block2_whod5.mp3",
      "t4_block3_heed1.mp3", "t4_block3_heed4.mp3", "t4_block3_heed5.mp3",
      "t4_block3_hoed1.mp3", "t4_block3_hoed2.mp3", "t4_block3_hoed4.mp3",
      "t4_block3_hoed5.mp3", "t4_block3_whod1.mp3", "t4_block3_whod2.mp3",
      "t4_block3_whod3.mp3", "t4_block3_whod5.mp3", "t4_block4_heed1.mp3",
      "t4_block4_heed2.mp3", "t4_block4_heed3.mp3", "t4_block4_heed4.mp3",
      "t4_block4_heed5.mp3", "t4_block4_hoed1.mp3", "t4_block4_hoed2.mp3",
      "t4_block4_hoed3.mp3", "t4_block4_whod1.mp3", "t4_block4_whod2.mp3",
      "t4_block4_whod3.mp3", "t4_block4_whod5.mp3"), class = "factor"),
          Duration = c(497L, 517L, 580L, 563L, 569L, 486L, 506L, 536L,
          545L, 554L, 516L, 600L, 607L, 577L, 537L, 583L, 544L, 566L,
          567L, 616L, 652L, 564L, 517L, 612L, 564L, 632L, 662L, 565L,
          594L, 622L, 552L, 542L, 539L, 554L, 600L, 607L, 577L, 497L,
          517L, 580L, 563L, 569L, 594L, 563L, 623L, 602L, 516L, 600L,
          607L, 577L, 531L, 642L, 624L, 566L, 567L, 616L, 652L, 654L,
          576L, 556L, 608L, 632L, 662L, 565L, 497L, 517L, 580L, 563L,
          569L, 486L, 506L, 536L, 545L, 554L, 516L, 600L, 607L, 577L,
          537L, 583L, 544L, 566L, 567L, 616L, 652L, 564L, 517L, 612L,
          564L, 632L, 662L, 565L, 594L, 622L, 552L, 542L, 539L, 554L,
          600L, 607L, 577L, 497L, 517L, 580L, 563L, 569L, 594L, 563L,
          623L, 602L, 516L, 600L, 607L, 577L, 531L, 642L, 624L, 566L,
          567L, 616L, 652L, 654L, 576L, 556L, 608L, 632L, 662L, 565L,
          452L, 547L, 510L, 663L, 470L, 503L, 600L, 517L, 491L, 505L,
          641L, 581L, 520L, 485L, 517L, 622L, 452L, 547L, 510L, 663L,
          470L, 503L, 600L, 517L, 491L, 505L, 641L, 581L, 520L, 485L,
          517L, 622L, 510L, 458L, 558L, 638L, 483L, 538L, 577L, 600L,
          452L, 547L, 510L, 663L, 470L, 503L, 600L, 517L, 510L, 458L,
          558L, 638L, 483L, 538L, 577L, 600L, 452L, 547L, 510L, 663L,
          470L, 503L, 600L, 517L), F0 = c(196L, 204L, 204L, 197L, 203L,
          216L, 208L, 223L, 213L, 219L, 196L, 202L, 205L, 202L, 208L,
          205L, 206L, 197L, 202L, 195L, 200L, 201L, 210L, 202L, 208L,
          195L, 196L, 195L, 205L, 208L, 203L, 203L, 212L, 213L, 210L,
          206L, 204L, 196L, 204L, 204L, 197L, 203L, 201L, 198L, 199L,
          203L, 196L, 202L, 205L, 202L, 193L, 195L, 208L, 197L, 202L,
          195L, 200L, 201L, 195L, 205L, 202L, 195L, 196L, 195L, 196L,
          204L, 204L, 197L, 203L, 216L, 208L, 223L, 213L, 219L, 196L,
          202L, 205L, 202L, 208L, 205L, 206L, 197L, 202L, 195L, 200L,
          201L, 210L, 202L, 208L, 195L, 196L, 195L, 205L, 208L, 203L,
          203L, 212L, 213L, 210L, 206L, 204L, 196L, 204L, 204L, 197L,
          203L, 201L, 198L, 199L, 203L, 196L, 202L, 205L, 202L, 193L,
          195L, 208L, 197L, 202L, 195L, 200L, 201L, 195L, 205L, 202L,
          195L, 196L, 195L, 215L, 219L, 219L, 220L, 199L, 202L, 202L,
          204L, 224L, 231L, 238L, 240L, 217L, 212L, 210L, 208L, 215L,
          219L, 219L, 220L, 199L, 202L, 202L, 204L, 224L, 231L, 238L,
          240L, 217L, 212L, 210L, 208L, 230L, 223L, 219L, 221L, 199L,
          200L, 204L, 210L, 215L, 219L, 219L, 220L, 199L, 202L, 202L,
          204L, 230L, 223L, 219L, 221L, 199L, 200L, 204L, 210L, 215L,
          219L, 219L, 220L, 199L, 202L, 202L, 204L), F1 = c(576L, 553L,
          579L, 586L, 601L, 398L, 390L, 398L, 389L, 404L, 587L, 560L,
          562L, 553L, 393L, 397L, 382L, 553L, 592L, 556L, 571L, 387L,
          392L, 398L, 400L, 580L, 580L, 554L, 403L, 391L, 388L, 393L,
          382L, 375L, 384L, 392L, 388L, 576L, 553L, 579L, 586L, 601L,
          387L, 393L, 402L, 406L, 587L, 560L, 562L, 553L, 388L, 391L,
          412L, 553L, 592L, 556L, 571L, 410L, 404L, 401L, 420L, 580L,
          580L, 554L, 576L, 553L, 579L, 586L, 601L, 398L, 390L, 398L,
          389L, 404L, 587L, 560L, 562L, 553L, 393L, 397L, 382L, 553L,
          592L, 556L, 571L, 387L, 392L, 398L, 400L, 580L, 580L, 554L,
          403L, 391L, 388L, 393L, 382L, 375L, 384L, 392L, 388L, 576L,
          553L, 579L, 586L, 601L, 387L, 393L, 402L, 406L, 587L, 560L,
          562L, 553L, 388L, 391L, 412L, 553L, 592L, 556L, 571L, 410L,
          404L, 401L, 420L, 580L, 580L, 554L, 620L, 630L, 602L, 605L,
          571L, 573L, 560L, 553L, 434L, 417L, 306L, 319L, 414L, 419L,
          392L, 391L, 620L, 630L, 602L, 605L, 571L, 573L, 560L, 553L,
          434L, 417L, 306L, 319L, 414L, 419L, 392L, 391L, 448L, 441L,
          293L, 291L, 420L, 420L, 388L, 384L, 620L, 630L, 602L, 605L,
          571L, 573L, 560L, 553L, 448L, 441L, 293L, 291L, 420L, 420L,
          388L, 384L, 620L, 630L, 602L, 605L, 571L, 573L, 560L, 553L
          ), F2 = c(1339L, 1381L, 1381L, 1347L, 1394L, 1484L, 1521L,
          1539L, 1430L, 1454L, 1353L, 1378L, 1325L, 1357L, 1424L, 1563L,
          1578L, 1350L, 1397L, 1273L, 1319L, 1548L, 1452L, 1499L, 1515L,
          1358L, 1347L, 1248L, 1575L, 1438L, 1414L, 1548L, 3001L, 2916L,
          2948L, 2973L, 2947L, 1339L, 1381L, 1381L, 1347L, 1394L, 2943L,
          2913L, 2987L, 2940L, 1353L, 1378L, 1325L, 1357L, 3010L, 3008L,
          2972L, 1350L, 1397L, 1273L, 1319L, 2963L, 2991L, 3007L, 2989L,
          1358L, 1347L, 1248L, 1339L, 1381L, 1381L, 1347L, 1394L, 1484L,
          1521L, 1539L, 1430L, 1454L, 1353L, 1378L, 1325L, 1357L, 1424L,
          1563L, 1578L, 1350L, 1397L, 1273L, 1319L, 1548L, 1452L, 1499L,
          1515L, 1358L, 1347L, 1248L, 1575L, 1438L, 1414L, 1548L, 3001L,
          2916L, 2948L, 2973L, 2947L, 1339L, 1381L, 1381L, 1347L, 1394L,
          2943L, 2913L, 2987L, 2940L, 1353L, 1378L, 1325L, 1357L, 3010L,
          3008L, 2972L, 1350L, 1397L, 1273L, 1319L, 2963L, 2991L, 3007L,
          2989L, 1358L, 1347L, 1248L, 1247L, 1244L, 1293L, 1264L, 1348L,
          1354L, 1378L, 1381L, 1314L, 1233L, 1190L, 1208L, 1643L, 1659L,
          1452L, 1438L, 1247L, 1244L, 1293L, 1264L, 1348L, 1354L, 1378L,
          1381L, 1314L, 1233L, 1190L, 1208L, 1643L, 1659L, 1452L, 1438L,
          2837L, 2816L, 2780L, 2776L, 2684L, 2718L, 2947L, 2948L, 1247L,
          1244L, 1293L, 1264L, 1348L, 1354L, 1378L, 1381L, 2837L, 2816L,
          2780L, 2776L, 2684L, 2718L, 2947L, 2948L, 1247L, 1244L, 1293L,
          1264L, 1348L, 1354L, 1378L, 1381L), F3 = c(2831L, 2779L,
          2915L, 2875L, 2712L, 2730L, 2793L, 2779L, 2772L, 2692L, 2718L,
          2856L, 2674L, 2659L, 2717L, 2584L, 2829L, 2726L, 2685L, 2866L,
          2793L, 2614L, 2636L, 2907L, 2822L, 2932L, 2882L, 2882L, 2650L,
          2929L, 2809L, 2737L, 3623L, 3607L, 3584L, 3576L, 3680L, 2831L,
          2779L, 2915L, 2875L, 2712L, 3641L, 3590L, 3556L, 3584L, 2718L,
          2856L, 2674L, 2659L, 3640L, 3656L, 3686L, 2726L, 2685L, 2866L,
          2793L, 3516L, 3552L, 3513L, 3579L, 2932L, 2882L, 2882L, 2831L,
          2779L, 2915L, 2875L, 2712L, 2730L, 2793L, 2779L, 2772L, 2692L,
          2718L, 2856L, 2674L, 2659L, 2717L, 2584L, 2829L, 2726L, 2685L,
          2866L, 2793L, 2614L, 2636L, 2907L, 2822L, 2932L, 2882L, 2882L,
          2650L, 2929L, 2809L, 2737L, 3623L, 3607L, 3584L, 3576L, 3680L,
          2831L, 2779L, 2915L, 2875L, 2712L, 3641L, 3590L, 3556L, 3584L,
          2718L, 2856L, 2674L, 2659L, 3640L, 3656L, 3686L, 2726L, 2685L,
          2866L, 2793L, 3516L, 3552L, 3513L, 3579L, 2932L, 2882L, 2882L,
          2711L, 3129L, 2786L, 2833L, 2754L, 2771L, 2856L, 2779L, 2909L,
          2750L, 2866L, 2863L, 2804L, 2704L, 2636L, 2929L, 2711L, 3129L,
          2786L, 2833L, 2754L, 2771L, 2856L, 2779L, 2909L, 2750L, 2866L,
          2863L, 2804L, 2704L, 2636L, 2929L, 3226L, 3121L, 3867L, 3319L,
          3426L, 3269L, 3680L, 3357L, 2711L, 3129L, 2786L, 2833L, 2754L,
          2771L, 2856L, 2779L, 3226L, 3121L, 3867L, 3319L, 3426L, 3269L,
          3680L, 3357L, 2711L, 3129L, 2786L, 2833L, 2754L, 2771L, 2856L,
          2779L), Word = structure(c(2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L,
          4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L,
          4L, 4L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 2L,
          2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
          2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 2L, 2L,
          2L, 2L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 1L, 1L,
          1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
          2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
          3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L), .Label = c("heed", "hoed", "hoed ", "whod"
          ), class = "factor"), Vowel = structure(c(2L, 2L, 2L, 2L,
          2L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 2L, 2L,
          2L, 2L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 1L, 1L,
          1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
          2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 4L,
          4L, 4L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 4L, 4L,
          4L, 4L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
          1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
          1L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("i", "o", "o ",
          "u"), class = "factor"), F1.Mean = c(564L, 564L, 564L, 564L,
          564L, 394L, 394L, 394L, 394L, 394L, 564L, 564L, 564L, 564L,
          394L, 394L, 394L, 564L, 564L, 564L, 564L, 394L, 394L, 394L,
          394L, 564L, 564L, 564L, 394L, 394L, 394L, 394L, 398L, 398L,
          398L, 398L, 398L, 564L, 564L, 564L, 564L, 564L, 398L, 398L,
          398L, 398L, 564L, 564L, 564L, 564L, 398L, 398L, 398L, 564L,
          564L, 564L, 564L, 398L, 398L, 398L, 398L, 564L, 564L, 564L,
          564L, 564L, 564L, 564L, 564L, 394L, 394L, 394L, 394L, 394L,
          564L, 564L, 564L, 564L, 394L, 394L, 394L, 564L, 564L, 564L,
          564L, 394L, 394L, 394L, 394L, 564L, 564L, 564L, 394L, 394L,
          394L, 394L, 398L, 398L, 398L, 398L, 398L, 564L, 564L, 564L,
          564L, 564L, 398L, 398L, 398L, 398L, 564L, 564L, 564L, 564L,
          398L, 398L, 398L, 564L, 564L, 564L, 564L, 398L, 398L, 398L,
          398L, 564L, 564L, 564L, 627L, 627L, 614L, 614L, 614L, 614L,
          566L, 566L, 432L, 432L, 327L, 327L, 415L, 415L, 393L, 393L,
          627L, 627L, 614L, 614L, 614L, 614L, 566L, 566L, 432L, 432L,
          327L, 327L, 415L, 415L, 393L, 393L, 397L, 397L, 292L, 292L,
          417L, 417L, 398L, 398L, 627L, 627L, 614L, 614L, 614L, 614L,
          566L, 566L, 397L, 397L, 292L, 292L, 417L, 417L, 398L, 398L,
          627L, 627L, 614L, 614L, 614L, 614L, 566L, 566L), F2.Mean = c(1328L,
          1328L, 1328L, 1328L, 1328L, 1496L, 1496L, 1496L, 1496L, 1496L,
          1328L, 1328L, 1328L, 1328L, 1496L, 1496L, 1496L, 1328L, 1328L,
          1328L, 1328L, 1496L, 1496L, 1496L, 1496L, 1328L, 1328L, 1328L,
          1496L, 1496L, 1496L, 1496L, 2969L, 2969L, 2969L, 2969L, 2969L,
          1328L, 1328L, 1328L, 1328L, 1328L, 2969L, 2969L, 2969L, 2969L,
          1328L, 1328L, 1328L, 1328L, 2969L, 2969L, 2969L, 1328L, 1328L,
          1328L, 1328L, 2969L, 2969L, 2969L, 2969L, 1328L, 1328L, 1328L,
          1328L, 1328L, 1328L, 1328L, 1328L, 1496L, 1496L, 1496L, 1496L,
          1496L, 1328L, 1328L, 1328L, 1328L, 1496L, 1496L, 1496L, 1328L,
          1328L, 1328L, 1328L, 1496L, 1496L, 1496L, 1496L, 1328L, 1328L,
          1328L, 1496L, 1496L, 1496L, 1496L, 2969L, 2969L, 2969L, 2969L,
          2969L, 1328L, 1328L, 1328L, 1328L, 1328L, 2969L, 2969L, 2969L,
          2969L, 1328L, 1328L, 1328L, 1328L, 2969L, 2969L, 2969L, 1328L,
          1328L, 1328L, 1328L, 2969L, 2969L, 2969L, 2969L, 1328L, 1328L,
          1328L, 1250L, 1250L, 1247L, 1247L, 1247L, 1247L, 1357L, 1357L,
          1292L, 1292L, 1157L, 1157L, 1746L, 1746L, 1455L, 1455L, 1250L,
          1250L, 1247L, 1247L, 1247L, 1247L, 1357L, 1357L, 1292L, 1292L,
          1157L, 1157L, 1746L, 1746L, 1455L, 1455L, 2828L, 2828L, 2763L,
          2763L, 2721L, 2721L, 2969L, 2969L, 1250L, 1250L, 1247L, 1247L,
          1247L, 1247L, 1357L, 1357L, 2828L, 2828L, 2763L, 2763L, 2721L,
          2721L, 2969L, 2969L, 1250L, 1250L, 1247L, 1247L, 1247L, 1247L,
          1357L, 1357L), Distance = c(16L, 54L, 55L, 29L, 76L, 13L,
          25L, 43L, 66L, 43L, 34L, 50L, 4L, 31L, 72L, 67L, 83L, 25L,
          74L, 56L, 11L, 52L, 44L, 5L, 20L, 34L, 25L, 81L, 80L, 58L,
          82L, 52L, 36L, 58L, 25L, 7L, 24L, 16L, 54L, 55L, 29L, 76L,
          28L, 56L, 18L, 30L, 34L, 50L, 4L, 31L, 42L, 40L, 14L, 25L,
          74L, 56L, 11L, 13L, 23L, 38L, 30L, 34L, 25L, 81L, 16L, 54L,
          55L, 29L, 76L, 13L, 25L, 43L, 66L, 43L, 34L, 50L, 4L, 31L,
          72L, 67L, 83L, 25L, 74L, 56L, 11L, 52L, 44L, 5L, 20L, 34L,
          25L, 81L, 80L, 58L, 82L, 52L, 36L, 58L, 25L, 7L, 24L, 16L,
          54L, 55L, 29L, 76L, 28L, 56L, 18L, 30L, 34L, 50L, 4L, 31L,
          42L, 40L, 14L, 25L, 74L, 56L, 11L, 13L, 23L, 38L, 30L, 34L,
          25L, 81L, 8L, 7L, 48L, 19L, 110L, 115L, 22L, 27L, 22L, 61L,
          39L, 52L, 103L, 87L, 3L, 17L, 8L, 7L, 48L, 19L, 110L, 115L,
          22L, 27L, 22L, 61L, 39L, 52L, 103L, 87L, 3L, 17L, 52L, 46L,
          17L, 13L, 37L, 4L, 24L, 25L, 8L, 7L, 48L, 19L, 110L, 115L,
          22L, 27L, 52L, 46L, 17L, 13L, 37L, 4L, 24L, 25L, 8L, 7L,
          48L, 19L, 110L, 115L, 22L, 27L), Included = 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, 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, 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, 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 = "Yes", class = "factor"),
          Talker = structure(c(4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
          4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L,
          1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L,
          1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L,
          4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L,
          4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L,
          3L, 4L, 4L), .Label = c("T1 ", "T2", "T3", "T4"), class = "factor"),
          Ambiguity = 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, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 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, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 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, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L), .Label = c("High", "Low"), class = "factor"),
          Variability = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
          1L, 1L, 1L, 1L), .Label = c("Mixed", "Single"), class = "factor"),
          Consistency = 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, 1L, 1L, 1L,
          1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
          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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
          1L, 1L, 1L, 1L), .Label = c("Consistent", "Inconsistent"), class = "factor"),
          Fake = c(477, 497, 560, 543, 549, 466, 486, 516, 525, 534,
          496, 580, 587, 557, 517, 563, 524, 546, 547, 596, 632, 544,
          497, 592, 544, 612, 642, 545, 574, 602, 532, 522, 519, 534,
          580, 587, 557, 477, 497, 560, 543, 549, 574, 543, 603, 582,
          496, 580, 587, 557, 511, 622, 604, 546, 547, 596, 632, 634,
          556, 536, 588, 612, 642, 545, 477, 497, 560, 543, 549, 466,
          486, 516, 525, 534, 496, 580, 587, 557, 517, 563, 524, 546,
          547, 596, 632, 544, 497, 592, 544, 612, 642, 545, 574, 602,
          532, 522, 519, 534, 580, 587, 557, 477, 497, 560, 543, 549,
          574, 543, 603, 582, 496, 580, 587, 557, 511, 622, 604, 546,
          547, 596, 632, 634, 556, 536, 588, 612, 642, 545, 452, 547,
          510, 663, 470, 503, 600, 517, 491, 505, 641, 581, 520, 485,
          517, 622, 452, 547, 510, 663, 470, 503, 600, 517, 491, 505,
          641, 581, 520, 485, 517, 622, 510, 458, 558, 638, 483, 538,
          577, 600, 452, 547, 510, 663, 470, 503, 600, 517, 510, 458,
          558, 638, 483, 538, 577, 600, 452, 547, 510, 663, 470, 503,
          600, 517), Check = c(20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
          20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0)), row.names = c(NA, -192L), class = "data.frame")

Body:
You can do this directly without using ifelse :

option1$Surgical <- with(option1, Duration - (20 *
                                  (Variability == 'Single' & Duration > 625)))

Here, we take advantage of the fact that

20 * TRUE #gives
#[1] 20

and

20 * FALSE #gives
#[1] 0

So whenever the condition (Variability == 'Single' & Duration > 625) is TRUE it subtracts 20 from Duration or else 0.


来源: stackexchange

答:
Not sure if that's exactly what you meant, since you did not specify if you're interested in bins of 15 min from midnight or from the beginning of the dataset, but here's something that I think would work:

I generated random dates in some range (to have something to bin) using that answer.

```<code>import pandas as pd
import numpy as np

# Make some fake data
def random_date_generator(start_date, range_in_days):
    days_to_add = np.arange(0, range_in_days)
    random_date = np.datetime64(start_date) + np.random.choice(days_to_add)
    return random_date

data_length = 1000
date_col = [random_date_generator('1970-01-01 00:00:00', 100000) for dc in np.arange(data_length)]
count_col = np.random.randint(5, size = data_length)

# Sample:
df = pd.DataFrame({'login_time':date_col, 'counts': count_col})
df = df.set_index(['login_time'])

df.resample('15T').count()
</code>```

ContentLicense: CC BY-SA 4.0

Title: Time series data that needs to be sampled to every 15 minutes and plotted

Body:
I have a data frame that looks like this:

                 counts month
login_time
1970-03-14 17:45:52 3   Mar
1970-01-09 01:31:25 3   Jan
1970-04-12 04:03:15 3   Apr
1970-02-24 23:09:57 3   Feb
1970-04-04 01:17:40 3   Apr
1970-02-12 11:16:53 3   Feb
1970-03-17 01:01:39 3   Mar
1970-01-06 21:45:52 3   Jan
1970-03-29 03:24:57 3   Mar
1970-04-03 14:42:38 2   Apr

I would like to aggregate these login counts by 15 min intervals and then plot the results.

I tried the following:

df.groupby('login_time').resample('15min').count()

but the way it resamples doesn't seem correct

        counts  month
login_time  login_time
1970-01-01 20:12:16 1970-01-01 20:00:00 1   1
1970-01-01 20:13:18 1970-01-01 20:00:00 1   1
1970-01-01 20:16:10 1970-01-01 20:15:00 1   1
1970-01-01 20:16:36 1970-01-01 20:15:00 1   1
1970-01-01 20:16:37 1970-01-01 20:15:00 1   1
1970-01-01 20:21:41 1970-01-01 20:15:00 1   1
1970-01-01 20:26:05 1970-01-01 20:15:00 1   1
1970-01-01 20:26:21 1970-01-01 20:15:00 1   1
1970-01-01 20:31:03 1970-01-01 20:30:00 1   1
1970-01-01 20:34:46 1970-01-01 20:30:00 1   1

Thank you!

Body:
Not sure if that's exactly what you meant, since you did not specify if you're interested in bins of 15 min from midnight or from the beginning of the dataset, but here's something that I think would work:

I generated random dates in some range (to have something to bin) using that answer.

import pandas as pd
import numpy as np

# Make some fake data
def random_date_generator(start_date, range_in_days):
    days_to_add = np.arange(0, range_in_days)
    random_date = np.datetime64(start_date) + np.random.choice(days_to_add)
    return random_date

data_length = 1000
date_col = [random_date_generator('1970-01-01 00:00:00', 100000) for dc in np.arange(data_length)]
count_col = np.random.randint(5, size = data_length)

# Sample:
df = pd.DataFrame({'login_time':date_col, 'counts': count_col})
df = df.set_index(['login_time'])

df.resample('15T').count()


问:
How to write a Celery group or chain using transaction.on_commit
I am using django 3.0.2, python 3.6.6, celery 4.3.0, and redis server 4.0.9. I want to create some chains and groups of tasks that run after the model has been saved (transaction.on_commit). I can make an individual task work this way, but I can't seem to devine the correct incantation to make a group or chain use transaction.on_commit.

Sidebar: I extended the celery Task class to "hide" the lamba stuff when using transaction.on_commit because I always had to look up the correct format - see https://browniebroke.com/making-celery-work-nicely-with-django-transactions/ for the details. In my code, I use task.delay_on_commit to replace the transaction.on_commit and lambda.

Back to the main story. I tried this code, and it failed saying the the object query in my tasks did not exist.

```<code>jobs = group(tasks.clean_document_image.delay_on_commit(self.document_id, key, values[key]) for key in values).apply_async()
</code>```

clean_document_image takes an uploaded image (the document_id object's FileField) and creates several copies of the image in different sizes (the key in the values dictionary is the width of the copy, and the value in the values dictionary is just the string name of the size - e.g., thumb, xsmall, xxxlarge, etc.). Notice that I tried to delay each of the elements of the group until the transaction saving the FileField compeleted.

When I run this "emulation" of a group, it works as expected, the object with the FileField has been saved and the lookup with the document_i works.

```<code>for key in values:
    tasks.clean_document_image.delay_on_commit(self.document_id, key, values[key])
</code>```

What is the rght way to create a group of tasks that don't start until the django object has been saved? In other words, how do I incorporate transaction.on_commit into a group of tasks?

Thanks!

Mark

答:
I have found that this works:

```<code>from django.db import transaction
transaction.on_commit(lambda: chain(task1.si(args),
                                    task2.si(args),
                                    task3.si(args)).delay())
</code>```

The .si is for tasks that do not return a value as input for the next task in the chain. If you want the output of task1 to be used by task2, then use task1.s(args). The first argument for task2 has to be the output value of task1.

Body:
I am using django 3.0.2, python 3.6.6, celery 4.3.0, and redis server 4.0.9. I want to create some chains and groups of tasks that run after the model has been saved (transaction.on_commit). I can make an individual task work this way, but I can't seem to devine the correct incantation to make a group or chain use transaction.on_commit.

Sidebar: I extended the celery Task class to "hide" the lamba stuff when using transaction.on_commit because I always had to look up the correct format - see https://browniebroke.com/making-celery-work-nicely-with-django-transactions/ for the details. In my code, I use task.delay_on_commit to replace the transaction.on_commit and lambda.

Back to the main story. I tried this code, and it failed saying the the object query in my tasks did not exist.

jobs = group(tasks.clean_document_image.delay_on_commit(self.document_id, key, values[key]) for key in values).apply_async()

clean_document_image takes an uploaded image (the document_id object's FileField) and creates several copies of the image in different sizes (the key in the values dictionary is the width of the copy, and the value in the values dictionary is just the string name of the size - e.g., thumb, xsmall, xxxlarge, etc.). Notice that I tried to delay each of the elements of the group until the transaction saving the FileField compeleted.

When I run this "emulation" of a group, it works as expected, the object with the FileField has been saved and the lookup with the document_i works.

for key in values:
    tasks.clean_document_image.delay_on_commit(self.document_id, key, values[key])

What is the rght way to create a group of tasks that don't start until the django object has been saved? In other words, how do I incorporate transaction.on_commit into a group of tasks?

Thanks!

Mark

Body:
I have found that this works:

from django.db import transaction
transaction.on_commit(lambda: chain(task1.si(args),
                                    task2.si(args),
                                    task3.si(args)).delay())

The .si is for tasks that do not return a value as input for the next task in the chain. If you want the output of task1 to be used by task2, then use task1.s(args). The first argument for task2 has to be the output value of task1.


问:
How to receive data MQTT on AWS
I have an external service that sends me data via MQTT. I need to receive this data on AWS then process it and then write it to an RDS instance. What services are recommended for this purpose? An Amazon MQ and a Lambda? A SQS and a Lambda? Any other?

Thanks for any help.

答:
AWS IoT 'things' have a Message Broker that supports MQTT.

Traditionally, IoT and MQTT involves huge numbers of messages, which are normally stored in DynamoDB. However, you could write an AWS Lambda function to store the received messages in an Amazon RDS database.

Title: How to receive data MQTT on AWS


问:
What does "at" mean in distributed system?
at means what in distributed system?
tcc means try confirm cancel
distributed system module acid, basic,soga,I know acid is database`s concept,and I meet at module,I can not know it,any one can help me ?</p>

答: Solely based on the topic being distributed systems, AT might stand for Atomic Transactions, although its hard to tell from the information you provided.


问:
Move Directory to Google Bucket
How can we move entire folder(within folder have many sub directory too) to Bucket of google cloud? Can anyone help on this.</p>

答:
Use -r flag in gsutil copy command.

From gsutil documentation:

If you want to copy an entire directory tree you need to use the -r option. For example, to upload the directory tree "dir":

```<code>gsutil cp -r mydir gs://my-bucket
</code>```

Title: Move Directory to Google Bucket

Body:
Use -r flag in gsutil copy command.

From gsutil documentation:

If you want to copy an entire directory tree you need to use the -r option. For example, to upload the directory tree "dir":

gsutil cp -r mydir gs://my-bucket


问:
How to validate GUID is a GUID
How to determine if a string contains a GUID vs just a string of numbers.

will a GUID always contain at least 1 alpha character?

答:
A GUID is a 16-byte (128-bit) number, typically represented by a 32-character hexadecimal string.  A GUID (in hex form) need not contain any alpha characters, though by chance it probably would.  If you are targeting a GUID in hex form, you can check that the string is 32-characters long (after stripping dashes and curly brackets) and has only letters A-F and numbers.

There is certain style of presenting GUIDs (dash-placement) and regular expressions can be used to check for this, e.g.,

```<code>@"^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$"
</code>```

from http://www.geekzilla.co.uk/view8AD536EF-BC0D-427F-9F15-3A1BC663848E.htm.  That said, it should be emphasized that the GUID really is a 128-bit number and could be represented in a number of different ways.

ContentLicense: CC BY-SA 3.0

Title: How to validate GUID is a GUID

Body:
A GUID is a 16-byte (128-bit) number, typically represented by a 32-character hexadecimal string.  A GUID (in hex form) need not contain any alpha characters, though by chance it probably would.  If you are targeting a GUID in hex form, you can check that the string is 32-characters long (after stripping dashes and curly brackets) and has only letters A-F and numbers.

There is certain style of presenting GUIDs (dash-placement) and regular expressions can be used to check for this, e.g.,

@"^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$"

from http://www.geekzilla.co.uk/view8AD536EF-BC0D-427F-9F15-3A1BC663848E.htm.  That said, it should be emphasized that the GUID really is a 128-bit number and could be represented in a number of different ways.


问:
How to pass a parameter from blade template to controller
I'm working on a sage template on bedrock boilerplate,
which uses laravel blade and controller. I'm getting
posts data from WordPress API and displaying it by category.
This gets done on controller. I want to pass a parameter
on the blade template so controller knows which category
to retrieve. Here is the code.

```<code>public function getposts3($category = 2) {

        $args = array(
            'orderby' => 'title',
            'per_page' => 10,
            'categories' => $category,
            );

          $url = add_query_arg( $args, 'https://localhost/bedrock/web/index.php/wp-json/wp/v2/posts');

          $stuff = wp_remote_get($url, array('sslverify' => FALSE));

          $body = wp_remote_retrieve_body($stuff);

          $posts = json_decode($body);

          return $posts;
    }
</code>```
```<code>@foreach ($getposts3 as $post)
  <div class="w-1/2  bg-purple-light rounded m-auto mb-5">
    <h1>{{$post->title->rendered}}</h1>
    <div>{!!$post->content->rendered!!}</div>
  </div>
@endforeach
</code>```

I come from JavaScript so I tried doing $getposts3(3)
to pass the parameter but it doesn't work. What is
the correct way to do this?

Also I want to put a button that will change the parameter
and it should call the function again and reload all the posts
from the new category. How can I achieve this?

答:
Create a route for getposts3

```<code>function getposts3(Request $request) {
 // curl to wordpress api
 // you can get category id that client choosen from $request
 return response()->json($curlResponse);
}
</code>```

Then from client side you have to make an api call to getposts3 and append it to html body

Body:
I'm working on a sage template on bedrock boilerplate,
which uses laravel blade and controller. I'm getting
posts data from WordPress API and displaying it by category.
This gets done on controller. I want to pass a parameter
on the blade template so controller knows which category
to retrieve. Here is the code.

public function getposts3($category = 2) {

        $args = array(
            'orderby' => 'title',
            'per_page' => 10,
            'categories' => $category,
            );

          $url = add_query_arg( $args, 'https://localhost/bedrock/web/index.php/wp-json/wp/v2/posts');

          $stuff = wp_remote_get($url, array('sslverify' => FALSE));

          $body = wp_remote_retrieve_body($stuff);

          $posts = json_decode($body);

          return $posts;
    }

@foreach ($getposts3 as $post)

{{$post->title->rendered}}

{!!$post->content->rendered!!}

@endforeach

I come from JavaScript so I tried doing $getposts3(3)
to pass the parameter but it doesn't work. What is
the correct way to do this?

Also I want to put a button that will change the parameter
and it should call the function again and reload all the posts
from the new category. How can I achieve this?

Body:
Create a route for getposts3

function getposts3(Request $request) {
 // curl to wordpress api
 // you can get category id that client choosen from $request
 return response()->json($curlResponse);
}

Then from client side you have to make an api call to getposts3 and append it to html body


问:
Define a mathematical function recursively
I have a mathematical function of integer division by 5

intDivByFive(N) = N/5

I have been told to define it recursively.

Can someone explain what exactly is it that I'm being asked to do here?

答:
I am assuming that you want to compute N/5 recursively ... without using the / operator.  (This is unnecessary and impractical, but we can ignore that in this context.)

(Note in the rest of this answer I am renaming N to be D to align with the terminology used in the JLS.)

For the Euclidian definition of the division d / n, we need to find q and r such that d = q * n + r where 0 ≤ r < |n|.

Thus, for d / 5, q can be computed by the following:

```<code>   public int intDivByFive(int d) {
      if (d < 0)
          return intDivByFive(d + 5) - 1;
      else if (d >= 5)
          return intDivByFive(d - 5) + 1;
      else
          return 0;
   }
</code>```

The function above works by repeatedly adding or subtracting 5 and counting the number of times you do that.  Additions are negative counts.

In theory, this works for all integers.  In practice it will fail with a StackOverflowError if the magnitude of d is too large.  (Java does not do tail call optimization in any existing version, at time of writing.)

HOWEVER, that's not what / means in Java.  In fact the JLS definition for division is:

Integer division rounds toward 0. That is, the quotient produced for operands n and d that are integers after binary numeric promotion (§5.6.2) is an integer value q whose magnitude is as large as possible while satisfying |d ⋅ q| ≤ |n|. Moreover, q is positive when |n| ≥ |d| and n and d have the same sign, but q is negative when |n| ≥ |d| and n and d have opposite signs.

So the correct implementation for Java / semantics is:

```<code>  public int intDivByFive(int d) {
      if (d <= -5)
          return intDivByFive(d + 5) - 1;
      else if (n >= 5)
          return intDivByFive(d - 5) + 1;
      else
          return 0;
   }
</code>```

We could debate endlessly which version is correct.  But it depends on what is meant by "the mathematical function of division by 5".  We don't have the context to determine that.

Since mathematicians normally1 take division to mean Euclidian division, I would argue that the first solution is more correct.  However, this is semantics.  The real point is that there are multiple different definitions of division.

1 - For example, my old copy of "Fundamentals of Abstract Algebra" by Neal H. McCoy (1972) uses the Euclidian definition but simply calls this division.

Body:
I am assuming that you want to compute N/5 recursively ... without using the / operator.  (This is unnecessary and impractical, but we can ignore that in this context.)

(Note in the rest of this answer I am renaming N to be D to align with the terminology used in the JLS.)

For the Euclidian definition of the division d / n, we need to find q and r such that d = q * n + r where 0 ≤ r < |n|.

Thus, for d / 5, q can be computed by the following:

   public int intDivByFive(int d) {
      if (d < 0)
          return intDivByFive(d + 5) - 1;
      else if (d >= 5)
          return intDivByFive(d - 5) + 1;
      else
          return 0;
   }

The function above works by repeatedly adding or subtracting 5 and counting the number of times you do that.  Additions are negative counts.

In theory, this works for all integers.  In practice it will fail with a StackOverflowError if the magnitude of d is too large.  (Java does not do tail call optimization in any existing version, at time of writing.)

HOWEVER, that's not what / means in Java.  In fact the JLS definition for division is:

Integer division rounds toward 0. That is, the quotient produced for operands n and d that are integers after binary numeric promotion (§5.6.2) is an integer value q whose magnitude is as large as possible while satisfying |d ⋅ q| ≤ |n|. Moreover, q is positive when |n| ≥ |d| and n and d have the same sign, but q is negative when |n| ≥ |d| and n and d have opposite signs.

So the correct implementation for Java / semantics is:

  public int intDivByFive(int d) {
      if (d <= -5)
          return intDivByFive(d + 5) - 1;
      else if (n >= 5)
          return intDivByFive(d - 5) + 1;
      else
          return 0;
   }

We could debate endlessly which version is correct.  But it depends on what is meant by "the mathematical function of division by 5".  We don't have the context to determine that.

Since mathematicians normally1 take division to mean Euclidian division, I would argue that the first solution is more correct.  However, this is semantics.  The real point is that there are multiple different definitions of division.

1 - For example, my old copy of "Fundamentals of Abstract Algebra" by Neal H. McCoy (1972) uses the Euclidian definition but simply calls this division.


问:
R: formating a dataframe in two specific ways based on separation and matching
I have a df1 like this:

```<code>    A                 B
1 xxx      B2341; A3456
2 yyy B2341; CC6x; GG63
3 zzz              CC6X
4 www              GG63
5 kkk              5634
</code>```

To obtain df1, I use the following commands

```<code> df1 <- data.frame(A=c("xxx", "yyy", "zzz", "www", "kkk"), B=c("B2341; A3456", "B2341; CC6x; GG63", "CC6X", "GG63", "5634"))
</code>```

In step one, I want to separate all the items (separated by ; and a space) in column B to table like this.  As I want to do some analysis based on this table format.  However, since there are uneven items for each cells.  I would like to ask fo your help to get it done.

```<code>xxx B2341
xxx A3456
yyy B2341
yyy CC6X
yyy GG63
zzz CC6X
www GG63
kkk 5634
</code>```

In step two, I want to get a table based on the matching result of 2nd column of df2, i.e. both xxx and yyy got B2341 in 2nd column of df2.  yyy and zzz also got CC6X; yyy and www also got GG63.

So, I would like to have a df with two columns that show matching rows, such as:

```<code>xxx yyy
yyy zzz
yyy www
</code>```

Please kindly help to instruct how to get the two dataframes based on my df1 with R in a smarter way.  Thank you.

答:
Step One:

```<code>library(reshape)
x <- melt((strsplit(as.character(df1$B), "; ")))
x <- data.frame("A"=df1[x$L1,1],"B"=x$value)
</code>```

x:

```<code>  value L1 match
1 B2341  1   xxx
2 A3456  1   xxx
3 B2341  2   yyy
4  CC6x  2   yyy
5  GG63  2   yyy
6  CC6X  3   zzz
7  GG63  4   www
8  5634  5   kkk
</code>```

Step 2:

```<code>y <- unique(merge(x,x[duplicated(x$B),],by="B")[2:3])
y[y$A.x != y$A.y,]
</code>```

y:

```<code>  A.x A.y
1 xxx yyy
3 yyy www
</code>```

Note: step 2 doesn't come out exactly as you specified because I believe you mistyped "CC6X" as "CC6x", if you wanted it to ignore capitalization I would recommend  x$B <- tolower(x$B)

Body:
I have a df1 like this:

    A                 B
1 xxx      B2341; A3456
2 yyy B2341; CC6x; GG63
3 zzz              CC6X
4 www              GG63
5 kkk              5634

To obtain df1, I use the following commands

 df1 <- data.frame(A=c("xxx", "yyy", "zzz", "www", "kkk"), B=c("B2341; A3456", "B2341; CC6x; GG63", "CC6X", "GG63", "5634"))

In step one, I want to separate all the items (separated by ; and a space) in column B to table like this.  As I want to do some analysis based on this table format.  However, since there are uneven items for each cells.  I would like to ask fo your help to get it done.

xxx B2341
xxx A3456
yyy B2341
yyy CC6X
yyy GG63
zzz CC6X
www GG63
kkk 5634

In step two, I want to get a table based on the matching result of 2nd column of df2, i.e. both xxx and yyy got B2341 in 2nd column of df2.  yyy and zzz also got CC6X; yyy and www also got GG63.

So, I would like to have a df with two columns that show matching rows, such as:

xxx yyy
yyy zzz
yyy www

Please kindly help to instruct how to get the two dataframes based on my df1 with R in a smarter way.  Thank you.

Body:
Step One:

library(reshape)
x <- melt((strsplit(as.character(df1$B), "; ")))
x <- data.frame("A"=df1[x$L1,1],"B"=x$value)

x:

  value L1 match
1 B2341  1   xxx
2 A3456  1   xxx
3 B2341  2   yyy
4  CC6x  2   yyy
5  GG63  2   yyy
6  CC6X  3   zzz
7  GG63  4   www
8  5634  5   kkk

Step 2:

y <- unique(merge(x,x[duplicated(x$B),],by="B")[2:3])
y[y$A.x != y$A.y,]

y:

  A.x A.y
1 xxx yyy
3 yyy www

Note: step 2 doesn't come out exactly as you specified because I believe you mistyped "CC6X" as "CC6x", if you wanted it to ignore capitalization I would recommend  x$B <- tolower(x$B)


问:
Is there is Any possibility for Math.Ceiling Operator with two arguments?
I want an output of 14.45 and I have p = 14.445, if I use Output=Math.Round(p,2); I get the output of 14.44,

I couldn't able to use Math.Ceiling here because it consists of two arguments.

Is there is any way of getting output of 14.45?

答:
There is Math.Round with 3 parameters, that let's you pick how 5 is rounded, and you can get behaviour you want. Otherwise you can also do (Math.Floor(p * 100) + 1) / 100, but I suggest the Round :)

EDIT:
Code sample : Math.Round(p, precision, MidpointRounding.AwayFromZero)

But MidpointRounding.AwayFromZero is just a guess since, some other values of the MidpointRounding will also produce 14.45 from 14.445.


问:
Should I build the object in the constructor?
I have a class called book consists off the book name and List of chapters. I read the information about the chapters ( such as the chapters name, chapter number ... etc) from some txt file on the hard desktop.

The book object itself is meaningless without loading the chapters.
For best practices, should I write a build method and I build my object like the below ?

```<code>Book newBook = new Book(bookName).build();
</code>```

Where build has the logic of loading the file form hard disk and filling the chapters list, or I should just make this build method private and create an object like the below.

```<code>Book newBook = new Book(bookName);
</code>```

and inside the constructor of the book I should call the private method called build ?

答: Move reading the file part into a separate class. Inject an object of that class into the Book. This will allow you to separate your domain from the technical details of the I/O handling. In future if you decide to move the data to a DB you will only have to swap the dependency. Also, this will allow to mock out the I/O object for unit testing.</p>

Body:
I have a class called book consists off the book name and List of chapters. I read the information about the chapters ( such as the chapters name, chapter number ... etc) from some txt file on the hard desktop.

The book object itself is meaningless without loading the chapters.
For best practices, should I write a build method and I build my object like the below ?

Book newBook = new Book(bookName).build();

Where build has the logic of loading the file form hard disk and filling the chapters list, or I should just make this build method private and create an object like the below.

Book newBook = new Book(bookName);

and inside the constructor of the book I should call the private method called build ?


问:
SASS if custom field condition
I trying add scss rule based on ACF field (or any field or post) value, but not sucess. How can I achieve code like This:

```<code>$option = $the_field('custom_field_name');

.p {
if($option == "1"){ $color = "red";}
}
</code>```

Its possible in SASS?

答:
```<code> $type: audi;   //value you selected
p {
   @if $type == benz {
      color: red;
   } @else if $type == mahindra {
      color: blue;
   } @else if $type == audi {
      color: green;
   } @else {
      color: black;
   }
}
</code>```

Title: SASS if custom field condition

Body:
I trying add scss rule based on ACF field (or any field or post) value, but not sucess. How can I achieve code like This:

$option = $the_field('custom_field_name');

.p {
if($option == "1"){ $color = "red";}
}

Its possible in SASS?


问:
Python CSV to Array
Need some help pls. I have a csv file in the following format.
input.csv

```<code>Project1,folder1/file1,data
Project1,folder1/file2,data
Project1,folder1/file3,data
Project1,folder1/file4,data
Project1,folder2/file11,data
Project1,folder2/file42a,data
Project1,folder2/file42b,data
Project1,folder2/file42c,data
Project1,folder2/file42d,data
Project1,folder3/filec,data
Project1,folder3/fileb,data
Project1,folder3/filea,data
</code>```

Basically, ignore all columns except column #2. This column is like a directory tree, in the format <foldername> forwardslash <filename>. There is no header-row.

I wish Python ver 3x, to read this file and make this into an array in the following format. The input csv file is large and hence need an efficient way to this pls.

```<code>print(out_array)

'folder1/file1', 'folder1/file2', 'folder1/file3', 'folder1/file4'
'folder2/file11', 'folder2/file42a', 'folder2/file42b', 'folder2/file42c', 'folder2/file42d'
'folder3/filec', 'folder3/fileb', 'folder3/filea'
</code>```

Each folder is output on a new row. The input csv file, will not have the folder names jumbled up. Hence, all rows for folder1 will be together, and not mixed with others.

答:
If you can, use pandas. It should be efficient and fast enough for most of the cases.

```<code>import pandas as pd

df = pd.read_csv("filename.csv", usecols=[1], names=[0])
df[1] = df[0].str.split('/', expand=True)[0]
df.groupby(1)[0].apply(list).values
</code>```

Result:

```<code>array([list(['folder1/file1', 'folder1/file2', 'folder1/file3', 'folder1/file4']),
       list(['folder2/file11', 'folder2/file42a', 'folder2/file42b', 'folder2/file42c', 'folder2/file42d']),
       list(['folder3/filec', 'folder3/fileb', 'folder3/filea'])],
      dtype=object)
</code>```

usecols is basically to determine which columns to read. As you want to group by the folder, you split it and make a new column for folder. After that you group by the folder column to combine it into arrays. From there you can just get the values.

Title: Python CSV to Array

Body:
Need some help pls. I have a csv file in the following format.
input.csv

Project1,folder1/file1,data
Project1,folder1/file2,data
Project1,folder1/file3,data
Project1,folder1/file4,data
Project1,folder2/file11,data
Project1,folder2/file42a,data
Project1,folder2/file42b,data
Project1,folder2/file42c,data
Project1,folder2/file42d,data
Project1,folder3/filec,data
Project1,folder3/fileb,data
Project1,folder3/filea,data

Basically, ignore all columns except column #2. This column is like a directory tree, in the format <foldername> forwardslash <filename>. There is no header-row.

I wish Python ver 3x, to read this file and make this into an array in the following format. The input csv file is large and hence need an efficient way to this pls.

print(out_array)

'folder1/file1', 'folder1/file2', 'folder1/file3', 'folder1/file4'
'folder2/file11', 'folder2/file42a', 'folder2/file42b', 'folder2/file42c', 'folder2/file42d'
'folder3/filec', 'folder3/fileb', 'folder3/filea'

Each folder is output on a new row. The input csv file, will not have the folder names jumbled up. Hence, all rows for folder1 will be together, and not mixed with others.

Body:
If you can, use pandas. It should be efficient and fast enough for most of the cases.

import pandas as pd

df = pd.read_csv("filename.csv", usecols=[1], names=[0])
df[1] = df[0].str.split('/', expand=True)[0]
df.groupby(1)[0].apply(list).values

Result:

array([list(['folder1/file1', 'folder1/file2', 'folder1/file3', 'folder1/file4']),
       list(['folder2/file11', 'folder2/file42a', 'folder2/file42b', 'folder2/file42c', 'folder2/file42d']),
       list(['folder3/filec', 'folder3/fileb', 'folder3/filea'])],
      dtype=object)

usecols is basically to determine which columns to read. As you want to group by the folder, you split it and make a new column for folder. After that you group by the folder column to combine it into arrays. From there you can just get the values.


答:
As I said, it's unnecessary to make basic arithmetic operation a recursive function.

If you want a recursive function f(n) that gives the same result as n/5, you can use something like this:

```<code>int divByFive(int n) {
    if(n > -5 && n < 5) {
        return 0;
    }
    if(n > 0) {
        return 1 + divByFive(n - 5);
    } else {
        return -1 + divByFive(n + 5);
    }
}
</code>```

Just add or subtract 5 until you reach 0 (or close to 0).

Title: Define a mathematical function recursively

Body:
I have a mathematical function of integer division by 5

intDivByFive(N) = N/5

I have been told to define it recursively.

Can someone explain what exactly is it that I'm being asked to do here?

Body:
As I said, it's unnecessary to make basic arithmetic operation a recursive function.

If you want a recursive function f(n) that gives the same result as n/5, you can use something like this:

int divByFive(int n) {
    if(n > -5 && n < 5) {
        return 0;
    }
    if(n > 0) {
        return 1 + divByFive(n - 5);
    } else {
        return -1 + divByFive(n + 5);
    }
}

Just add or subtract 5 until you reach 0 (or close to 0).


问:
Map column names from a datatable to another datatable in C#
I would like to map a datatable column names from another datatable. Please refer below example. I have 2 datatables returned from database.

Please see above 2 tables. The first table contains data and second datatable contains column mapping.
I would like to map column names from second table to first table. The final result should be as below.

答:
You can generate a SQL statement dynamically and end up with:</p>

```<code>Select column1 as city, column2 as country,
column3 as population, column4 as tourist
from whatever_table
</code>```

Body:
You can generate a SQL statement dynamically and end up with:

Select column1 as city, column2 as country,
column3 as population, column4 as tourist
from whatever_table


问:
Create two dataframes from two dataframes based on multiindex in one dataframe and columns in another dataframe
I m not sure if this has been answered before. But my requirement is that
I have a dataframe like this:

df1:

```<code>         A  B
I1 I2

x11 x12  a11 b11
x12 x22  a21 b21
</code>```

Note that this has multiindex of [I1, I2] and columns [A, B]

and then another dataframe like this:

df2:

```<code>    I1   I2
  0  x11  x12
  1  y11  y12
</code>```

This has columns [I1, I2] which is the same as multiindex of df1.

Now what I would like to create is two dataframes like below:

df3 which has rows for which the index in df1 matches to that of column values in df2

```<code>A  B
a11 b11
</code>```

df4 with the remaining i.e.

```<code>A  B
a21 b21
</code>```

I know how to do this using iterrows() but it is not efficient. Looking for a vectorized solution. Thanks.

答:
Let us try reset_index with merge

```<code>df3=df1.reset_index().merge(df2).set_index(['I1','I2'])
df4=df1.drop(df3.index)
</code>```

Or

```<code>idx=pd.MultiIndex.from_frame(df2)
df3=df1.reindex(idx).dropna()
df4=df1.drop(df3.index)
</code>```

Body:
I m not sure if this has been answered before. But my requirement is that
I have a dataframe like this:

df1:

         A  B
I1 I2

x11 x12  a11 b11
x12 x22  a21 b21

Note that this has multiindex of [I1, I2] and columns [A, B]

and then another dataframe like this:

df2:

    I1   I2
  0  x11  x12
  1  y11  y12

This has columns [I1, I2] which is the same as multiindex of df1.

Now what I would like to create is two dataframes like below:

df3 which has rows for which the index in df1 matches to that of column values in df2

A  B
a11 b11

df4 with the remaining i.e.

A  B
a21 b21

I know how to do this using iterrows() but it is not efficient. Looking for a vectorized solution. Thanks.

Body:
Let us try reset_index with merge

df3=df1.reset_index().merge(df2).set_index(['I1','I2'])
df4=df1.drop(df3.index)

Or

idx=pd.MultiIndex.from_frame(df2)
df3=df1.reindex(idx).dropna()
df4=df1.drop(df3.index)


问:
Problem with using node.js on VSC with Windows
My laptop is 64-bit operating system, Windows 10
I have installed Node.js for Windows (version v12.17.0)
I have installed code.runner on VSC as well

However, the error msg
"Command 'node' not found, but can be installed with:

sudo apt install nodejs"

keep appearing. I have no idea what is wrong.

Will changing the user settings or workspace settings help ?

答:
The problem is that you have not set the Path in the Environment Variables.
In Windows, search for "Environment Variables".

Open Environment Variables.Open Path and add the PATH : C:\Program Files\nodejs\bin

By default, the installer uses the Node.js distribution in C:\Program Files\nodejs. If node is installed in  C:\Program Files\nodejs directory, then add the PATH in  in window's PATH environment variable as C:\Program Files\nodejs\bin.

Restart any open command prompts for the change to take effect.


问:
Architecture for providing different linear algebra back-ends
I am prototyping a new system in Python; the functionality is mostly numerical.

An important requirement is the ability to use different linear algebra back-ends: from individual user implementations to generic libraries, such as Numpy. The linear algebra implementation (that is, the back-end) must be independent from the interface.

My initial architectural attempt is as follows:

(1) Define the system interface

```<code>>>> v1 = Vector([1,2,3])
>>> v2 = Vector([4,5,6])
>>> print v1 * v2
>>> # prints "Vector([4, 10, 18])"
</code>```

(2) Implement the code allowing to use that interface independently of the back-end

```<code># this example uses numpy as the back-end, but I mean
# to do this for a general back-end
import numpy
def numpy_array(*args): # creates a numpy array from the arguments
    return numpy.array(*args)

class VectorBase(type):
    def __init__(cls, name, bases, attrs):
        engine = attrs.pop("engine", None)
        if not engine:
            raise RuntimeError("you need to specify an engine")
        # this implementation would change depending on `engine`
        def new(cls, *args):
            return numpy_array(*args)
        setattr(cls, "new", classmethod(new))

class Vector(object):
    __metaclass__ = VectorBase
    # I could change this at run time
    # and offer alternative back-ends
    engine = "numpy"
    @classmethod
    def create(cls, v):
        nv = cls()
        nv._v = v
        return nv
    def __init__(self, *args):
        self._v = None
        if args:
            self._v = self.new(*args)
    def __repr__(self):
        l = [item for item in self._v]
        return "Vector(%s)" % repr(l)
    def __mul__(self, other):
        try:
            return Vector.create(self._v * other._v)
        except AttributeError:
            return Vector.create(self._v * other)
    def __rmul__(self, other):
        return self.__mul__(other)
</code>```

This simple example works as follows: the Vector class keeps a reference to a vector instance made by the back-end (numpy.ndarray in the example); all arithmetic calls are implemented by the interface, but their evaluation is deferred to the back-end.

In practice, the interface overloads all the appropriate operators and defers to the back-end (the example only shows __mul__ and __rmul__, but you can follow that the same would be done for every operation).

I am willing to loose some performance in exchange of customizability. Even while my example works, it does not feel right -- I would be crippling the back-end with so many constructor calls! This begs for a different metaclass implementation, allowing for a better call deferment.

So, how would you recommend that I implement this functionality? I need to stress the importance of keeping all of the system's Vector instances homogeneous and independent of the linear algebra back-end.

答:
You should check out PEP-3141 and the standard lib module ABCMeta.

For a detailed explanation of how to use ABCMeta, the always helpful PyMOTW has a nice write-up.

ContentLicense: CC BY-SA 2.5

Body:
I am prototyping a new system in Python; the functionality is mostly numerical.

An important requirement is the ability to use different linear algebra back-ends: from individual user implementations to generic libraries, such as Numpy. The linear algebra implementation (that is, the back-end) must be independent from the interface.

My initial architectural attempt is as follows:

(1) Define the system interface

>>> v1 = Vector([1,2,3])
>>> v2 = Vector([4,5,6])
>>> print v1 * v2
>>> # prints "Vector([4, 10, 18])"

(2) Implement the code allowing to use that interface independently of the back-end

# this example uses numpy as the back-end, but I mean
# to do this for a general back-end
import numpy
def numpy_array(*args): # creates a numpy array from the arguments
    return numpy.array(*args)

class VectorBase(type):
    def __init__(cls, name, bases, attrs):
        engine = attrs.pop("engine", None)
        if not engine:
            raise RuntimeError("you need to specify an engine")
        # this implementation would change depending on `engine`
        def new(cls, *args):
            return numpy_array(*args)
        setattr(cls, "new", classmethod(new))

class Vector(object):
    __metaclass__ = VectorBase
    # I could change this at run time
    # and offer alternative back-ends
    engine = "numpy"
    @classmethod
    def create(cls, v):
        nv = cls()
        nv._v = v
        return nv
    def __init__(self, *args):
        self._v = None
        if args:
            self._v = self.new(*args)
    def __repr__(self):
        l = [item for item in self._v]
        return "Vector(%s)" % repr(l)
    def __mul__(self, other):
        try:
            return Vector.create(self._v * other._v)
        except AttributeError:
            return Vector.create(self._v * other)
    def __rmul__(self, other):
        return self.__mul__(other)

This simple example works as follows: the Vector class keeps a reference to a vector instance made by the back-end (numpy.ndarray in the example); all arithmetic calls are implemented by the interface, but their evaluation is deferred to the back-end.

In practice, the interface overloads all the appropriate operators and defers to the back-end (the example only shows __mul__ and __rmul__, but you can follow that the same would be done for every operation).

I am willing to loose some performance in exchange of customizability. Even while my example works, it does not feel right -- I would be crippling the back-end with so many constructor calls! This begs for a different metaclass implementation, allowing for a better call deferment.

So, how would you recommend that I implement this functionality? I need to stress the importance of keeping all of the system's Vector instances homogeneous and independent of the linear algebra back-end.


问:
How can I generate a tsconfig.json file?
How can I generate a tsconfig.json via the command line?
I tried command tsc init, but this doesn't work.

答:
install TypeScript :

```<code>npm install typescript
</code>```

add tsc script to package.json:

```<code>"scripts": {
  "tsc": "tsc"
 },
</code>```

run this:

```<code>npx tsc --init
</code>```

Body:
install TypeScript :

npm install typescript

add tsc script to package.json:

"scripts": {
  "tsc": "tsc"
 },

run this:

npx tsc --init


问:
How to count correct answer only one time if I attempt many time correctly?
I am counting the correct answer for total 5 questions. If I am going to re-attempt the same question and get correct again, I shouldn't count it as correct again. I am writing code using javascript.

my code is like this, but if I re attempt same question correctly, my total score will add again.

```<code>var score = 0;

question1.addEventListener("click", () => {

    var firstQuestion = confirm("Is 10 < 20?");

    if (firstQuestion == true){
        score += 1;
        document.getElementById("answerQuestion1").innerHTML = `Correct`;
        document.getElementById("summary").innerHTML = `Your score is: ${score}`;
    }
    else{
        score = 0;
        document.getElementById("answerQuestion1").innerHTML = `Incorrect`;
        document.getElementById("summary").innerHTML = `Your score is: ${score}`;
    }
});
</code>```

答:
try this</p>

```<code>var score = 0
var firstattempt=true

question1.addEventListener("click", () => {

var firstQuestion = confirm("Is 10 < 20?");

                if (firstQuestion == true && firstattempt)
                {
                    score += 1;
                    document.getElementById("answerQuestion1").innerHTML = `Correct`;
                    document.getElementById("summary").innerHTML = `Your score is: ${score}`;
                }else
                {
                    score=0;
                    firstattempt=false
                    document.getElementById("answerQuestion1").innerHTML = `Incorrect`;
                    document.getElementById("summary").innerHTML = `Your score is: ${score}`;
                }

            });
</code>```

Body:
I am counting the correct answer for total 5 questions. If I am going to re-attempt the same question and get correct again, I shouldn't count it as correct again. I am writing code using javascript.

my code is like this, but if I re attempt same question correctly, my total score will add again.

var score = 0;

question1.addEventListener("click", () => {

    var firstQuestion = confirm("Is 10 < 20?");

    if (firstQuestion == true){
        score += 1;
        document.getElementById("answerQuestion1").innerHTML = `Correct`;
        document.getElementById("summary").innerHTML = `Your score is: ${score}`;
    }
    else{
        score = 0;
        document.getElementById("answerQuestion1").innerHTML = `Incorrect`;
        document.getElementById("summary").innerHTML = `Your score is: ${score}`;
    }
});

Body:
try this

var score = 0
var firstattempt=true

question1.addEventListener("click", () => {

var firstQuestion = confirm("Is 10 < 20?");

                if (firstQuestion == true && firstattempt)
                {
                    score += 1;
                    document.getElementById("answerQuestion1").innerHTML = `Correct`;
                    document.getElementById("summary").innerHTML = `Your score is: ${score}`;
                }else
                {
                    score=0;
                    firstattempt=false
                    document.getElementById("answerQuestion1").innerHTML = `Incorrect`;
                    document.getElementById("summary").innerHTML = `Your score is: ${score}`;
                }

            });


答:
see http://en.wikipedia.org/wiki/Globally_unique_identifier

There is no guarantee that an alpha will actually be there.

Title: How to validate GUID is a GUID

Body:
How to determine if a string contains a GUID vs just a string of numbers.

will a GUID always contain at least 1 alpha character?