带有日期列输出的 data.frame 在 RStudio 控制台中,预览,但不在块下方 [英] data.frame with Date column ouput in RStudio console,preview, but not below the chunk

查看:43
本文介绍了带有日期列输出的 data.frame 在 RStudio 控制台中,预览,但不在块下方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Rstudio 3.3.2 的笔记本:

Using Rstudio 3.3.2's notebook :

---
title: "R Notebook"
output: html_notebook
---

当尝试显示带有日期列的 data.frame 时,data.frame 显示在查看器选项卡中,但不在块本身下方:

When trying to display a data.frame with a Date column, the data.frame is displayed in the Viewer tab, but not below the chunk itself :

    ```{r}
    df <- data.frame(date=c("31/08/2011", "31/07/2011", "30/06/2011"),values=c(0.8378,0.8457,0.8147))               

    #no Date format ->OK, output below the chunk
    df

    df$dateformatted<-as.Date(strptime(df$date,'%d/%m/%Y'))

    #with Date format -> NOK, no output below the chunk,only in Viewer.
    df 

    ```

RStudio 诊断:

RStudio diagnostics :

26 Feb 2017 20:42:00 [rsession-x] ERROR r error 7 (Unexpected data type); OCCURRED AT: rstudio::core::Error rstudio::r::json::{anonymous}::jsonValueFromVectorElement(SEXP, int, rstudio::core::json::Value*) /home/ubuntu/rstudio/src/cpp/r/RJson.cpp:149; LOGGED FROM: void rstudio::session::modules::rmarkdown::notebook::enqueueChunkOutput(const string&, const string&, const string&, unsigned int, ChunkOutputType, const rstudio::core::FilePath&, const Value&) /home/ubuntu/rstudio/src/cpp/session/modules/rmarkdown/NotebookOutput.cpp:449

这个问题.

有谁知道我做错了什么?非常感谢.

Does anyone knows what did I do wrong ? Thanks a lot in advance.

推荐答案

这确实是 RStudio 当前版本中的一个错误:包含 Date 对象的 data.frames 在笔记本中没有正确呈现.您可以尝试安装最新的 RStudio 每日版本并确认问题已解决:

This is indeed a bug in the current release of RStudio: data.frames containing Date objects are not rendered properly in notebooks. You might try installing the latest daily build of RStudio and confirming the issue is resolved there:

http://dailies.rstudio.com

这篇关于带有日期列输出的 data.frame 在 RStudio 控制台中,预览,但不在块下方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆