问:
R apply function by factor
I have found a nice R function from here to get ROC curve x,y co-ords and stats (auc, p-value etc). which are returned as a list (2 data.frames)

```<code>rocdata <- function(grp, pred){
  # Produces x and y co-ordinates for ROC curve plot
  # Arguments: grp - labels classifying subject status
  #            pred - values of each observation
  # Output: List with 2 components:
  #         roc = data.frame with x and y co-ordinates of plot
  #         stats = data.frame containing: area under ROC curve, p value, upper and lower 95% confidence interval

  grp <- as.factor(grp)
  if (length(pred) != length(grp)) {
    stop("The number of classifiers must match the number of data points")
  }

  if (length(levels(grp)) != 2) {
    stop("There must only be 2 values for the classifier")
  }

  cut <- unique(pred)
  tp <- sapply(cut, function(x) length(which(pred > x & grp == levels(grp)[1])))
  fn <- sapply(cut, function(x) length(which(pred < x & grp == levels(grp)[1])))
  fp <- sapply(cut, function(x) length(which(pred > x & grp == levels(grp)[2])))
  tn <- sapply(cut, function(x) length(which(pred < x & grp == levels(grp)[2])))
  tpr <- tp / (tp + fn)
  fpr <- fp / (fp + tn)
  roc = data.frame(x = fpr, y = tpr)
  roc <- roc[order(roc$x, roc$y),]

  i <- 2:nrow(roc)
  auc <- (roc$x[i] - roc$x[i - 1]) %*% (roc$y[i] + roc$y[i - 1])/2

  pos <- pred[grp == levels(grp)[2]]
  neg <- pred[grp == levels(grp)[1]]
  q1 <- auc/(2-auc)
  q2 <- (2*auc^2)/(1+auc)
  se.auc <- sqrt(((auc * (1 - auc)) + ((length(pos) -1)*(q1 - auc^2)) + ((length(neg) -1)*(q2 - auc^2)))/(length(pos)*length(neg)))
  ci.upper <- auc + (se.auc * 0.96)
  ci.lower <- auc - (se.auc * 0.96)

  se.auc.null <- sqrt((1 + length(pos) + length(neg))/(12*length(pos)*length(neg)))
  z <- (auc - 0.5)/se.auc.null
  p <- 2*pnorm(-abs(z))

  stats <- data.frame (auc = auc,
                       p.value = p,
                       ci.upper = ci.upper,
                       ci.lower = ci.lower
                       )
  return (list(roc = roc, stats = stats))
}
</code>```

I would like to run this function on my data frame but first split the data frame into individual data frames according to factor variable (100%,75%,66%,50%,25%). i.e. I would like the ROC coords (data.frame) and stats data.frame for each factor or variable. I then plan to plot ROC curves for each factor(variable) which I know how to do.

I think the function as stands is probably fine for my purposes and I probably want to use ddply from plyr or one of the apply functions.

something like split_df <- ddply(jr_all_melt,.(variable), rocdata(jr_all_melt$Class, jr_all_melt$SBR))

which I would hope would return an roc and stat data.frame with an additional column variable. I know what I want to achieve, but in R I am permanently lost on how best to implement it.

The function works fine for complete dataset using rocdata(jr_all_melt$Class, jr_all_melt$SBR) but this includes all levels of variable. I want to split the results by variable and compare the ROC curves and stats.

```structure(list(Age = c(50.2916666666667, 50.2916666666667, 81.7666666666667,
81.7666666666667, 72.4333333333333, 72.4333333333333, 62.1916666666667,
62.1916666666667, 79.3694444444444, 79.3694444444444, 81.0583333333333,
81.0583333333333, 67.4194444444445, 67.4194444444445, 82.6361111111111,
82.6361111111111, 49.2638888888889, 49.2638888888889, 79.5416666666667,
79.5416666666667, 53.8833333333333, 53.8833333333333, 53.7416666666667,
53.7416666666667, 91.1, 91.1, 79.6138888888889, 79.6138888888889,
64.8388888888889, 64.8388888888889, 81.0444444444445, 81.0444444444445,
64.3305555555555, 64.3305555555555, 67.0083333333333, 67.0083333333333,
56.3972222222222, 56.3972222222222, 83.1777777777778, 83.1777777777778,
75.9027777777778, 75.9027777777778, 79.7944444444445, 79.7944444444445,
56.4277777777778, 56.4277777777778, 67.5083333333333, 67.5083333333333,
70.9888888888889, 70.9888888888889, 67.5805555555555, 67.5805555555555,
67.7388888888889, 67.7388888888889, 58.3083333333333, 58.3083333333333,
68.2805555555556, 68.2805555555556, 52.6055555555556, 52.6055555555556,
84.2861111111111, 84.2861111111111, 70.7861111111111, 70.7861111111111,
75.5222222222222, 75.5222222222222, 82.8361111111111, 82.8361111111111,
80.2361111111111, 80.2361111111111, 76.3888888888889, 76.3888888888889,
73.4, 73.4, 59.3055555555556, 59.3055555555556, 74.6972222222222,
74.6972222222222, 76.025, 76.025, 65.0944444444444, 65.0944444444444,
64.1888888888889, 61.9722222222222, 52.0472222222222, 64.8055555555556,
72.5083333333333, 83.0416666666667, 72.9, 68.9666666666667, 60.3694444444444,
80.3027777777778, 70.9333333333333, 68.4555555555555, 70.825,
73.9972222222222, 60.0916666666667, 77.2833333333333, 73.0722222222222,
66.4861111111111, 66.4777777777778, 41.7722222222222, 78.1861111111111,
74.8305555555555, 72.1638888888889, 71.725, 78.7416666666667,
65.0055555555556, 77.7083333333333, 54.1722222222222, 62.8583333333333,
73.0361111111111, 78.4944444444444, 77.4027777777778, 75.2472222222222,
68.475, 64.7222222222222, 81.1972222222222, 51.5861111111111,
60.8833333333333, 73.3972222222222, 76.8694444444444, 53.8805555555556,
63.3083333333333, 78.1083333333333, 78.4666666666667, 50.2916666666667,
50.2916666666667, 81.7666666666667, 81.7666666666667, 72.4333333333333,
72.4333333333333, 62.1916666666667, 62.1916666666667, 79.3694444444444,
79.3694444444444, 81.0583333333333, 81.0583333333333, 67.4194444444445,
67.4194444444445, 82.6361111111111, 82.6361111111111, 49.2638888888889,
49.2638888888889, 79.5416666666667, 79.5416666666667, 53.8833333333333,
53.8833333333333, 53.7416666666667, 53.7416666666667, 91.1, 91.1,
79.6138888888889, 79.6138888888889, 64.8388888888889, 64.8388888888889,
81.0444444444445, 81.0444444444445, 64.3305555555555, 64.3305555555555,
67.0083333333333, 67.0083333333333, 56.3972222222222, 56.3972222222222,
83.1777777777778, 83.1777777777778, 75.9027777777778, 75.9027777777778,
79.7944444444445, 79.7944444444445, 56.4277777777778, 56.4277777777778,
67.5083333333333, 67.5083333333333, 70.9888888888889, 70.9888888888889,
67.5805555555555, 67.5805555555555, 67.7388888888889, 67.7388888888889,
58.3083333333333, 58.3083333333333, 68.2805555555556, 68.2805555555556,
52.6055555555556, 52.6055555555556, 84.2861111111111, 84.2861111111111,
70.7861111111111, 70.7861111111111, 75.5222222222222, 75.5222222222222,
82.8361111111111, 82.8361111111111, 80.2361111111111, 80.2361111111111,
76.3888888888889, 76.3888888888889, 73.4, 73.4, 59.3055555555556,
59.3055555555556, 74.6972222222222, 74.6972222222222, 76.025,
76.025, 65.0944444444444, 65.0944444444444, 64.1888888888889,
61.9722222222222, 52.0472222222222, 64.8055555555556, 72.5083333333333,
83.0416666666667, 72.9, 68.9666666666667, 60.3694444444444, 80.3027777777778,
70.9333333333333, 68.4555555555555, 70.825, 73.9972222222222,
60.0916666666667, 77.2833333333333, 73.0722222222222, 66.4861111111111,
66.4777777777778, 41.7722222222222, 78.1861111111111, 74.8305555555555,
72.1638888888889, 71.725, 78.7416666666667, 65.0055555555556,
77.7083333333333, 54.1722222222222, 62.8583333333333, 73.0361111111111,
78.4944444444444, 77.4027777777778, 75.2472222222222, 68.475,
64.7222222222222, 81.1972222222222, 51.5861111111111, 60.8833333333333,
73.3972222222222, 76.8694444444444, 53.8805555555556, 63.3083333333333,
78.1083333333333, 78.4666666666667, 50.2916666666667, 50.2916666666667,
81.7666666666667, 81.7666666666667, 72.4333333333333, 72.4333333333333,
62.1916666666667, 62.1916666666667, 79.3694444444444, 79.3694444444444,
81.0583333333333, 81.0583333333333, 67.4194444444445, 67.4194444444445,
82.6361111111111, 82.6361111111111, 49.2638888888889, 49.2638888888889,
79.5416666666667, 79.5416666666667, 53.8833333333333, 53.8833333333333,
53.7416666666667, 53.7416666666667, 91.1, 91.1, 79.6138888888889,
79.6138888888889, 64.8388888888889, 64.8388888888889, 81.0444444444445,
81.0444444444445, 64.3305555555555, 64.3305555555555, 67.0083333333333,
67.0083333333333, 56.3972222222222, 56.3972222222222, 83.1777777777778,
83.1777777777778, 75.9027777777778, 75.9027777777778, 79.7944444444445,
79.7944444444445, 56.4277777777778, 56.4277777777778, 67.5083333333333,
67.5083333333333, 70.9888888888889, 70.9888888888889, 67.5805555555555,
67.5805555555555, 67.7388888888889, 67.7388888888889, 58.3083333333333,
58.3083333333333, 68.2805555555556, 68.2805555555556, 52.6055555555556,
52.6055555555556, 84.2861111111111, 84.2861111111111, 70.7861111111111,
70.7861111111111, 75.5222222222222, 75.5222222222222, 82.8361111111111,
82.8361111111111, 80.2361111111111, 80.2361111111111, 76.3888888888889,
76.3888888888889, 73.4, 73.4, 59.3055555555556, 59.3055555555556,
74.6972222222222, 74.6972222222222, 76.025, 76.025, 65.0944444444444,
65.0944444444444, 64.1888888888889, 61.9722222222222, 52.0472222222222,
64.8055555555556, 72.5083333333333, 83.0416666666667, 72.9, 68.9666666666667,
60.3694444444444, 80.3027777777778, 70.9333333333333, 68.4555555555555,
70.825, 73.9972222222222, 60.0916666666667, 77.2833333333333,
73.0722222222222, 66.4861111111111, 66.4777777777778, 41.7722222222222,
78.1861111111111, 74.8305555555555, 72.1638888888889, 71.725,
78.7416666666667, 65.0055555555556, 77.7083333333333, 54.1722222222222,
62.8583333333333, 73.0361111111111, 78.4944444444444, 77.4027777777778,
75.2472222222222, 68.475, 64.7222222222222, 81.1972222222222,
51.5861111111111, 60.8833333333333, 73.3972222222222, 76.8694444444444,
53.8805555555556, 63.3083333333333, 78.1083333333333, 78.4666666666667,
50.2916666666667, 50.2916666666667, 81.7666666666667, 81.7666666666667,
72.4333333333333, 72.4333333333333, 62.1916666666667, 62.1916666666667,
79.3694444444444, 79.3694444444444, 81.0583333333333, 81.0583333333333,
67.4194444444445, 67.4194444444445, 82.6361111111111, 82.6361111111111,
49.2638888888889, 49.2638888888889, 79.5416666666667, 79.5416666666667,
53.8833333333333, 53.8833333333333, 53.7416666666667, 53.7416666666667,
91.1, 91.1, 79.6138888888889, 79.6138888888889, 64.8388888888889,
64.8388888888889, 81.0444444444445, 81.0444444444445, 64.3305555555555,
64.3305555555555, 67.0083333333333, 67.0083333333333, 56.3972222222222,
56.3972222222222, 83.1777777777778, 83.1777777777778, 75.9027777777778,
75.9027777777778, 79.7944444444445, 79.7944444444445, 56.4277777777778,
56.4277777777778, 67.5083333333333, 67.5083333333333, 70.9888888888889,
70.9888888888889, 67.5805555555555, 67.5805555555555, 67.7388888888889,
67.7388888888889, 58.3083333333333, 58.3083333333333, 68.2805555555556,
68.2805555555556, 52.6055555555556, 52.6055555555556, 84.2861111111111,
84.2861111111111, 70.7861111111111, 70.7861111111111, 75.5222222222222,
75.5222222222222, 82.8361111111111, 82.8361111111111, 80.2361111111111,
80.2361111111111, 76.3888888888889, 76.3888888888889, 73.4, 73.4,
59.3055555555556, 59.3055555555556, 74.6972222222222, 74.6972222222222,
76.025, 76.025, 65.0944444444444, 65.0944444444444, 64.1888888888889,
61.9722222222222, 52.0472222222222, 64.8055555555556, 72.5083333333333,
83.0416666666667, 72.9, 68.9666666666667, 60.3694444444444, 80.3027777777778,
70.9333333333333, 68.4555555555555, 70.825, 73.9972222222222,
60.0916666666667, 77.2833333333333, 73.0722222222222, 66.4861111111111,
66.4777777777778, 41.7722222222222, 78.1861111111111, 74.8305555555555,
72.1638888888889, 71.725, 78.7416666666667, 65.0055555555556,
77.7083333333333, 54.1722222222222, 62.8583333333333, 73.0361111111111,
78.4944444444444, 77.4027777777778, 75.2472222222222, 68.475,
64.7222222222222, 81.1972222222222, 51.5861111111111, 60.8833333333333,
73.3972222222222, 76.8694444444444, 53.8805555555556, 63.3083333333333,
78.1083333333333, 78.4666666666667, 50.2916666666667, 50.2916666666667,
81.7666666666667, 81.7666666666667, 72.4333333333333, 72.4333333333333,
62.1916666666667, 62.1916666666667, 79.3694444444444, 79.3694444444444,
81.0583333333333, 81.0583333333333, 67.4194444444445, 67.4194444444445,
82.6361111111111, 82.6361111111111, 49.2638888888889, 49.2638888888889,
79.5416666666667, 79.5416666666667, 53.8833333333333, 53.8833333333333,
53.7416666666667, 53.7416666666667, 91.1, 91.1, 79.6138888888889,
79.6138888888889, 64.8388888888889, 64.8388888888889, 81.0444444444445,
81.0444444444445, 64.3305555555555, 64.3305555555555, 67.0083333333333,
67.0083333333333, 56.3972222222222, 56.3972222222222, 83.1777777777778,
83.1777777777778, 75.9027777777778, 75.9027777777778, 79.7944444444445,
79.7944444444445, 56.4277777777778, 56.4277777777778, 67.5083333333333,
67.5083333333333, 70.9888888888889, 70.9888888888889, 67.5805555555555,
67.5805555555555, 67.7388888888889, 67.7388888888889, 58.3083333333333,
58.3083333333333, 68.2805555555556, 68.2805555555556, 52.6055555555556,
52.6055555555556, 84.2861111111111, 84.2861111111111, 70.7861111111111,
70.7861111111111, 75.5222222222222, 75.5222222222222, 82.8361111111111,
82.8361111111111, 80.2361111111111, 80.2361111111111, 76.3888888888889,
76.3888888888889, 73.4, 73.4, 59.3055555555556, 59.3055555555556,
74.6972222222222, 74.6972222222222, 76.025, 76.025, 65.0944444444444,
65.0944444444444, 64.1888888888889, 61.9722222222222, 52.0472222222222,
64.8055555555556, 72.5083333333333, 83.0416666666667, 72.9, 68.9666666666667,
60.3694444444444, 80.3027777777778, 70.9333333333333, 68.4555555555555,
70.825, 73.9972222222222, 60.0916666666667, 77.2833333333333,
73.0722222222222, 66.4861111111111, 66.4777777777778, 41.7722222222222,
78.1861111111111, 74.8305555555555, 72.1638888888889, 71.725,
78.7416666666667, 65.0055555555556, 77.7083333333333, 54.1722222222222,
62.8583333333333, 73.0361111111111, 78.4944444444444, 77.4027777777778,
75.2472222222222, 68.475, 64.7222222222222, 81.1972222222222,
51.5861111111111, 60.8833333333333, 73.3972222222222, 76.8694444444444,
53.8805555555556, 63.3083333333333, 78.1083333333333, 78.4666666666667
), Sex = c("M", "M", "M", "M", "F", "F", "M", "M", "M", "M",
"M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F", "F", "M",
"M", "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M", "M",
"M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "F", "F", "F",
"F", "F", "F", "F", "F", "M", "M", "M", "M", "F", "F", "F", "F",
"M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M", "M",
"M", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M", "M", "F",
"M", "F", "M", "M", "M", "M", "M", "M", "F", "M", "M", "M", "F",
"M", "F", "M", "M", "M", "F", "M", "F", "F", "F", "M", "F", "M",
"M", "F", "F", "M", "F", "F", "M", "M", "M", "M", "F", "F", "M",
"M", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M",
"F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "F", "F", "F",
"F", "F", "F", "M", "M", "F", "F", "M", "M", "M", "M", "F", "F",
"M", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "F", "F",
"F", "M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F", "F",
"M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "F", "F", "F",
"F", "F", "F", "F", "M", "M", "M", "M", "F", "M", "F", "M", "M",
"M", "M", "M", "M", "F", "M", "M", "M", "F", "M", "F", "M", "M",
"M", "F", "M", "F", "F", "F", "M", "F", "M", "M", "F", "F", "M",
"F", "F", "M", "M", "M", "M", "F", "F", "M", "M", "M", "M", "F",
"F", "M", "M", "M", "M", "M", "M", "M", "M", "F", "F", "F", "F",
"M", "M", "F", "F", "M", "M", "F", "F", "F", "F", "F", "F", "M",
"M", "F", "F", "M", "M", "M", "M", "F", "F", "M", "M", "M", "M",
"M", "M", "F", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M",
"M", "F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "M", "M",
"M", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "F", "F",
"M", "M", "M", "M", "F", "M", "F", "M", "M", "M", "M", "M", "M",
"F", "M", "M", "M", "F", "M", "F", "M", "M", "M", "F", "M", "F",
"F", "F", "M", "F", "M", "M", "F", "F", "M", "F", "F", "M", "M",
"M", "M", "F", "F", "M", "M", "M", "M", "F", "F", "M", "M", "M",
"M", "M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F", "F",
"M", "M", "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M",
"M", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "F", "F",
"F", "F", "F", "F", "F", "F", "M", "M", "M", "M", "F", "F", "F",
"F", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M",
"M", "M", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M", "M",
"F", "M", "F", "M", "M", "M", "M", "M", "M", "F", "M", "M", "M",
"F", "M", "F", "M", "M", "M", "F", "M", "F", "F", "F", "M", "F",
"M", "M", "F", "F", "M", "F", "F", "M", "M", "M", "M", "F", "F",
"M", "M", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M",
"M", "F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "F", "F",
"F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "M", "M", "F",
"F", "M", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "F",
"F", "F", "M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F",
"F", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "F", "F",
"F", "F", "F", "F", "F", "M", "M", "M", "M", "F", "M", "F", "M",
"M", "M", "M", "M", "M", "F", "M", "M", "M", "F", "M", "F", "M",
"M", "M", "F", "M", "F", "F", "F", "M", "F", "M", "M", "F", "F",
"M", "F", "F", "M", "M", "M", "M", "F", "F"), Class = c(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, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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 10.491, 12.792,
13.091, 7.091, 7.082, 5.406, 5.044, 11.007, 11.679, 9.909, 10.501,
10.268, 9.312, 16.485, 16.838, 11.743, 9.811, 13.447, 13.355,
5.138, 5.475, 8.883, 8.323, 9.054, 9.72, 21.538, 23.007, 8.842,
9.027, 5.757, 4.229, 5.293, 5.56, 9.714, 9.559, 13.698, 13.965,
7.364, 9.345, 9.309, 9.641, 6.893, 5.765, 7.45, 7.414, 3.651,
3.594, 8.243, 9.381, 7.068, 6.376, 7.011, 8.016, 9.391, 8.884,
8.24, 8.142, 9.045, 8.306, 5.427, 6.813, 10.123, 12.302, 3.953,
9.049, 4.292, 4.182, 5.084, 1.839, 2.693, 3.541, 4.079, 5.09,
5.655, 2.735, 8.321, -0.761, 4.331, 3.822, 1.403, 8.115, 7.87,
8.127, 3.931, 7.447, 1.362, 4.431, -1.583, 6.545, 2.851, 4.957,
6.518, 5.894, 3.874, 8.008, 4.72, 7.651, 8.212, 6.915, 9.625,
7.094, 2.291, 8.13, 7.71, 6.319, 2.494, 2.002, 12.478, 13.372,
12.212, 12.551, 10.571, 11.693, 8.674, 6.894, 5.061, 7.714, 8.512,
8.35, 12.251, 12.375, 7.898, 6.654, 12.89, 12.83, 12.24, 10.638,
13.615, 13.877, 6.845, 7.28, 5.224, 4.883, 10.742, 11.542, 10.308,
10.896, 9.356, 11.338, 15.793, 16.179, 12.567, 11.429, 13.431,
13.99, 6.123, 5.167, 8.709, 7.829, 7.599, 8.454, 19.393, 20.918,
8.33, 9.136, 4.824, 3.95, 6.425, 6.67, 8.22, 7.626, 13.909, 13.971,
8.425, 8.845, 8.887, 9.942, 7.078, 5.547, 6.837, 6.094, 4.576,
4.528, 8.619, 10.478, 3.125, 3.382, 7.22, 8.293, 11.238, 10.548,
7.197, 7.097, 9.659, 8.863, 5.577, 6.025, 10.77, 11.954, 3.814,
9.114, 4.435, 3.592, 5.265, 1.093, 3.903, 3.581, 3.602, 4.468,
5.451, 1.995, 7.03, -0.539, 4.875, 3.812, 1.476, 8.107, 8.628,
9.107, 2.54, 6.902, 1.553, 5.64, -2.762, 6.625, 2.715, 5.475,
6.085, 6.385, 2.794, 7.813, 4.801, 5.883, 7.837, 4.8, 9.527,
8.804, 2.988, 5.729, 7.275, 8.683, 2.627, 1.882, 11.884, 12.791,
10.861, 9.382, 9.525, 10.237, 9.299, 7.338, 5.075, 7.583, 10.324,
9.143, 14.003, 12.861, 7.687, 6.719, 13.422, 13.595, 11.828,
10.943, 12.296, 12.836, 7.069, 7.523, 5.691, 5.309, 11.494, 12.253,
8.711, 8.991, 9.009, 8.809, 15.387, 15.631, 11.948, 12.295, 15.034,
13.889, 5.454, 6.518, 9.535, 8.777, 8.436, 8.396, 18.508, 20.444,
9.505, 8.998, 4.705, 3.47, 5.202, 4.86, 7.532, 7.451, 14.499,
14.114, 6.872, 9.877, 9.077, 9.33, 6.009, 4.583, 5.988, 6.252,
4.766, 4.273, 11.44, 10.971, 6.393, 5.551, 7.107, 6.959, 11.844,
10.795, 9.183, 8.909, 9.142, 7.753, 6.055, 7.152, 9.566, 11.637,
3.668, 8.697, 4.701, 3.218, 4.292, 0.273, 2.713, 3.579, 5.496,
6.322, 4.852, 3.553, 6.82, -0.745, 4.581, 4.12, 1.886, 7.633,
8.07, 8.381, 3.627, 7.156, 1.669, 2.754, -2.56, 5.437, 2.587,
4.361, 4.959, 4.653, 3.2, 7.943, 5.922, 6.379, 5.403, 4.698,
9.665, 6.82, 2.432, 8.587, 6.4, 6.454, 2.054, 0.999, 10.129,
11.129, 13.195, 11.133, 10.702, 12.333, 9.4, 7.665, 5.538, 8.751,
8.868, 8.25, 12.695, 12.2, 8.346, 6.802, 12.007, 11.245, 11.456,
9.58, 12.941, 12.826, 6.239, 6.829, 5.887, 4.896, 10.303, 11.478,
8.972, 9.636, 9.538, 8.34, 16.686, 16.453, 10.827, 8.923, 13.867,
13.964, 5.016, 5.51, 7.635, 7.577, 7.725, 9.532, 21.083, 21.567,
9.417, 8.435, 5.635, 4.206, 4.299, 6.018, 8.642, 8.961, 12.613,
12.665, 8.861, 10.567, 9.365, 9.341, 6.435, 5.435, 7.099, 7.285,
5.467, 4.823, 8.959, 10.568, 6.085, 4.575, 7.267, 8.206, 9.589,
9.242, 7.504, 7.43, 9.171, 7.967, 3.426, 5.843, 10.341, 12.598,
4.001, 9.796, 4.188, 5.943, 6.093, 0.063, 2.512, 3.094, 3.106,
5.35, 6.468, 3.677, 7.964, -0.355, 4.088, 3.271, 0.608, 7.864,
7.941, 7.409, 1.796, 6.667, 0.731, 5.275, -1.904, 5.552, 2.487,
4.371, 6.181, 6.772, 2.993, 7.824, 4.659, 5.242, 5.33, 5.572,
9.409, 6.97, 2.791, 7.5, 6.753, 6.453, 1.955, 1.61, 13.193, 13.31,
12.485, 9.241, 11.773, 12.114, 9.747, 6.474, 5.956, 9.922, 11.264,
10.741, 15.046, 14.575, 6.828, 5.505, 13.366, 12.29, 10.432,
10.353, 12.386, 11.557, 6.68, 7.691, 5.158, 5.553, 10.371, 11.818,
9.635, 9.746, 8.955, 7.844, 18.448, 17.837, 11.19, 11.44, 13.722,
13.807, 7.387, 6.504, 8.724, 8.63, 9.441, 11.918, 19.074, 21.111,
8.849, 8.582, 3.558, 3.453, 4.963, 5.903, 9.605, 9.247, 12.929,
14.318, 7.057, 8.258, 9.982, 9.598, 8.709, 6.397, 7.797, 5.743,
5.742, 5.503, 7.563, 8.864, 5.685, 5.297, 7.63, 7.469, 10.426,
9.266, 7.451, 7.535, 9.941, 8.376, 4.793, 5.155, 9.867, 12.821,
3.052, 5.617, 2.7, 4.793, 6.38, 0.828, 2.281, 2.713, 4.508, 5.245,
5.325, 3.849, 6.326, 0.197, 5.909, 3.548, 1.077, 8.596, 10.599,
6.268, 1.86, 7.651, 1.083, 4.869, -2.972, 4.83, 2.146, 5.991,
4.333, 7.388, 2.181, 6.888, 4.85, 5.289, 5.878, 4.706, 4.609,
6.398, 2.106, 10.709, 6.243, 7.267, 1.431, 1.706)), row.names = c(NA,
-630L), .Names = c("Age", "Sex", "Class", "variable", "SBR"), class = "data.frame")
```

答:
I have only been able to get the data in the desired format by manually splitting the data.frame running the function and combining back together. How do I do this in a tidier fashion?</p>

```<code>FullCount = jr_all_melt[jr_all_melt$variable=="100%",]
ThreeQuart = jr_all_melt[jr_all_melt$variable=="75%",]
TwoThird = jr_all_melt[jr_all_melt$variable=="66.6%",]
HalfCount = jr_all_melt[jr_all_melt$variable=="50%",]
OneQuart = jr_all_melt[jr_all_melt$variable=="25%",]

Full.ROC = rocdata(FullCount$Class,FullCount$SBR)
Full.ROC$roc$variable = "100%"
ThreeQuart.ROC = rocdata(ThreeQuart$Class,ThreeQuart$SBR)
ThreeQuart.ROC$roc$variable = "75%"
TwoThird.ROC = rocdata(TwoThird$Class,TwoThird$SBR)
TwoThird.ROC$roc$variable = "66.6%"
HalfCount.ROC = rocdata(HalfCount$Class,HalfCount$SBR)
HalfCount.ROC$roc$variable = "50%"
OneQuart.ROC = rocdata(OneQuart$Class,OneQuart$SBR)
OneQuart.ROC$roc$variable = "25%"

roc_all <- rbind(Full.ROC$roc,ThreeQuart.ROC$roc,TwoThird.ROC$roc,HalfCount.ROC$roc,OneQuart.ROC$roc)
stats_all <- rbind(stats_all, Full.ROC$stats,ThreeQuart.ROC$stats, TwoThird.ROC$stats, HalfCount.ROC$stats,OneQuart.ROC$stats)
</code>```

Title: R apply function by factor

Body:
I have found a nice R function from here to get ROC curve x,y co-ords and stats (auc, p-value etc). which are returned as a list (2 data.frames)

rocdata <- function(grp, pred){
  # Produces x and y co-ordinates for ROC curve plot
  # Arguments: grp - labels classifying subject status
  #            pred - values of each observation
  # Output: List with 2 components:
  #         roc = data.frame with x and y co-ordinates of plot
  #         stats = data.frame containing: area under ROC curve, p value, upper and lower 95% confidence interval

  grp <- as.factor(grp)
  if (length(pred) != length(grp)) {
    stop("The number of classifiers must match the number of data points")
  }

  if (length(levels(grp)) != 2) {
    stop("There must only be 2 values for the classifier")
  }

  cut <- unique(pred)
  tp <- sapply(cut, function(x) length(which(pred > x & grp == levels(grp)[1])))
  fn <- sapply(cut, function(x) length(which(pred < x & grp == levels(grp)[1])))
  fp <- sapply(cut, function(x) length(which(pred > x & grp == levels(grp)[2])))
  tn <- sapply(cut, function(x) length(which(pred < x & grp == levels(grp)[2])))
  tpr <- tp / (tp + fn)
  fpr <- fp / (fp + tn)
  roc = data.frame(x = fpr, y = tpr)
  roc <- roc[order(roc$x, roc$y),]

  i <- 2:nrow(roc)
  auc <- (roc$x[i] - roc$x[i - 1]) %*% (roc$y[i] + roc$y[i - 1])/2

  pos <- pred[grp == levels(grp)[2]]
  neg <- pred[grp == levels(grp)[1]]
  q1 <- auc/(2-auc)
  q2 <- (2*auc^2)/(1+auc)
  se.auc <- sqrt(((auc * (1 - auc)) + ((length(pos) -1)*(q1 - auc^2)) + ((length(neg) -1)*(q2 - auc^2)))/(length(pos)*length(neg)))
  ci.upper <- auc + (se.auc * 0.96)
  ci.lower <- auc - (se.auc * 0.96)

  se.auc.null <- sqrt((1 + length(pos) + length(neg))/(12*length(pos)*length(neg)))
  z <- (auc - 0.5)/se.auc.null
  p <- 2*pnorm(-abs(z))

  stats <- data.frame (auc = auc,
                       p.value = p,
                       ci.upper = ci.upper,
                       ci.lower = ci.lower
                       )
  return (list(roc = roc, stats = stats))
}

I would like to run this function on my data frame but first split the data frame into individual data frames according to factor variable (100%,75%,66%,50%,25%). i.e. I would like the ROC coords (data.frame) and stats data.frame for each factor or variable. I then plan to plot ROC curves for each factor(variable) which I know how to do.

I think the function as stands is probably fine for my purposes and I probably want to use ddply from plyr or one of the apply functions.

something like split_df <- ddply(jr_all_melt,.(variable), rocdata(jr_all_melt$Class, jr_all_melt$SBR))

which I would hope would return an roc and stat data.frame with an additional column variable. I know what I want to achieve, but in R I am permanently lost on how best to implement it.

The function works fine for complete dataset using rocdata(jr_all_melt$Class, jr_all_melt$SBR) but this includes all levels of variable. I want to split the results by variable and compare the ROC curves and stats.

structure(list(Age = c(50.2916666666667, 50.2916666666667, 81.7666666666667,
81.7666666666667, 72.4333333333333, 72.4333333333333, 62.1916666666667,
62.1916666666667, 79.3694444444444, 79.3694444444444, 81.0583333333333,
81.0583333333333, 67.4194444444445, 67.4194444444445, 82.6361111111111,
82.6361111111111, 49.2638888888889, 49.2638888888889, 79.5416666666667,
79.5416666666667, 53.8833333333333, 53.8833333333333, 53.7416666666667,
53.7416666666667, 91.1, 91.1, 79.6138888888889, 79.6138888888889,
64.8388888888889, 64.8388888888889, 81.0444444444445, 81.0444444444445,
64.3305555555555, 64.3305555555555, 67.0083333333333, 67.0083333333333,
56.3972222222222, 56.3972222222222, 83.1777777777778, 83.1777777777778,
75.9027777777778, 75.9027777777778, 79.7944444444445, 79.7944444444445,
56.4277777777778, 56.4277777777778, 67.5083333333333, 67.5083333333333,
70.9888888888889, 70.9888888888889, 67.5805555555555, 67.5805555555555,
67.7388888888889, 67.7388888888889, 58.3083333333333, 58.3083333333333,
68.2805555555556, 68.2805555555556, 52.6055555555556, 52.6055555555556,
84.2861111111111, 84.2861111111111, 70.7861111111111, 70.7861111111111,
75.5222222222222, 75.5222222222222, 82.8361111111111, 82.8361111111111,
80.2361111111111, 80.2361111111111, 76.3888888888889, 76.3888888888889,
73.4, 73.4, 59.3055555555556, 59.3055555555556, 74.6972222222222,
74.6972222222222, 76.025, 76.025, 65.0944444444444, 65.0944444444444,
64.1888888888889, 61.9722222222222, 52.0472222222222, 64.8055555555556,
72.5083333333333, 83.0416666666667, 72.9, 68.9666666666667, 60.3694444444444,
80.3027777777778, 70.9333333333333, 68.4555555555555, 70.825,
73.9972222222222, 60.0916666666667, 77.2833333333333, 73.0722222222222,
66.4861111111111, 66.4777777777778, 41.7722222222222, 78.1861111111111,
74.8305555555555, 72.1638888888889, 71.725, 78.7416666666667,
65.0055555555556, 77.7083333333333, 54.1722222222222, 62.8583333333333,
73.0361111111111, 78.4944444444444, 77.4027777777778, 75.2472222222222,
68.475, 64.7222222222222, 81.1972222222222, 51.5861111111111,
60.8833333333333, 73.3972222222222, 76.8694444444444, 53.8805555555556,
63.3083333333333, 78.1083333333333, 78.4666666666667, 50.2916666666667,
50.2916666666667, 81.7666666666667, 81.7666666666667, 72.4333333333333,
72.4333333333333, 62.1916666666667, 62.1916666666667, 79.3694444444444,
79.3694444444444, 81.0583333333333, 81.0583333333333, 67.4194444444445,
67.4194444444445, 82.6361111111111, 82.6361111111111, 49.2638888888889,
49.2638888888889, 79.5416666666667, 79.5416666666667, 53.8833333333333,
53.8833333333333, 53.7416666666667, 53.7416666666667, 91.1, 91.1,
79.6138888888889, 79.6138888888889, 64.8388888888889, 64.8388888888889,
81.0444444444445, 81.0444444444445, 64.3305555555555, 64.3305555555555,
67.0083333333333, 67.0083333333333, 56.3972222222222, 56.3972222222222,
83.1777777777778, 83.1777777777778, 75.9027777777778, 75.9027777777778,
79.7944444444445, 79.7944444444445, 56.4277777777778, 56.4277777777778,
67.5083333333333, 67.5083333333333, 70.9888888888889, 70.9888888888889,
67.5805555555555, 67.5805555555555, 67.7388888888889, 67.7388888888889,
58.3083333333333, 58.3083333333333, 68.2805555555556, 68.2805555555556,
52.6055555555556, 52.6055555555556, 84.2861111111111, 84.2861111111111,
70.7861111111111, 70.7861111111111, 75.5222222222222, 75.5222222222222,
82.8361111111111, 82.8361111111111, 80.2361111111111, 80.2361111111111,
76.3888888888889, 76.3888888888889, 73.4, 73.4, 59.3055555555556,
59.3055555555556, 74.6972222222222, 74.6972222222222, 76.025,
76.025, 65.0944444444444, 65.0944444444444, 64.1888888888889,
61.9722222222222, 52.0472222222222, 64.8055555555556, 72.5083333333333,
83.0416666666667, 72.9, 68.9666666666667, 60.3694444444444, 80.3027777777778,
70.9333333333333, 68.4555555555555, 70.825, 73.9972222222222,
60.0916666666667, 77.2833333333333, 73.0722222222222, 66.4861111111111,
66.4777777777778, 41.7722222222222, 78.1861111111111, 74.8305555555555,
72.1638888888889, 71.725, 78.7416666666667, 65.0055555555556,
77.7083333333333, 54.1722222222222, 62.8583333333333, 73.0361111111111,
78.4944444444444, 77.4027777777778, 75.2472222222222, 68.475,
64.7222222222222, 81.1972222222222, 51.5861111111111, 60.8833333333333,
73.3972222222222, 76.8694444444444, 53.8805555555556, 63.3083333333333,
78.1083333333333, 78.4666666666667, 50.2916666666667, 50.2916666666667,
81.7666666666667, 81.7666666666667, 72.4333333333333, 72.4333333333333,
62.1916666666667, 62.1916666666667, 79.3694444444444, 79.3694444444444,
81.0583333333333, 81.0583333333333, 67.4194444444445, 67.4194444444445,
82.6361111111111, 82.6361111111111, 49.2638888888889, 49.2638888888889,
79.5416666666667, 79.5416666666667, 53.8833333333333, 53.8833333333333,
53.7416666666667, 53.7416666666667, 91.1, 91.1, 79.6138888888889,
79.6138888888889, 64.8388888888889, 64.8388888888889, 81.0444444444445,
81.0444444444445, 64.3305555555555, 64.3305555555555, 67.0083333333333,
67.0083333333333, 56.3972222222222, 56.3972222222222, 83.1777777777778,
83.1777777777778, 75.9027777777778, 75.9027777777778, 79.7944444444445,
79.7944444444445, 56.4277777777778, 56.4277777777778, 67.5083333333333,
67.5083333333333, 70.9888888888889, 70.9888888888889, 67.5805555555555,
67.5805555555555, 67.7388888888889, 67.7388888888889, 58.3083333333333,
58.3083333333333, 68.2805555555556, 68.2805555555556, 52.6055555555556,
52.6055555555556, 84.2861111111111, 84.2861111111111, 70.7861111111111,
70.7861111111111, 75.5222222222222, 75.5222222222222, 82.8361111111111,
82.8361111111111, 80.2361111111111, 80.2361111111111, 76.3888888888889,
76.3888888888889, 73.4, 73.4, 59.3055555555556, 59.3055555555556,
74.6972222222222, 74.6972222222222, 76.025, 76.025, 65.0944444444444,
65.0944444444444, 64.1888888888889, 61.9722222222222, 52.0472222222222,
64.8055555555556, 72.5083333333333, 83.0416666666667, 72.9, 68.9666666666667,
60.3694444444444, 80.3027777777778, 70.9333333333333, 68.4555555555555,
70.825, 73.9972222222222, 60.0916666666667, 77.2833333333333,
73.0722222222222, 66.4861111111111, 66.4777777777778, 41.7722222222222,
78.1861111111111, 74.8305555555555, 72.1638888888889, 71.725,
78.7416666666667, 65.0055555555556, 77.7083333333333, 54.1722222222222,
62.8583333333333, 73.0361111111111, 78.4944444444444, 77.4027777777778,
75.2472222222222, 68.475, 64.7222222222222, 81.1972222222222,
51.5861111111111, 60.8833333333333, 73.3972222222222, 76.8694444444444,
53.8805555555556, 63.3083333333333, 78.1083333333333, 78.4666666666667,
50.2916666666667, 50.2916666666667, 81.7666666666667, 81.7666666666667,
72.4333333333333, 72.4333333333333, 62.1916666666667, 62.1916666666667,
79.3694444444444, 79.3694444444444, 81.0583333333333, 81.0583333333333,
67.4194444444445, 67.4194444444445, 82.6361111111111, 82.6361111111111,
49.2638888888889, 49.2638888888889, 79.5416666666667, 79.5416666666667,
53.8833333333333, 53.8833333333333, 53.7416666666667, 53.7416666666667,
91.1, 91.1, 79.6138888888889, 79.6138888888889, 64.8388888888889,
64.8388888888889, 81.0444444444445, 81.0444444444445, 64.3305555555555,
64.3305555555555, 67.0083333333333, 67.0083333333333, 56.3972222222222,
56.3972222222222, 83.1777777777778, 83.1777777777778, 75.9027777777778,
75.9027777777778, 79.7944444444445, 79.7944444444445, 56.4277777777778,
56.4277777777778, 67.5083333333333, 67.5083333333333, 70.9888888888889,
70.9888888888889, 67.5805555555555, 67.5805555555555, 67.7388888888889,
67.7388888888889, 58.3083333333333, 58.3083333333333, 68.2805555555556,
68.2805555555556, 52.6055555555556, 52.6055555555556, 84.2861111111111,
84.2861111111111, 70.7861111111111, 70.7861111111111, 75.5222222222222,
75.5222222222222, 82.8361111111111, 82.8361111111111, 80.2361111111111,
80.2361111111111, 76.3888888888889, 76.3888888888889, 73.4, 73.4,
59.3055555555556, 59.3055555555556, 74.6972222222222, 74.6972222222222,
76.025, 76.025, 65.0944444444444, 65.0944444444444, 64.1888888888889,
61.9722222222222, 52.0472222222222, 64.8055555555556, 72.5083333333333,
83.0416666666667, 72.9, 68.9666666666667, 60.3694444444444, 80.3027777777778,
70.9333333333333, 68.4555555555555, 70.825, 73.9972222222222,
60.0916666666667, 77.2833333333333, 73.0722222222222, 66.4861111111111,
66.4777777777778, 41.7722222222222, 78.1861111111111, 74.8305555555555,
72.1638888888889, 71.725, 78.7416666666667, 65.0055555555556,
77.7083333333333, 54.1722222222222, 62.8583333333333, 73.0361111111111,
78.4944444444444, 77.4027777777778, 75.2472222222222, 68.475,
64.7222222222222, 81.1972222222222, 51.5861111111111, 60.8833333333333,
73.3972222222222, 76.8694444444444, 53.8805555555556, 63.3083333333333,
78.1083333333333, 78.4666666666667, 50.2916666666667, 50.2916666666667,
81.7666666666667, 81.7666666666667, 72.4333333333333, 72.4333333333333,
62.1916666666667, 62.1916666666667, 79.3694444444444, 79.3694444444444,
81.0583333333333, 81.0583333333333, 67.4194444444445, 67.4194444444445,
82.6361111111111, 82.6361111111111, 49.2638888888889, 49.2638888888889,
79.5416666666667, 79.5416666666667, 53.8833333333333, 53.8833333333333,
53.7416666666667, 53.7416666666667, 91.1, 91.1, 79.6138888888889,
79.6138888888889, 64.8388888888889, 64.8388888888889, 81.0444444444445,
81.0444444444445, 64.3305555555555, 64.3305555555555, 67.0083333333333,
67.0083333333333, 56.3972222222222, 56.3972222222222, 83.1777777777778,
83.1777777777778, 75.9027777777778, 75.9027777777778, 79.7944444444445,
79.7944444444445, 56.4277777777778, 56.4277777777778, 67.5083333333333,
67.5083333333333, 70.9888888888889, 70.9888888888889, 67.5805555555555,
67.5805555555555, 67.7388888888889, 67.7388888888889, 58.3083333333333,
58.3083333333333, 68.2805555555556, 68.2805555555556, 52.6055555555556,
52.6055555555556, 84.2861111111111, 84.2861111111111, 70.7861111111111,
70.7861111111111, 75.5222222222222, 75.5222222222222, 82.8361111111111,
82.8361111111111, 80.2361111111111, 80.2361111111111, 76.3888888888889,
76.3888888888889, 73.4, 73.4, 59.3055555555556, 59.3055555555556,
74.6972222222222, 74.6972222222222, 76.025, 76.025, 65.0944444444444,
65.0944444444444, 64.1888888888889, 61.9722222222222, 52.0472222222222,
64.8055555555556, 72.5083333333333, 83.0416666666667, 72.9, 68.9666666666667,
60.3694444444444, 80.3027777777778, 70.9333333333333, 68.4555555555555,
70.825, 73.9972222222222, 60.0916666666667, 77.2833333333333,
73.0722222222222, 66.4861111111111, 66.4777777777778, 41.7722222222222,
78.1861111111111, 74.8305555555555, 72.1638888888889, 71.725,
78.7416666666667, 65.0055555555556, 77.7083333333333, 54.1722222222222,
62.8583333333333, 73.0361111111111, 78.4944444444444, 77.4027777777778,
75.2472222222222, 68.475, 64.7222222222222, 81.1972222222222,
51.5861111111111, 60.8833333333333, 73.3972222222222, 76.8694444444444,
53.8805555555556, 63.3083333333333, 78.1083333333333, 78.4666666666667
), Sex = c("M", "M", "M", "M", "F", "F", "M", "M", "M", "M",
"M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F", "F", "M",
"M", "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M", "M",
"M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "F", "F", "F",
"F", "F", "F", "F", "F", "M", "M", "M", "M", "F", "F", "F", "F",
"M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M", "M",
"M", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M", "M", "F",
"M", "F", "M", "M", "M", "M", "M", "M", "F", "M", "M", "M", "F",
"M", "F", "M", "M", "M", "F", "M", "F", "F", "F", "M", "F", "M",
"M", "F", "F", "M", "F", "F", "M", "M", "M", "M", "F", "F", "M",
"M", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M",
"F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "F", "F", "F",
"F", "F", "F", "M", "M", "F", "F", "M", "M", "M", "M", "F", "F",
"M", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "F", "F",
"F", "M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F", "F",
"M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "F", "F", "F",
"F", "F", "F", "F", "M", "M", "M", "M", "F", "M", "F", "M", "M",
"M", "M", "M", "M", "F", "M", "M", "M", "F", "M", "F", "M", "M",
"M", "F", "M", "F", "F", "F", "M", "F", "M", "M", "F", "F", "M",
"F", "F", "M", "M", "M", "M", "F", "F", "M", "M", "M", "M", "F",
"F", "M", "M", "M", "M", "M", "M", "M", "M", "F", "F", "F", "F",
"M", "M", "F", "F", "M", "M", "F", "F", "F", "F", "F", "F", "M",
"M", "F", "F", "M", "M", "M", "M", "F", "F", "M", "M", "M", "M",
"M", "M", "F", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M",
"M", "F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "M", "M",
"M", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "F", "F",
"M", "M", "M", "M", "F", "M", "F", "M", "M", "M", "M", "M", "M",
"F", "M", "M", "M", "F", "M", "F", "M", "M", "M", "F", "M", "F",
"F", "F", "M", "F", "M", "M", "F", "F", "M", "F", "F", "M", "M",
"M", "M", "F", "F", "M", "M", "M", "M", "F", "F", "M", "M", "M",
"M", "M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F", "F",
"M", "M", "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M",
"M", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "F", "F",
"F", "F", "F", "F", "F", "F", "M", "M", "M", "M", "F", "F", "F",
"F", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M",
"M", "M", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M", "M",
"F", "M", "F", "M", "M", "M", "M", "M", "M", "F", "M", "M", "M",
"F", "M", "F", "M", "M", "M", "F", "M", "F", "F", "F", "M", "F",
"M", "M", "F", "F", "M", "F", "F", "M", "M", "M", "M", "F", "F",
"M", "M", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M",
"M", "F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "F", "F",
"F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "M", "M", "F",
"F", "M", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "F",
"F", "F", "M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F",
"F", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "F", "F",
"F", "F", "F", "F", "F", "M", "M", "M", "M", "F", "M", "F", "M",
"M", "M", "M", "M", "M", "F", "M", "M", "M", "F", "M", "F", "M",
"M", "M", "F", "M", "F", "F", "F", "M", "F", "M", "M", "F", "F",
"M", "F", "F", "M", "M", "M", "M", "F", "F"), Class = c(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, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0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L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L), .Label = c("100%", "75%", "66.6%", "50%",
"25%"), class = "factor"), SBR = c(12.681, 13.04, 11.72, 10.124,
10.69, 11.764, 8.561, 6.438, 4.263, 7.568, 9.231, 8.922, 12.651,
12.43, 8.281, 7.087, 12.944, 12.538, 11.443, 10.491, 12.792,
13.091, 7.091, 7.082, 5.406, 5.044, 11.007, 11.679, 9.909, 10.501,
10.268, 9.312, 16.485, 16.838, 11.743, 9.811, 13.447, 13.355,
5.138, 5.475, 8.883, 8.323, 9.054, 9.72, 21.538, 23.007, 8.842,
9.027, 5.757, 4.229, 5.293, 5.56, 9.714, 9.559, 13.698, 13.965,
7.364, 9.345, 9.309, 9.641, 6.893, 5.765, 7.45, 7.414, 3.651,
3.594, 8.243, 9.381, 7.068, 6.376, 7.011, 8.016, 9.391, 8.884,
8.24, 8.142, 9.045, 8.306, 5.427, 6.813, 10.123, 12.302, 3.953,
9.049, 4.292, 4.182, 5.084, 1.839, 2.693, 3.541, 4.079, 5.09,
5.655, 2.735, 8.321, -0.761, 4.331, 3.822, 1.403, 8.115, 7.87,
8.127, 3.931, 7.447, 1.362, 4.431, -1.583, 6.545, 2.851, 4.957,
6.518, 5.894, 3.874, 8.008, 4.72, 7.651, 8.212, 6.915, 9.625,
7.094, 2.291, 8.13, 7.71, 6.319, 2.494, 2.002, 12.478, 13.372,
12.212, 12.551, 10.571, 11.693, 8.674, 6.894, 5.061, 7.714, 8.512,
8.35, 12.251, 12.375, 7.898, 6.654, 12.89, 12.83, 12.24, 10.638,
13.615, 13.877, 6.845, 7.28, 5.224, 4.883, 10.742, 11.542, 10.308,
10.896, 9.356, 11.338, 15.793, 16.179, 12.567, 11.429, 13.431,
13.99, 6.123, 5.167, 8.709, 7.829, 7.599, 8.454, 19.393, 20.918,
8.33, 9.136, 4.824, 3.95, 6.425, 6.67, 8.22, 7.626, 13.909, 13.971,
8.425, 8.845, 8.887, 9.942, 7.078, 5.547, 6.837, 6.094, 4.576,
4.528, 8.619, 10.478, 3.125, 3.382, 7.22, 8.293, 11.238, 10.548,
7.197, 7.097, 9.659, 8.863, 5.577, 6.025, 10.77, 11.954, 3.814,
9.114, 4.435, 3.592, 5.265, 1.093, 3.903, 3.581, 3.602, 4.468,
5.451, 1.995, 7.03, -0.539, 4.875, 3.812, 1.476, 8.107, 8.628,
9.107, 2.54, 6.902, 1.553, 5.64, -2.762, 6.625, 2.715, 5.475,
6.085, 6.385, 2.794, 7.813, 4.801, 5.883, 7.837, 4.8, 9.527,
8.804, 2.988, 5.729, 7.275, 8.683, 2.627, 1.882, 11.884, 12.791,
10.861, 9.382, 9.525, 10.237, 9.299, 7.338, 5.075, 7.583, 10.324,
9.143, 14.003, 12.861, 7.687, 6.719, 13.422, 13.595, 11.828,
10.943, 12.296, 12.836, 7.069, 7.523, 5.691, 5.309, 11.494, 12.253,
8.711, 8.991, 9.009, 8.809, 15.387, 15.631, 11.948, 12.295, 15.034,
13.889, 5.454, 6.518, 9.535, 8.777, 8.436, 8.396, 18.508, 20.444,
9.505, 8.998, 4.705, 3.47, 5.202, 4.86, 7.532, 7.451, 14.499,
14.114, 6.872, 9.877, 9.077, 9.33, 6.009, 4.583, 5.988, 6.252,
4.766, 4.273, 11.44, 10.971, 6.393, 5.551, 7.107, 6.959, 11.844,
10.795, 9.183, 8.909, 9.142, 7.753, 6.055, 7.152, 9.566, 11.637,
3.668, 8.697, 4.701, 3.218, 4.292, 0.273, 2.713, 3.579, 5.496,
6.322, 4.852, 3.553, 6.82, -0.745, 4.581, 4.12, 1.886, 7.633,
8.07, 8.381, 3.627, 7.156, 1.669, 2.754, -2.56, 5.437, 2.587,
4.361, 4.959, 4.653, 3.2, 7.943, 5.922, 6.379, 5.403, 4.698,
9.665, 6.82, 2.432, 8.587, 6.4, 6.454, 2.054, 0.999, 10.129,
11.129, 13.195, 11.133, 10.702, 12.333, 9.4, 7.665, 5.538, 8.751,
8.868, 8.25, 12.695, 12.2, 8.346, 6.802, 12.007, 11.245, 11.456,
9.58, 12.941, 12.826, 6.239, 6.829, 5.887, 4.896, 10.303, 11.478,
8.972, 9.636, 9.538, 8.34, 16.686, 16.453, 10.827, 8.923, 13.867,
13.964, 5.016, 5.51, 7.635, 7.577, 7.725, 9.532, 21.083, 21.567,
9.417, 8.435, 5.635, 4.206, 4.299, 6.018, 8.642, 8.961, 12.613,
12.665, 8.861, 10.567, 9.365, 9.341, 6.435, 5.435, 7.099, 7.285,
5.467, 4.823, 8.959, 10.568, 6.085, 4.575, 7.267, 8.206, 9.589,
9.242, 7.504, 7.43, 9.171, 7.967, 3.426, 5.843, 10.341, 12.598,
4.001, 9.796, 4.188, 5.943, 6.093, 0.063, 2.512, 3.094, 3.106,
5.35, 6.468, 3.677, 7.964, -0.355, 4.088, 3.271, 0.608, 7.864,
7.941, 7.409, 1.796, 6.667, 0.731, 5.275, -1.904, 5.552, 2.487,
4.371, 6.181, 6.772, 2.993, 7.824, 4.659, 5.242, 5.33, 5.572,
9.409, 6.97, 2.791, 7.5, 6.753, 6.453, 1.955, 1.61, 13.193, 13.31,
12.485, 9.241, 11.773, 12.114, 9.747, 6.474, 5.956, 9.922, 11.264,
10.741, 15.046, 14.575, 6.828, 5.505, 13.366, 12.29, 10.432,
10.353, 12.386, 11.557, 6.68, 7.691, 5.158, 5.553, 10.371, 11.818,
9.635, 9.746, 8.955, 7.844, 18.448, 17.837, 11.19, 11.44, 13.722,
13.807, 7.387, 6.504, 8.724, 8.63, 9.441, 11.918, 19.074, 21.111,
8.849, 8.582, 3.558, 3.453, 4.963, 5.903, 9.605, 9.247, 12.929,
14.318, 7.057, 8.258, 9.982, 9.598, 8.709, 6.397, 7.797, 5.743,
5.742, 5.503, 7.563, 8.864, 5.685, 5.297, 7.63, 7.469, 10.426,
9.266, 7.451, 7.535, 9.941, 8.376, 4.793, 5.155, 9.867, 12.821,
3.052, 5.617, 2.7, 4.793, 6.38, 0.828, 2.281, 2.713, 4.508, 5.245,
5.325, 3.849, 6.326, 0.197, 5.909, 3.548, 1.077, 8.596, 10.599,
6.268, 1.86, 7.651, 1.083, 4.869, -2.972, 4.83, 2.146, 5.991,
4.333, 7.388, 2.181, 6.888, 4.85, 5.289, 5.878, 4.706, 4.609,
6.398, 2.106, 10.709, 6.243, 7.267, 1.431, 1.706)), row.names = c(NA,
-630L), .Names = c("Age", "Sex", "Class", "variable", "SBR"), class = "data.frame")

Body:
I have only been able to get the data in the desired format by manually splitting the data.frame running the function and combining back together. How do I do this in a tidier fashion?

FullCount = jr_all_melt[jr_all_melt$variable=="100%",]
ThreeQuart = jr_all_melt[jr_all_melt$variable=="75%",]
TwoThird = jr_all_melt[jr_all_melt$variable=="66.6%",]
HalfCount = jr_all_melt[jr_all_melt$variable=="50%",]
OneQuart = jr_all_melt[jr_all_melt$variable=="25%",]

Full.ROC = rocdata(FullCount$Class,FullCount$SBR)
Full.ROC$roc$variable = "100%"
ThreeQuart.ROC = rocdata(ThreeQuart$Class,ThreeQuart$SBR)
ThreeQuart.ROC$roc$variable = "75%"
TwoThird.ROC = rocdata(TwoThird$Class,TwoThird$SBR)
TwoThird.ROC$roc$variable = "66.6%"
HalfCount.ROC = rocdata(HalfCount$Class,HalfCount$SBR)
HalfCount.ROC$roc$variable = "50%"
OneQuart.ROC = rocdata(OneQuart$Class,OneQuart$SBR)
OneQuart.ROC$roc$variable = "25%"

roc_all <- rbind(Full.ROC$roc,ThreeQuart.ROC$roc,TwoThird.ROC$roc,HalfCount.ROC$roc,OneQuart.ROC$roc)
stats_all <- rbind(stats_all, Full.ROC$stats,ThreeQuart.ROC$stats, TwoThird.ROC$stats, HalfCount.ROC$stats,OneQuart.ROC$stats)


来源: stackexchange

问:
Confusion on Potential Variable Scope (Maybe Pointers)? Not sure
I tried searching for an answer (I feel this is a basic concept) but I was unable to find one that related directly to mine... so here is my post.

I am currently parsing log files off my server and building a script to kind of automate some of the process (learn a new skill, make my job easier, etc.). I built a simplified parser to breakdown each line. I have omitted quite a bit of code as it's unrelated.

Here is my function:

```<code>var parsedDataSet = make(map[int][]string)

func parseData(dataSet []string) {
    var tempArray []string
    for index, element := range dataSet {
        tempData := strings.Fields(element)
        tempArray = append(tempArray, tempData[0], tempData[3][1:]+" "+tempData[4][:len(tempData[4])-1], tempData[5][1:], tempData[6], tempData[7][:len(tempData[7])-1], tempData[8], tempData[9])
        parsedDataSet[index] = tempArray
        fmt.Println(parsedDataSet[index])
        tempArray = tempArray[:0]
    }
    fmt.Println("------")
    fmt.Println(parsedDataSet[0])
    fmt.Println(parsedDataSet[1])
    fmt.Println(parsedDataSet[2])
    fmt.Println(parsedDataSet[3])
}
</code>```

Here is the sample result:

As you can see when I print out the "parsedDataSet" variable at different sections it holds different values. Above the "------" line break is the values I want, below is the values I am showing outside of the "for" loop. I am leaning towards variable scope as it's assigning the values inside the "for" loop and it's not carrying it outside of that. However, I am accessing a global variable for assignment so my assumption is that it would carry through to the global scope.

I am new to Go so I am still learning quite a bit with the language - loving it so far. I just can't wrap my head around the issue. I re-wrote this in Python (my current language) and it worked perfectly fine in a near similar manner.

Thank you in advance for your help!

答:
A slice assignment does not perform a copy, it's just a pointer. This means that every parsedDataSet entry is the same slice.

The simplest solution is for you to move var tempArray []string inside the for loop.

For details on slices and how re-slicing works, you should read up on the details

ContentLicense: CC BY-SA 3.0

Body:
I tried searching for an answer (I feel this is a basic concept) but I was unable to find one that related directly to mine... so here is my post.

I am currently parsing log files off my server and building a script to kind of automate some of the process (learn a new skill, make my job easier, etc.). I built a simplified parser to breakdown each line. I have omitted quite a bit of code as it's unrelated.

Here is my function:

var parsedDataSet = make(map[int][]string)

func parseData(dataSet []string) {
    var tempArray []string
    for index, element := range dataSet {
        tempData := strings.Fields(element)
        tempArray = append(tempArray, tempData[0], tempData[3][1:]+" "+tempData[4][:len(tempData[4])-1], tempData[5][1:], tempData[6], tempData[7][:len(tempData[7])-1], tempData[8], tempData[9])
        parsedDataSet[index] = tempArray
        fmt.Println(parsedDataSet[index])
        tempArray = tempArray[:0]
    }
    fmt.Println("------")
    fmt.Println(parsedDataSet[0])
    fmt.Println(parsedDataSet[1])
    fmt.Println(parsedDataSet[2])
    fmt.Println(parsedDataSet[3])
}

Here is the sample result:

As you can see when I print out the "parsedDataSet" variable at different sections it holds different values. Above the "------" line break is the values I want, below is the values I am showing outside of the "for" loop. I am leaning towards variable scope as it's assigning the values inside the "for" loop and it's not carrying it outside of that. However, I am accessing a global variable for assignment so my assumption is that it would carry through to the global scope.

I am new to Go so I am still learning quite a bit with the language - loving it so far. I just can't wrap my head around the issue. I re-wrote this in Python (my current language) and it worked perfectly fine in a near similar manner.

Thank you in advance for your help!


问:
Populate array with input values

I try to push the strings from an input into an array so after I can assign that array to a <select> and each <option> should be one string from the input. This is what I've done so far and this is the error I get and I have no idea how to do it and because I cannot find some reliable information about Angular arrays only hardcoding examples I would like to provide me an example how can I do this.

This is my HTML code in which I have just an input to add player's name

      <form (submit)="onSubmit()" #formName="ngForm">

Add a new player

          <input type="text" class="form-control" placeholder="e.g.Jimbo"
      [(ngModel)]="name" name="name" id="name" #name="ngModel" required>
      {{model.name}}

    <button type="submit" class="btn btn-success" [disabled]="!formName.form.valid">Add Player</button>
  </form>
```

<p></p>

<p>Here is my ts file with the function onSubmit() in which I try to push the names from the input into the array</p>

<pre class="lang-ts prettyprint-override"><code>import { Component, OnInit } from '@angular/core';
import { AddPlayer } from './add-player';

@Component({
  selector: 'app-add-player',
  templateUrl: './add-player.component.html',
  styleUrls: ['./add-player.component.css']
})
export class AddPlayerComponent{

  name:string = "";
  onSubmit() {
    this.listOfNames.push(this.name)
    console.log(this.listOfNames);
  }
}
</code>```

And here is another ts file with the constructor

export class AddPlayer {
  constructor(
    public listOfNames: string[] = []
    ){}
}
```

答:
You try to push into this.listOfNames which should be declared in your AddPlayerComponent like this

```<code>import { Component, OnInit } from '@angular/core';
import { AddPlayer } from './add-player';

@Component({
  selector: 'app-add-player',
  templateUrl: './add-player.component.html',
  styleUrls: ['./add-player.component.css']
})
export class AddPlayerComponent{
  listOfNames = [];
  name:string = "";
  onSubmit() {
    this.listOfNames.push(this.name)
    console.log(this.listOfNames);
  }
}
</code>```

Title: Populate array with input values

Body:
I try to push the strings from an input into an array so after I can assign that array to a <select> and each <option> should be one string from the input. This is what I've done so far and this is the error I get and I have no idea how to do it and because I cannot find some reliable information about Angular arrays only hardcoding examples I would like to provide me an example how can I do this.

This is my HTML code in which I have just an input to add player's name

      <form (submit)="onSubmit()" #formName="ngForm">

Add a new player

          <input type="text" class="form-control" placeholder="e.g.Jimbo"
      [(ngModel)]="name" name="name" id="name" #name="ngModel" required>
      {{model.name}}

    <button type="submit" class="btn btn-success" [disabled]="!formName.form.valid">Add Player</button>
  </form>

Here is my ts file with the function onSubmit() in which I try to push the names from the input into the array

import { Component, OnInit } from '@angular/core';
import { AddPlayer } from './add-player';

@Component({
  selector: 'app-add-player',
  templateUrl: './add-player.component.html',
  styleUrls: ['./add-player.component.css']
})
export class AddPlayerComponent{

  name:string = "";
  onSubmit() {
    this.listOfNames.push(this.name)
    console.log(this.listOfNames);
  }
}

And here is another ts file with the constructor

export class AddPlayer {
  constructor(
    public listOfNames: string[] = []
    ){}
}

Body:
You try to push into this.listOfNames which should be declared in your AddPlayerComponent like this

import { Component, OnInit } from '@angular/core';
import { AddPlayer } from './add-player';

@Component({
  selector: 'app-add-player',
  templateUrl: './add-player.component.html',
  styleUrls: ['./add-player.component.css']
})
export class AddPlayerComponent{
  listOfNames = [];
  name:string = "";
  onSubmit() {
    this.listOfNames.push(this.name)
    console.log(this.listOfNames);
  }
}


问:
How to use HadoopJarStepConfig.StepProperties?
AWS docs state that this property is "A list of Java properties that are set when the job flow step runs. You can use these properties to pass key-value pairs to your main function in the JAR file."

But there is no explanation (at least, I failed to find any) how exactly they are passed, and how to properly access said collection of key-value pairs on a main function side.

Quick check proved that they aren't passed via environment nor command line arguments. Could be some other way?

答:
Okay, seems that this map goes to Java system properties and is accessible from main function side via System.getProperties() call, but there are some non-obvious implications.

First thing to keep in the mind, that internally they are set via environment variable HADOOP_CLIENT_OPTS as -Dkey=value switches. But EMR does not bother itself to properly escape keys nor values by shell rules.

Also, it does not report any syntax errors if there are properties with non-printable characters, just omits setting them altogether. And it plays even worse with special shell characters like * ? ( ) \ and such — it'll fail the task execution without a proper explanation, and the log records will vaguely point only to obscure syntax errors in some eval() call deeply inside of EMR internal shell script wrappers.

Please be aware about that behaviour.

Properties must be shell-escaped, and in some cases even doubly shell-escaped.


问:
How do I get over my fears of <% %> in my ASP.Net MVC markup?
So I totally buy into the basic tenents of ASP.NET, testability, SoC, HTML control...it's awesome.  However being new to it I have a huge hang up with the markup.  I know it comes from my hatred of classic ASP, and I can't help but feel like I've entered the twilight zone when I see this.

I don't know what the alternative is (can I use server controls, databinding etc...?)

答:
Very occasionally use helper methods (I'm NOT talking about the extension helper methods) to write HTML code in the view itself using the Html object model. I wouldnt recomment this unless you have some wierd logic that you cant easily write in the view. As long as the code in .aspx.cs is VIEW code then its fine.

In your View's .aspx file :

```<code> <%-- render section --%>
 <% RenderTextSection(section); %>
</code>```

In your View's 'codebehind' you use HtmlGenericControl to create HTML and then the following line to write it out :

```<code>htmlControl.RenderControl(new HtmlTextWriter(Response.Output));
</code>```

My full method :

```<code>protected void RenderTextSection(ProductSectionInfo item)

    {
        HtmlGenericControl sectionTextDiv = new HtmlGenericControl("div");

        bool previousHasBulletPoint = false;
        System.Web.UI.HtmlControls.HtmlControl currentContainer = sectionTextDiv;

        foreach (var txt in item.DescriptionItems)
        {
            if (!previousHasBulletPoint && txt.bp)
            {
                // start bulleted section
                currentContainer = new HtmlGenericControl("UL");
                sectionTextDiv.Controls.Add(currentContainer);
            }
            else if (previousHasBulletPoint && !txt.bp)
            {
                // exit bulleted section
                currentContainer = sectionTextDiv;
            }

            if (txt.bp)
            {
                currentContainer.Controls.Add(new HtmlGenericControl("LI")
                {
                    InnerHtml = txt.t
                });
            }
            else
            {
                currentContainer.Controls.Add(new HtmlGenericControl()
                {
                    InnerHtml = txt.t
                });
            }

            previousHasBulletPoint = txt.bp;
        }

        sectionTextDiv.RenderControl(new HtmlTextWriter(Response.Output));
    }
</code>```

OwnerDisplayName: Webjedi

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: Fabian Steeg

Body:
Very occasionally use helper methods (I'm NOT talking about the extension helper methods) to write HTML code in the view itself using the Html object model. I wouldnt recomment this unless you have some wierd logic that you cant easily write in the view. As long as the code in .aspx.cs is VIEW code then its fine.

In your View's .aspx file :

 <%-- render section --%>
 <% RenderTextSection(section); %>

In your View's 'codebehind' you use HtmlGenericControl to create HTML and then the following line to write it out :

htmlControl.RenderControl(new HtmlTextWriter(Response.Output));

My full method :

protected void RenderTextSection(ProductSectionInfo item)

    {
        HtmlGenericControl sectionTextDiv = new HtmlGenericControl("div");

        bool previousHasBulletPoint = false;
        System.Web.UI.HtmlControls.HtmlControl currentContainer = sectionTextDiv;

        foreach (var txt in item.DescriptionItems)
        {
            if (!previousHasBulletPoint && txt.bp)
            {
                // start bulleted section
                currentContainer = new HtmlGenericControl("UL");
                sectionTextDiv.Controls.Add(currentContainer);
            }
            else if (previousHasBulletPoint && !txt.bp)
            {
                // exit bulleted section
                currentContainer = sectionTextDiv;
            }

            if (txt.bp)
            {
                currentContainer.Controls.Add(new HtmlGenericControl("LI")
                {
                    InnerHtml = txt.t
                });
            }
            else
            {
                currentContainer.Controls.Add(new HtmlGenericControl()
                {
                    InnerHtml = txt.t
                });
            }

            previousHasBulletPoint = txt.bp;
        }

        sectionTextDiv.RenderControl(new HtmlTextWriter(Response.Output));
    }

OwnerDisplayName: Simon


问:
How do you edit the settings you entered when you registered your Facebook app?
How do you edit the settings you entered when you registered your Facebook app?
I need to change the base url and cannot for the life of me figure it out navigating the site.
Someone must know where this is accessible.

Edit:
Hmmm, guess I have been going to the right place, right now I just get
'An error occurred with Developer. Please try again later.'

答: From the right sidebar My Apps on the developers page</p>


问:
local site is automatically on https on chrome
I had an update on my computer ( ubuntu) and now my host that i had in local is not working anymore :
This site can’t be reached
www.site.dev refused to connect.
Try:

Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED

This same url works on firefox and postman for my api so I am a bit lost!

答:
I just saw this post and I have my explanation.

https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/

Chrome is now redirecting all .dev to https... so I have to change my extension of local website or use another browser.

For those ones that have same issue, don't use chrome or rename your vhost and host file to another extension because .dev won't work chrome in http.

ContentLicense: CC BY-SA 4.0


问:
Can't create table with jpa+spring boot
I'm trying to generate table using JPA. but i can't create it. There is no error in the code, but it seems that there is configuration error. but i can't find it, i tried many configurations but nothing happen.
Thanks a lot.

This is application.property:

```<code>spring.datasource.url=jdbc:mysql://localhost:3306/springapp
spring.datasource.username= root
spring.datasource.password= me
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=create
</code>```

this is my class:

```<code>@Entity
public class Customer {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private int id;
    private String name;
    private String phone;

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public Customer(String name, String phone) {
        super();
        this.name = name;
        this.phone = phone;
    }
    public Customer() {
        super();
    }
}
</code>```

This is the application:

```<code>@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
</code>```

And this is the controller:

@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    CustomerRepository customerRepository;

```<code>@RequestMapping("/findall")
@ResponseBody
public List<Customer> findAll() {
    return customerRepository.findAll();
}
</code>```

}

Pom.xml

```<code>    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>GStock-3</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>GStock-3</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
</code>```

答:
Try to add @EntityScan

```<code>@EntityScan("<package with entities>")
@SpringBootApplication
public class Application { ... }
</code>```

Title: Can't create table with jpa+spring boot

Body:
I'm trying to generate table using JPA. but i can't create it. There is no error in the code, but it seems that there is configuration error. but i can't find it, i tried many configurations but nothing happen.
Thanks a lot.

This is application.property:

spring.datasource.url=jdbc:mysql://localhost:3306/springapp
spring.datasource.username= root
spring.datasource.password= me
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=create

this is my class:

@Entity
public class Customer {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private int id;
    private String name;
    private String phone;

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public Customer(String name, String phone) {
        super();
        this.name = name;
        this.phone = phone;
    }
    public Customer() {
        super();
    }
}

This is the application:

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

And this is the controller:

@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    CustomerRepository customerRepository;

@RequestMapping("/findall")
@ResponseBody
public List<Customer> findAll() {
    return customerRepository.findAll();
}

}

Pom.xml

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>GStock-3</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>GStock-3</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
        <relativePath/>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Body:
Try to add @EntityScan

@EntityScan("<package with entities>")
@SpringBootApplication
public class Application { ... }


问:
Eclipse highlighting the same occurrence of the word
In  Notepad++, it has a very nice feature that if I select a word, it will highlight all the same words throughout the text. I can also set the hot-keys to highlight up to five different  words with different styles (See the effect below) .

Is there any ways to get this similar effect in eclipse? I know when editing Java, it will highlight all the same variables, but it will not work when I highlight the comments and editing other files type (e.g. xml, html, js, css and etc).

答: Window > Preferences > Java > Editor > Mark Occurrences</p>


问:
group by in sas
I've the below dataset as input

```<code>ID
--

1
2
2
3
4
4
4
5
</code>```

And need a new dataset as below

```<code>ID   count of ID
--   -----------

1    1
2    2
3    1
4    3
5    1
</code>```

Could you please tell how to do this in SAS wihtout using PROC SQL?

答:
Here is yet another possibility, often known as a DoW construction:</p>

```<code>Data want;
  do count=1 by 1 until(last.ID);
    set have;
    by id;
    end;
run;
</code>```

Title: group by in sas

Body:
I've the below dataset as input

ID
--

1
2
2
3
4
4
4
5

And need a new dataset as below

ID   count of ID
--   -----------

1    1
2    2
3    1
4    3
5    1

Could you please tell how to do this in SAS wihtout using PROC SQL?

Body:
Here is yet another possibility, often known as a DoW construction:

Data want;
  do count=1 by 1 until(last.ID);
    set have;
    by id;
    end;
run;


问:
it shows SyntaxError: unexpected EOF while parsing whenever i run the code

```<code>from sense_hat import SenseHat
from time import sleep, strftime

sense = SenseHat()

# ------------------------------------------------
# DATA
# ------------------------------------------------

# Colours
colours = {

  'r' : [255, 0, 0],
  # Add orange, yellow, green, blue, indigo, violet here
  'o' : [255, 125, 0],
  'y' : [255, 255, 0],
  'g' : [0, 255, 0],
  'b' : [0, 0, 255],
  'i' : [75, 0, 130],
  'v' : [51, 2, 170],
  'n' : [135, 80, 22],
  'w' : [255, 255, 255],
  'e' : [0, 0, 0]  # e stands for empty/black

}

# Pictures
with open("pictures.txt", "r") as f:
  all_pics = f.readlines()
# ------------------------------------------------
# FUNCTIONS
# ------------------------------------------------
# Display a given picture string on the sense HAT
# ------------------------------------------------
def display_pic(pic_string):

  # Get rid of newline and split the line into a list
  pic_string = pic_string.strip("\n")
  pic_string = pic_string.split(",")

  # Look up each letter in the dictionary of colours and add it to the list
  pic_list = []
  for letter in pic_string:
      pic_list.append(colours[letter])

  # Display the pixel colours from the file
  sense.set_pixels(pic_list)

# ------------------------------------------------
# MAIN PROGRAM
# ------------------------------------------------
sense.clear()
display_pic(all_pics[7]

it show this-----> SyntaxError: unexpected EOF while parsing
</code>```

this code is to show images on a raspberry pi sense HAT please tell me to solve this problem. thank you n how i can edit the code . i followed the instructions on the raspberry pi website. i am making a advent calendar using sense HAT i expected it to make the sense HAT show pictures.

答:
add a ) to the last line

display_pic(all_pics[7]   )

Body:
from sense_hat import SenseHat
from time import sleep, strftime

sense = SenseHat()

# ------------------------------------------------
# DATA
# ------------------------------------------------

# Colours
colours = {

  'r' : [255, 0, 0],
  # Add orange, yellow, green, blue, indigo, violet here
  'o' : [255, 125, 0],
  'y' : [255, 255, 0],
  'g' : [0, 255, 0],
  'b' : [0, 0, 255],
  'i' : [75, 0, 130],
  'v' : [51, 2, 170],
  'n' : [135, 80, 22],
  'w' : [255, 255, 255],
  'e' : [0, 0, 0]  # e stands for empty/black

}

# Pictures
with open("pictures.txt", "r") as f:
  all_pics = f.readlines()
# ------------------------------------------------
# FUNCTIONS
# ------------------------------------------------
# Display a given picture string on the sense HAT
# ------------------------------------------------
def display_pic(pic_string):

  # Get rid of newline and split the line into a list
  pic_string = pic_string.strip("\n")
  pic_string = pic_string.split(",")

  # Look up each letter in the dictionary of colours and add it to the list
  pic_list = []
  for letter in pic_string:
      pic_list.append(colours[letter])

  # Display the pixel colours from the file
  sense.set_pixels(pic_list)

# ------------------------------------------------
# MAIN PROGRAM
# ------------------------------------------------
sense.clear()
display_pic(all_pics[7]

it show this-----> SyntaxError: unexpected EOF while parsing

this code is to show images on a raspberry pi sense HAT please tell me to solve this problem. thank you n how i can edit the code . i followed the instructions on the raspberry pi website. i am making a advent calendar using sense HAT i expected it to make the sense HAT show pictures.


问:
Using Higher order functions instead of two loops
I wanted to use higher order functions such as Map, Filter, Reduce.

My problem is I have an array which is not organised so I had to perform a loop operation to get the result I wanted. An array has two fields one is _id and totalCount which is an array the length will be minimum 0 to 3.

The totalCount each iteration consists of two fields one is orderstatus and another is total I want to perform a normal if else condition if orderstatus is "Merchant" or "driver" or "user" I want to take that iterated total and store it in my array like MerchantCount.

This is my code:

```<code>var arr = [{
   _id: "2017-12-08",
   totalcount: [{
     orderstatus: "MERCHANT",
     total: 1
   }]
 },
 {
   _id: "2017-12-02",
   totalcount: [{
     orderstatus: "USER",
     total: 2
   }]
 },
 {
   _id: "2017-12-06",
   totalcount: [{
     orderstatus: "DRIVER",
     total: 1
   }]
 },
 {
   _id: "2017-12-07",
   totalcount: [{
     orderstatus: "MERCHANT",
     total: 3
   }]
 },
 {
   _id: "2017-12-04",
   totalcount: [{
       orderstatus: "DRIVER",
       total: 1
     },
     {
       orderstatus: "MERCHANT",
       total: 2
     },
     {
       orderstatus: "USER",
       total: 1
     }
   ]
 }
]
</code>```

The loop am performing:

```<code>for (let i = 0; i < recentUserCount.length; i++) {
  for (let j = 0; j < recentUserCount[i].totalcount.length; j++) {
    if (recentUserCount[i].totalcount[j].usertype == "DRIVER") {
      recentUserCount[i].DRIVERCount = recentUserCount[i].totalcount[j].total;
    } else if (recentUserCount[i].totalcount[j].usertype == "USER") {
      recentUserCount[i].USERCount = recentUserCount[i].totalcount[j].total;
    } else if (recentUserCount[i].totalcount[j].usertype == "MERCHANT") {
      recentUserCount[i].MERCHANTCount = recentUserCount[i].totalcount[j].total;
    }
  }
}
</code>```

The result will be roughly like below:

```<code>    0 : {_id: "2017-12-08", totalcount: Array(1), MERCHANTCount: 3, $$hashKey: "object:316"}
    1 : {_id: "2017-12-07", totalcount: Array(1), MERCHANTCount: 3, $$hashKey: "object:317"}
    2 : {_id: "2017-12-06", totalcount: Array(1), DRIVERCount: 1, $$hashKey: "object:318"}
    3 : {_id: "2017-12-04", totalcount: Array(3), DRIVERCount: 1, MERCHANTCount: 2, USERCount: 1, …}
</code>```

I want the same operation to be performed using Map/Filter or Reduce method.

答:
I'd reduce and assign it

```<code>let res = arr.reduce((a, b) => {
    let totals = b.totalcount.reduce((x, y) => {
        x[y.orderstatus + 'Count'] = (x[y.orderstatus + 'Count'] || 0) + y.total;
        return x;
    }, {});
    return a.concat(Object.assign(b, totals));
}, []);
</code>```

var arr = [{_id:"2017-12-08",totalcount:[{orderstatus:"MERCHANT",total:1}]},{_id:"2017-12-02",totalcount:[{orderstatus:"USER",total:2}]},{_id:"2017-12-06",totalcount:[{orderstatus:"DRIVER",total:1}]},{_id:"2017-12-07",totalcount:[{orderstatus:"MERCHANT",total:3}]},{_id:"2017-12-04",totalcount:[{orderstatus:"DRIVER",total:1},{orderstatus:"MERCHANT",total:2},{orderstatus:"USER",total:1}]}];

let res = arr.reduce((a, b) => {
    let totals = b.totalcount.reduce((x, y) => {
        x[y.orderstatus + 'Count'] = (x[y.orderstatus + 'Count'] || 0) + y.total;
        return x;
    }, {});
    return a.concat(Object.assign(b, totals));
}, []);

console.log(res);```

Body:
I wanted to use higher order functions such as Map, Filter, Reduce.

My problem is I have an array which is not organised so I had to perform a loop operation to get the result I wanted. An array has two fields one is _id and totalCount which is an array the length will be minimum 0 to 3.

The totalCount each iteration consists of two fields one is orderstatus and another is total I want to perform a normal if else condition if orderstatus is "Merchant" or "driver" or "user" I want to take that iterated total and store it in my array like MerchantCount.

This is my code:

var arr = [{
   _id: "2017-12-08",
   totalcount: [{
     orderstatus: "MERCHANT",
     total: 1
   }]
 },
 {
   _id: "2017-12-02",
   totalcount: [{
     orderstatus: "USER",
     total: 2
   }]
 },
 {
   _id: "2017-12-06",
   totalcount: [{
     orderstatus: "DRIVER",
     total: 1
   }]
 },
 {
   _id: "2017-12-07",
   totalcount: [{
     orderstatus: "MERCHANT",
     total: 3
   }]
 },
 {
   _id: "2017-12-04",
   totalcount: [{
       orderstatus: "DRIVER",
       total: 1
     },
     {
       orderstatus: "MERCHANT",
       total: 2
     },
     {
       orderstatus: "USER",
       total: 1
     }
   ]
 }
]

The loop am performing:

for (let i = 0; i < recentUserCount.length; i++) {
  for (let j = 0; j < recentUserCount[i].totalcount.length; j++) {
    if (recentUserCount[i].totalcount[j].usertype == "DRIVER") {
      recentUserCount[i].DRIVERCount = recentUserCount[i].totalcount[j].total;
    } else if (recentUserCount[i].totalcount[j].usertype == "USER") {
      recentUserCount[i].USERCount = recentUserCount[i].totalcount[j].total;
    } else if (recentUserCount[i].totalcount[j].usertype == "MERCHANT") {
      recentUserCount[i].MERCHANTCount = recentUserCount[i].totalcount[j].total;
    }
  }
}

The result will be roughly like below:

    0 : {_id: "2017-12-08", totalcount: Array(1), MERCHANTCount: 3, $$hashKey: "object:316"}
    1 : {_id: "2017-12-07", totalcount: Array(1), MERCHANTCount: 3, $$hashKey: "object:317"}
    2 : {_id: "2017-12-06", totalcount: Array(1), DRIVERCount: 1, $$hashKey: "object:318"}
    3 : {_id: "2017-12-04", totalcount: Array(3), DRIVERCount: 1, MERCHANTCount: 2, USERCount: 1, …}

I want the same operation to be performed using Map/Filter or Reduce method.

Body:
I'd reduce and assign it

let res = arr.reduce((a, b) => {
    let totals = b.totalcount.reduce((x, y) => {
        x[y.orderstatus + 'Count'] = (x[y.orderstatus + 'Count'] || 0) + y.total;
        return x;
    }, {});
    return a.concat(Object.assign(b, totals));
}, []);

var arr = [{_id:"2017-12-08",totalcount:[{orderstatus:"MERCHANT",total:1}]},{_id:"2017-12-02",totalcount:[{orderstatus:"USER",total:2}]},{_id:"2017-12-06",totalcount:[{orderstatus:"DRIVER",total:1}]},{_id:"2017-12-07",totalcount:[{orderstatus:"MERCHANT",total:3}]},{_id:"2017-12-04",totalcount:[{orderstatus:"DRIVER",total:1},{orderstatus:"MERCHANT",total:2},{orderstatus:"USER",total:1}]}];

let res = arr.reduce((a, b) => {
    let totals = b.totalcount.reduce((x, y) => {
        x[y.orderstatus + 'Count'] = (x[y.orderstatus + 'Count'] || 0) + y.total;
        return x;
    }, {});
    return a.concat(Object.assign(b, totals));
}, []);

console.log(res);


问:
How to initialize a Mat with three channels
I want to initialize a kernel of three channels in OpenCV 2.4, and I looked at the documentation where there is no example of how to do it for Mats of more than one channel.

```<code>float data_[12] = {111, 112, 113, 121, 122, 123,
                   211, 212, 213, 221, 222, 223};
cv::Mat kernel(2, 2, CV_32FC3);
// How to initialize kernel with data_?
</code>```

Is there any way of initializing above kernel with data_?

答:
```<code>///! 2017.10.05 09:40:33 CST
/// convert uint8_t array/pointer to cv::Mat

#include <opencv2/core.hpp>
#include <iostream>

int main(){
    uint8_t uarr[] = {1,2,3,4,5,6,7,8,9,10,11,12};
    int rows = 2;
    int cols = 2;
    cv::Size sz(cols,rows);

    cv::Mat mat1(sz,CV_8UC3, uarr);
    cv::Mat mat2(rows, cols, CV_8UC3, uarr);

    std::cout<< "mat1: \n"<<mat1 << "\n\nmat2:\n" << mat2 << std::endl;
    return 0;
}
</code>```

The result is excepted:

```<code>mat1:
[  1,   2,   3,   4,   5,   6;
   7,   8,   9,  10,  11,  12]

mat2:
[  1,   2,   3,   4,   5,   6;
   7,   8,   9,  10,  11,  12]
</code>```

Details to my another answer:
OpenCV - how to create Mat from uint8_t pointer

Body:
I want to initialize a kernel of three channels in OpenCV 2.4, and I looked at the documentation where there is no example of how to do it for Mats of more than one channel.

float data_[12] = {111, 112, 113, 121, 122, 123,
                   211, 212, 213, 221, 222, 223};
cv::Mat kernel(2, 2, CV_32FC3);
// How to initialize kernel with data_?

Is there any way of initializing above kernel with data_?

Body:
///! 2017.10.05 09:40:33 CST
/// convert uint8_t array/pointer to cv::Mat

#include <opencv2/core.hpp>
#include <iostream>

int main(){
    uint8_t uarr[] = {1,2,3,4,5,6,7,8,9,10,11,12};
    int rows = 2;
    int cols = 2;
    cv::Size sz(cols,rows);

    cv::Mat mat1(sz,CV_8UC3, uarr);
    cv::Mat mat2(rows, cols, CV_8UC3, uarr);

    std::cout<< "mat1: \n"<<mat1 << "\n\nmat2:\n" << mat2 << std::endl;
    return 0;
}

The result is excepted:

mat1:
[  1,   2,   3,   4,   5,   6;
   7,   8,   9,  10,  11,  12]

mat2:
[  1,   2,   3,   4,   5,   6;
   7,   8,   9,  10,  11,  12]

Details to my another answer:
OpenCV - how to create Mat from uint8_t pointer


问:
Lost VSTS source control bindings in Visual Studio
Visual Studio 2015
Visual Studio 2013
Until recently used TFS for source control with Microsoft live id with my yahoo email.
Recent transition from TFS to VSTS.

Couple weeks ago devops switched my VSTS account to use company email instead of yahoo email.
After that in VS I couldn't use source control anymore,
was getting error: "TF30063: You are not authorized to access usga.visualstudio.com\DefaultCollection."
and not being able to bind to source control.
Devops removed my company-email-account and reactivated my yahoo-email-account
and source control in VS started to work again, and with VSTS now.

I have not used Visual Studio for a week or so.
Today I discovered that:

My solutions lost Source Control Bindings.
I can Not bind my solutions to Source Control Again in Visual Studio.
When I re-bind it tells me that status is 'invalid'.
I do Not get any other errors.
Happens for all solutions that used to work fine with source control.
I seem to have access to www.visualstudio.com -> mycompany.visualstudio.com
and can see my projects there.

Please help me to undestand what is going on and rebind.
Many thanks

答:
My issue was resolved the following way:
1. when I've started to use TFS four years ago, I've created Microsoft Live Id account using my Personal email

this year when our devops were switching us from TFS to VSTS
they have tried to enforce rule of everybody to use their Office email for MS Live Id account. So they have created new account for me with Office email

Then I have described issues

Problem was resolved by switching me back to using original MS account with my Personal email.

And

I had to delete existing workspaces in Visual Studio 2015
and create new ones for my solutions to rebind code to VSTS.
For some reason I had to repeat this process few times.

Hope it helps


问:
Getting string after first comma and before second comma
I have a string like this - "5,password,6099000,tree,city".

I want to extract only password from it. This means anything after first comma and before second comma.

How do I do this?

答:
```<code>String string = "5,password,6099000,tree,city";
String subString = string.substring(2,10);
</code>```

I assume you are a Java beginner, you may want to check

String Manipulation

Body:
String string = "5,password,6099000,tree,city";
String subString = string.substring(2,10);

I assume you are a Java beginner, you may want to check

String Manipulation


问:
SQL select only those group for which other column has only Nulls
I have SQL query with GROUP BY.
I want to select only this groups which have only Nulls in other column.

```<code>Select HH, TT from TABLE join TABLE... where XX GROUP BY HH

HH | TT
1  | Null
2  | Null
2  | Test
3  | Null
3  | Null
</code>```

I want to have only those:

```<code> HH | TT
 1  | Null
 3  | Null
</code>```

I'm on Oracle.

答:
This can be done with group by and having. Count of column TT should return 0 (as count ignores nulls).

```<code>select HH,max(TT) as TT
from tbl
group by HH
having count(TT)=0
</code>```

Body:
I have SQL query with GROUP BY.
I want to select only this groups which have only Nulls in other column.

Select HH, TT from TABLE join TABLE... where XX GROUP BY HH

HH | TT
1  | Null
2  | Null
2  | Test
3  | Null
3  | Null

I want to have only those:

 HH | TT
 1  | Null
 3  | Null

I'm on Oracle.

Body:
This can be done with group by and having. Count of column TT should return 0 (as count ignores nulls).

select HH,max(TT) as TT
from tbl
group by HH
having count(TT)=0


问:
Disable magnification gesture in WKWebView
I'm looking for a way to disable the "pinch to zoom" magnification gesture on the iOS implementation of WKWebView. There is a magnification BOOL property available for OS X but it doesn't seem to be available on iOS.

WKWebView.h

```<code>#if !TARGET_OS_IPHONE
/* @abstract A Boolean value indicating whether magnify gestures will
 change the web view's magnification.
 @discussion It is possible to set the magnification property even if
 allowsMagnification is set to NO.
 The default value is NO.
 */
@property (nonatomic) BOOL allowsMagnification;
</code>```

I've, also, tried look at the WKWebView's gesture recognizers but that seems to be turning up an empty array. I'm assuming the actual recognizers are bured deeper in the component's structure (fairly complex, by the looks of it) and would rather not go digging for them if at all possible.

I know of possible hacks that could potentially disable the gesture from firing (selectively passing gestures to the WebView, add child view to capture pinch gesture, etc) but I've always found those introduce lag into the event and want to keep the implementation as clean/hack free as possible.

答:
You can use UIScrollViewDelegate for this. First assign delegate to your webview in viewDidLoad() or any other suitable method as:</p>

```<code>class LoginViewController: UIViewController, WKUIDelegate, UIScrollViewDelegate {

  override func viewDidLoad() {
      webView.scrollView.delegate = self
  }

  //Add this delegate method in your view controller
  func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) {
      scrollView.pinchGestureRecognizer?.isEnabled = false
  }
}
</code>```

Body:
I'm looking for a way to disable the "pinch to zoom" magnification gesture on the iOS implementation of WKWebView. There is a magnification BOOL property available for OS X but it doesn't seem to be available on iOS.

WKWebView.h

#if !TARGET_OS_IPHONE
/* @abstract A Boolean value indicating whether magnify gestures will
 change the web view's magnification.
 @discussion It is possible to set the magnification property even if
 allowsMagnification is set to NO.
 The default value is NO.
 */
@property (nonatomic) BOOL allowsMagnification;

I've, also, tried look at the WKWebView's gesture recognizers but that seems to be turning up an empty array. I'm assuming the actual recognizers are bured deeper in the component's structure (fairly complex, by the looks of it) and would rather not go digging for them if at all possible.

I know of possible hacks that could potentially disable the gesture from firing (selectively passing gestures to the WebView, add child view to capture pinch gesture, etc) but I've always found those introduce lag into the event and want to keep the implementation as clean/hack free as possible.

Body:
You can use UIScrollViewDelegate for this. First assign delegate to your webview in viewDidLoad() or any other suitable method as:

class LoginViewController: UIViewController, WKUIDelegate, UIScrollViewDelegate {

  override func viewDidLoad() {
      webView.scrollView.delegate = self
  }

  //Add this delegate method in your view controller
  func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) {
      scrollView.pinchGestureRecognizer?.isEnabled = false
  }
}