vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

Base R Terminal error on `R: Run from Beginning to Line`

Open grcatlin opened this issue 11 months ago • 1 comments

Describe the bug Seemingly on MacOS, there are some odd terminal behaviors when NOT using radian where extra characters get added, text is garbled, or text is sent to the terminal in a way that it breaks functionality. This new stackoverflow post brought it up though I have experienced something similar when trying to use the R: Run from Beginning to Line command on longer scripts.

To Reproduce Steps to reproduce the behavior:

  1. Go to settings.json and ensure the base R term is used for r.rterm.mac and r.rpath.mac.
  2. Set r.bracketedPaste to false
  3. Open R in VS Code and R: Run from Beginning to Line at the bottom of a "longer" script.

I have tried this when "r.bracketedPaste": false and when it is true and code fails to execute properly either way. Interestingly, when I change r.rterm.mac back to using radian R: Run from Beginning to Line works when"r.bracketedPaste": false and when it is true.

As an example here is a function that errors out when I use R: Run from Beginning to Line.

Function
roc_f <- function(mod, response) {
    # generate prediction
    pred <- ROCR::prediction(
        glmmTMB:::predict.glmmTMB(mod, type = "response"),
        mod$frame |> dplyr::pull(response)
    )

    # cut rate ----

    # cut
    cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y = value,
            group = variable
        )
    ) +
        ggplot2::geom_line(
            ggplot2::aes(linetype = variable, color = variable)
        ) +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
        ggplot2::ylab("Sensitivity/Specificity") +
        ggplot2::xlab("Cutpoint") +
        gr.sg::theme_wgfd()

    # auc plot ----

    # get raw auc value
    auc <- ROCR::performance(
        pred,
        measure = "auc"
    ) |>
        getElement("y.values") |>
        unlist()

    # get true positive & false positive
    auc_plot <- ROCR::performance(
        pred,
        "tpr",
        "fpr"
    )

    # turn to df and rename cols
    auc_dat <- data.frame(
        x = [email protected],
        y = [email protected]
    )
    colnames(auc_dat) <- c([email protected], [email protected])

    # ggplot2 object
    auc_plot <- ggplot2::ggplot(
        auc_dat,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y = .data[[[email protected]]]
        )
    ) +
        ggplot2::geom_line() +
        ggplot2::geom_abline(col = "red") +
        ggplot2::ggtitle(
            label = "ROC curve",
            subtitle = paste0("AUC: ", round(auc, digits = 3))
        ) +
        gr.sg::theme_wgfd()

    # return ----

    # setup list
    ls <- list(
        auc_val = auc,
        auc_plot = auc_plot,
        cut_plot = cut_plot
    )

    # return
    return(ls)
}

This is what happens in my terminal when I try to run it - note that it repeats itself multiple times:

Terminal
# ROC function ----

roc_f <- function(mod, response) {
    # generate prediction
    pred <- ROCR::prediction(
        glmmTMB:::predict.glmmTMB(mod, type = "response"),
        mod$frame |> dplyr::pull(response)
    )

    # cut rate ----

    # cut
    cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        > 
# ROC function ----

roc_f <- function(mod, response) {
    # generate prediction
    pred <- ROCR::prediction(
        glmmTMB:::predict.glmmTMB(mod, type = "response"),
        mod$frame |> dplyr::pull(response)
    )

    # cut rate ----

    # cut
    cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        gg> # ROC function ----
> 
> roc_f <- function(mod, response) {
    # generate prediction
    pred <- ROCR::prediction(
        glmmTMB:::predict.glmmTMB(mod, type = "response"),
        mod$frame |> dplyr::pull(response)
    )

    # cut rate ----

    # cut
    cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
     +     # generate prediction
    pred <- ROCR::prediction(
        glmmTMB:::predict.glmmTMB(mod, type = "response"),
        mod$frame |> dplyr::pull(response)
    )

    # cut rate ----

    # cut
    cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                +     pred <- ROCR::prediction(
+         glmmTMB:::predict.glmmTMB(mod, type = "response"),
        mod$frame |> dplyr::pull(response)
    )

    # cut rate ----

    # cut
    cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        +         mod$frame |> dplyr::pull(response)
+     )

    # cut rate ----

    # cut
    cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- + 
    # cut rate ----

    # cut
    cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- RO+     # cut rate ----

    # cut
    cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
   + 
    # cut
    cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
     +     # cut
+     cut <- ROCR::performance(
        pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) +         pred,
        "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |+         "tpr",
        "tnr"
    )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues+         "tnr"
+     )

    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) | + 
    # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |   +     # create df
    cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true po+     cut_df <- data.frame(
        x = [email protected] |> unlist(),
        y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
  +         x = [email protected] |> unlist(),
+         y = [email protected] |> unlist(),
        alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
             +         alpha = [email protected] |> unlist()
    )
    colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    +     )
+     colnames(cut_df) <- c([email protected], [email protected], [email protected])
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x     +     cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln+         data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln        x        x   c_p        x       +         data.table::melt.data.table(id.vars = [email protected])

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln        x        x   c_p        x        x        x        xggp        x        x        x        x    + 
    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln        x        x   c_p        x        x        x        xggp        x        x        x        x      +     cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln        x        x   c_p        x        x        x        xggp        x        x        x        x        x        x     t,
             +         cut_df,
        ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln        x        x   c_p        x        x        x        xggp        x        x        x        x        x        x     t,
                              +         ggplot2::aes(
            x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln        x        x   c_p        x        x        x        xggp        x        x        x        x        x        x     t,
                                      .data[[auc_p   +             x = .data[[[email protected]]],
            y =            y =        up             y =            y =        uplot        line(
            ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln        x        x   c_p        x        x        x        xggp        x        x        x        x        x        x     t,
                                      .data[[auc_p                                             +             y =            y =        up                   uplot        line(
Error: unexpected '=' in:
"            x = .data[[[email protected]]],
            y =            y ="
>             ggplot2::aes            ggplot2::aes            ggplot2::aes  +
        ggplot2::ggtitle(
            "Cutpoint"
        ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln        x        x   c_p        x        x        x        xggp        x        x        x        x        x        x     t,
                                      .data[[auc_p                                                            .  )
    ) +
        ggplot2::geom_line() +
        ggplot2::geom_abline(col = "red") +
        ggplo        ggplo        ggplo        ggplo        ggplo    Error: unexpected symbol in "            ggplot2::aes            ggplot2"
>         ggplot2::ggtitle(
+             "Cutpoint"
+         ) +
                                      ci                     plot2::xlab("Cutpoint") +
        g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln        x        x   c_p        x        x        x        xggp        x        x        x        x        x        x     t,
                                      .data[[auc_p                                                            .  )
    ) +
        ggplot2::geom_line() +
        ggplot2::geom_abline(col = "red") +
        ggplo        ggplo        ggplo        ggplo        ggplo        ggplo       te0("AUC: ", round(auc, digits = 3))
        ) +                                       ci                     pl"Cutpoint") +
Error: unexpected symbol in:
"        ) +
                                      ci                     plot2"
>         g        g        g        g        g        g        g   c value
    auc <- ROCR::performance(
        pred,
        pred,
R:: "auc"
    ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
                       erformance(
        pred,
        "tpr",
                                    f a        e cols
    auc_dat <- data.frame(
        x        x        x        x        x        x        x        coln        x        x   c_p        x        x        x        xggp        x        x        x        x        x        x     t,
                                      .data[[auc_p                                                            .  )
    ) +
        ggplot2::geom_line() +
        ggplot2::geom_abline(col = "red") +
        ggplo        ggplo        ggplo        ggplo        ggplo        ggplo       te0("AUC: ", round(auc, digits = 3))
        ) +
            g::theme_wgfd()

    # return ----

    # setup list
    ls <- list(
        auc_val = auc,        auc_val = auc,        auc_val = auc,       Error: unexpected symbol in "        g        g"
>     auc <- ROCR::performance(
+         pred,
+         pred,
+ R:: "auc"
+     ) |    ) |    ) |    ) |    ) ues    ) |           ) |    )  # get true posi   e &     ) |    ) |
Error: unexpected ')' in:
"R:: "auc"
    ) |    )"
>                        erformance(
+         pred,
+         "tpr",
+                                     f a        e cols
Error: unexpected symbol in:
"        "tpr",
                                    f a"
>     auc_dat <- data.frame(
+         x        x        x        x        x        x        x        coln        x        x   c_p        x        x        x        xggp        x        x        x        x        x        x     t,
Error: unexpected symbol in:
"    auc_dat <- data.frame(
        x        x"
>                                       .data[[auc_p                                                            .  )
Error: unexpected symbol in "                                      .data[[auc_p                                                            ."
>     ) +
Error: unexpected ')' in "    )"
>         ggplot2::geom_line() +
+         ggplot2::geom_abline(col = "red") +
+         ggplo        ggplo        ggplo        ggplo        ggplo        ggplo       te0("AUC: ", round(auc, digits = 3))
Error: unexpected symbol in:
"        ggplot2::geom_abline(col = "red") +
        ggplo        ggplo"
>         ) +
Error: unexpected ')' in "        )"
>             g::theme_wgfd()
Error in loadNamespace(x) : there is no package called ‘g’
> 
>     # return ----
> 
>     # setup list
>     ls <- list(
+         auc_val = auc,        auc_val = auc,        auc_val = auc,        auc_val = )
Error: object 'auc' not found
> 
>     # return
>     return(ls)
Error: no function to return from, jumping to top level
> }
Error: unexpected '}' in "}"

Can you fix this issue by yourself? (We appreciate the help) No

(If applicable) Please attach setting.json

// R path for Mac OS X
"r.rterm.mac": "/usr/local/bin/R",

// Use bracketed paste mode
"r.bracketedPaste": false,

// Enable R session watcher
"r.sessionWatcher": true,

// Delay in milliseconds before sending each line to rterm (only applies if r.bracketedPaste is false)
"r.rtermSendDelay": 8,

Expected behavior For code to be send to the terminal as expected - like with radian.

Environment (please complete the following information):

  • OS: MacOS
  • VSCode Version: 1.87.0
  • R Version: 4.3.2
  • vscode-R version: v2.8.2

grcatlin avatar Mar 07 '24 22:03 grcatlin

I should note that I use VS Code with Windows and this doesn't happen there.

grcatlin avatar Mar 07 '24 23:03 grcatlin