小编Bah*_*482的帖子

DT:有没有办法在 google colab 中使用 r 作为交互式表格来显示数据帧?

您是否知道使用 R 在 colab 中显示数据框的“好”方法,最好是作为交互式表格?我正在尝试下面的代码(我通常在 rstudio 中使用),但它在 colab 中不起作用。

library(datasets)

data(iris)

library(DT)
DT::datatable(iris) #this typically displays a beautiful interactive html table, but not working with colab


#these display a simple table
View(iris)

fix(iris)
Run Code Online (Sandbox Code Playgroud)

我做了一些搜索,看起来有一种很好的方法可以在 python 下的 colab 中显示带有过滤器的交互式表https://colab.research.google.com/notebooks/data_table.ipynb#scrollTo=jcQEX_3vHOUz

但我找不到 R 的类似内容。您有什么建议吗?

谢谢

r dataframe dt google-colaboratory

6
推荐指数
1
解决办法
813
查看次数

使用 Caret 包的测试集的 ROC 曲线

我正在尝试从测试集上的插入符号中获取最佳模型的 ROC 曲线。我遇到了MLeval一个看起来很方便的包(输出非常彻底,使用几​​行代码提供了所有需要的指标和图表)。一个很好的例子在这里:https : //stackoverflow.com/a/59134729/12875646

我正在尝试下面的代码,并且能够获得训练集所需的指标/图表,但是当我尝试在测试集上工作时不断出错。

library(caret)
library(MLeval)
data(GermanCredit)

Train <- createDataPartition(GermanCredit$Class, p=0.6, list=FALSE)
training <- GermanCredit[ Train, ]
testing <- GermanCredit[ -Train, ]


ctrl <- trainControl(method = "repeatedcv", number = 10, classProbs = TRUE, savePredictions = TRUE)

mod_fit <- train(Class ~ Age + ForeignWorker + Property.RealEstate + Housing.Own + 
    CreditHistory.Critical,  data=training, method="glm", family="binomial",
    trControl = ctrl, tuneLength = 5, metric = "ROC")

pred <- predict(mod_fit, newdata=testing)
confusionMatrix(data=pred, testing$Class)

test = evalm(mod_fit) # this gives the ROC …
Run Code Online (Sandbox Code Playgroud)

r roc r-caret

3
推荐指数
1
解决办法
681
查看次数

将操作按钮与 R flexdashboard 一起使用

是否可以在 R flexdashboard 中使用操作按钮?

例如,在下面的代表中,是否可以添加一个按钮,以便代码仅在显示按钮时运行?

我在网站上找不到文档https://garrettgman.github.io/rmarkdown/flexdashboard/using.html#html_widgets

谷歌处理的大部分信息都是在“纯粹”的闪亮应用程序中使用操作按钮而不是flexdashboard。

---
title: "example"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
```

Column {data-width=100}
-----------------------------------------------------------------------

### Chart A

```{r}
numericInput("n1", "First number", 10)  


```

Column {data-width=900}
-----------------------------------------------------------------------

### Chart B

```{r}

DT::renderDataTable({
  

x = sample(1:input$n1, size=500, replace=TRUE)
x= as.data.frame(x)

  DT::datatable(x, options = list(
    bPaginate = FALSE
  ))
})


```
Run Code Online (Sandbox Code Playgroud)

r shiny flexdashboard

1
推荐指数
1
解决办法
2147
查看次数

标签 统计

r ×3

dataframe ×1

dt ×1

flexdashboard ×1

google-colaboratory ×1

r-caret ×1

roc ×1

shiny ×1