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