Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base R Terminal error on R: Run from Beginning to Line #1499

Open
grcatlin opened this issue Mar 7, 2024 · 1 comment
Open

Base R Terminal error on R: Run from Beginning to Line #1499

grcatlin opened this issue Mar 7, 2024 · 1 comment
Labels

Comments

@grcatlin
Copy link

grcatlin commented Mar 7, 2024

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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = auc_plot@x.values,
        y = auc_plot@y.values
    )
    colnames(auc_dat) <- c(auc_plot@x.name, auc_plot@y.name)

    # ggplot2 object
    auc_plot <- ggplot2::ggplot(
        auc_dat,
        ggplot2::aes(
            x = .data[[auc_plot@x.name]],
            y = .data[[auc_plot@y.name]]
        )
    ) +
        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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
        y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@x.values |> unlist(),
+         y = cut@y.values |> unlist(),
        alpha = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@alpha.values |> unlist()
    )
    colnames(cut_df) <- c(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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(cut@x.name, cut@y.name, cut@alpha.name)
    cut_df <- cut_df |>
        data.table::as.data.table() |>
        data.table::melt.data.table(id.vars = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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 = cut@alpha.name)

    cut_plot <- ggplot2::ggplot(
        cut_df,
        ggplot2::aes(
            x = .data[[cut@alpha.name]],
            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[[cut@alpha.name]],
            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[[cut@alpha.name]],
            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[[cut@alpha.name]],
            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[[cut@alpha.name]],
            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[[cut@alpha.name]],
            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[[cut@alpha.name]],
            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 grcatlin added the bug label Mar 7, 2024
@grcatlin
Copy link
Author

grcatlin commented Mar 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant