微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

有没有办法不显示数据结构中的行名

如何解决有没有办法不显示数据结构中的行名

我只想在 str() 函数显示列的名称和列的数据类型。我试过在 server.r 上这样做,但没有成功。

ui.r

mainPanel(
              width = 12,uIoUtput("data_browsing")
            )

server.r

 output$about_file <- renderPrint({str(data(),row.names = FALSE)})

The example of data structure

解决方法

如果我们需要名称和类型,用 sapply 遍历数据集,得到 class

output$about_file <- renderPrint({
       tmp <- data()
       nm1 <- sapply(tmp,class)
       cat(paste('data.frame: ',nrow(tmp),' obs. of ',ncol(tmp),' variables:'),"\n")
      cat(paste(names(nm1),nm1,sep=";",collapse = "\n"),"\n")
   })

str 没有 row.names 参数,但它不会给出任何错误或警告消息,因为有一个 ... 参数

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。