0

我正在尝试创建一个带有 ggplot2 绘图的 HTML5 演示文稿。我正在使用 Rstudio 的 Rpres 格式。但是我在输出演示中看不到任何情节。对于下面的示例,我得到一个带有如下消息的文本框:

<img src="PT terms for each age
Strata.Rnw-figure/unnamed-chunk-1-1.png" title="plot of chunk
unnamed-chunk-1" alt="plot of chunk unnamed-chunk-1" style="display:
block; margin: auto;" />

对于其他块,我根本看不到任何情节。我看到在子目录中生成的数字,但它们不包含在演示文稿中。这可能是因为我setwd用来更改其中一个块内的当前目录。

如何确保将绘图添加到演示文稿中?

```{r, echo=FALSE,fig.width=8, fig.height=4, warning=FALSE, eval=TRUE, message=FALSE, tidy=TRUE, fig.align='center',fig=TRUE}
    PT.term.table.combo.df <- structure(list(term = structure(c(3L, 6L, 10L, 9L, 5L, 8L, 2L, 
    7L, 1L, 4L, 11L, 16L, 20L, 13L, 18L, 19L, 15L, 14L, 17L, 12L), .Label = c("Erythema", 
    "Injection site erythema", "Injection site pain", "Injection site swelling", 
    "Pain", "Pain in extremity", "Paraesthesia", "Pruritus", "Rash", 
    "Urticaria", "Dizziness", "Fatigue", "Headache", "Unknown", 
    "Loss of consciousness", "Nausea", "Pallor", "Pyrexia", "Syncope", 
    "Vomiting", "Blood pressure decreased", "Condition aggravated", 
    "Convulsion", "Fall", "Grand mal convulsion", "Head injury", 
    "Immediate post-injection reaction", "Condition8", 
    "Condition2", "Condition3", "Condition4", 
    "Condition1", "Menstruation delayed", "Menstruation irregular", 
    "Condition5", "Condition12", "Unevaluable event"
    ), class = "factor"), normalized.count = structure(c(0.758666519304954, 
    0.509556068608868, 0.498746392459638, 0.426484861272957, 0.41955098519173, 
    0.333070361160926, 0.306233446655841, 0.303395720748491, 0.281332387076534, 
    0.275858307359097, 2.05157281092953, 1.55514068644281, 0.761792303294041, 
    0.730331039886107, 0.553772087835693, 0.545722098808532, 0.426814370578148, 
    0.422207780194755, 0.401335815218956, 0.325021057176447), .Names = c("Injection site pain", 
    "Pain in extremity", "Urticaria", "Rash", "Pain", "Pruritus", 
    "Injection site erythema", "Paraesthesia", "Erythema", "Injection site swelling", 
    "Dizziness", "Nausea", "Vomiting", "Headache", "Pyrexia", "Syncope", 
    "Loss of consciousness", "Hyperhidrosis", "Pallor", "Fatigue"
    )), source = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("1", 
    "2", "3", "4"), class = "factor")), .Names = c("term", "normalized.count", 
    "source"), row.names = c("Injection site pain", "Pain in extremity", 
    "Urticaria", "Rash", "Pain", "Pruritus", "Injection site erythema", 
    "Paraesthesia", "Erythema", "Injection site swelling", "Dizziness", 
    "Nausea", "Vomiting", "Headache", "Pyrexia", "Syncope", "Loss of consciousness", 
    "Hyperhidrosis", "Pallor", "Fatigue"), class = "data.frame")





    library(ggplot2)
    library(gdata)
    #PT.term.table.combo.df <- combine(lapply( PT.term.tables$communities , FUN = function(x) {  data.frame (term = names(x), normalized.count = x)}),names = 1:4) 

    PT.term.table.combo.df <- do.call(what=combine,args=lapply( PT.term.tables$communities , FUN = function(x) {  data.frame (term = names(x), normalized.count = x)}))
    levels(PT.term.table.combo.df$source)<- 1:4

    #PT.term.table <- PT.term.tables$communities[[1]]
    #term.df <- data.frame (term=names(PT.term.table), normalized.count = PT.term.table)
    PT.plot<-ggplot(data=PT.term.table.combo.df, aes(x=term, y=normalized.count )) +
      geom_bar(stat='identity') +   coord_flip()+facet_wrap(~source)
    print(PT.plot)
```    
4

1 回答 1

0

好的,我可以通过重命名我的 Rpres 文件来解决我的问题,这样它就没有任何空格。所以 "PT terms for each age Strata.Rnw.Rpres"我没有选择"PT_terms_plots.Rpres"作为文件名。如果您认为这可能是一个错误,请发表评论让我知道,以便我可以联系 Rstudio 开发人员。

于 2015-01-02T23:43:58.453 回答