在示例函数中运行不运行部分示例

问题描述 投票:0回答:1

我想在

dontrun
函数中运行
example
部分示例。尝试了
run.dontrun=TRUE
run.dontrun = FALSE
选项,但得到相同的输出。任何想法。

install.packages("eda4treeR")

带有

run.dontrun=TRUE
选项

library(eda4treeR)
example(
    topic          = "Exam8.2"
  , package        = "eda4treeR"
  , lib.loc        = NULL
  , character.only = c(TRUE, FALSE)[2]
  , give.lines     = c(TRUE, FALSE)[2]
  , local          = c(TRUE, FALSE)[2]
  , type           = c("console", "html")[2]
  , echo           = c(TRUE, FALSE)[1]
  , verbose        = getOption("verbose")
  , setRNG         = c(TRUE, FALSE)[1]
  , ask            = getOption("example.ask")
  , prompt.prefix  = NULL
  , run.dontrun    = c(TRUE, FALSE)[1]
  , run.donttest   = c(TRUE, FALSE)[2]
  )

### ** Examples

library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
library(supernova)

data(DataExam8.2)

# Pg.
fm8.2  <-
  lmer(
    formula = dbhmean ~ Repl + Column + Contcompf + Contcompf:Standard +
              (1|Repl:Row ) + (1|Repl:Column ) + (1|Contcompv:Clone)
  , data    = DataExam8.2
    )
fixed-effect model matrix is rank deficient so dropping 5 columns / coefficients
## Not run: 
##D varcomp(fm8.2)
## End(Not run)
anova(fm8.2)
Missing cells for: Contcompf0:Standard0, Contcompf1:StandardUG323, Contcompf1:StandardU6, Contcompf1:StandardPN14, Contcompf1:StandardSSOseed.  
Interpret type III hypotheses with care.
Type III Analysis of Variance Table with Satterthwaite's method
                    Sum Sq Mean Sq NumDF   DenDF F value
Repl                3.2720  0.8180     4  26.467  2.0489
Column              3.1018  0.6204     5  19.545  1.5539
Contcompf           5.3203  5.3203     1  54.905 13.3265
Contcompf:Standard 20.6587  6.8862     3 207.152 17.2488
                            Pr(>F)    
Repl                     0.1162606    
Column                   0.2194719    
Contcompf                0.0005845 ***
Contcompf:Standard 0.0000000004896 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(fm8.2, type = "II", test.statistic = "Chisq")
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: dbhmean
                     Chisq Df Pr(>Chisq)    
Repl                8.1957  4    0.08467 .  
Column              7.7694  5    0.16941    
Contcompf           4.6841  1    0.03044 *  
Contcompf:Standard 51.7463  3  3.392e-11 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
predictmeans(model = fm8.2, modelterm = "Repl")
Warning in Kmatrix(model, modelterm, covariate, prtnum = prtnum):
Missing treatments' combination appeared, predicted means maybe
misleading!
Warning in Kmatrix(model, modelterm): Missing treatments' combination
appeared, predicted means maybe misleading!
$`Predicted Means`
Repl
     1      2      3      4      5 
7.8926 8.2070 8.3429 8.4604 8.5464 

$`Standard Error of Means`
Repl
      1       2       3       4       5 
0.33123 0.33126 0.32992 0.32992 0.32992 

$`Standard Error of Differences`
  Max.SED   Min.SED  Aveg.SED 
0.2239675 0.2167320 0.2196681 

$LSD
 Max.LSD  Min.LSD Aveg.LSD 
 0.44792  0.43345  0.43932 
attr(,"Significant level")
[1] 0.05
attr(,"Degree of freedom")
[1] 60.56

$mean_table
  Repl   Mean      SE       Df LL(95%) UL(95%)
1    1 7.8926 0.33123 60.55892  7.2302  8.5551
2    2 8.2070 0.33126 60.55892  7.5445  8.8695
3    3 8.3429 0.32992 60.55892  7.6831  9.0027
4    4 8.4604 0.32992 60.55892  7.8006  9.1202
5    5 8.5464 0.32992 60.55892  7.8866  9.2062
predictmeans(model = fm8.2, modelterm = "Column")
Warning in Kmatrix(model, modelterm, covariate, prtnum = prtnum):
Missing treatments' combination appeared, predicted means maybe
misleading!

Warning in Kmatrix(model, modelterm, covariate, prtnum = prtnum):
Missing treatments' combination appeared, predicted means maybe
misleading!
$`Predicted Means`
Column
     1      2      3      4      5      6 
8.2214 8.4708 8.3779 7.9721 7.8166 8.7141 

$`Standard Error of Means`
Column
      1       2       3       4       5       6 
0.31662 0.39168 0.39315 0.26648 0.26646 0.31653 

$`Standard Error of Differences`
  Max.SED   Min.SED  Aveg.SED 
0.2714760 0.2102583 0.2373610 

$LSD
 Max.LSD  Min.LSD Aveg.LSD 
 0.54413  0.42143  0.47575 
attr(,"Significant level")
[1] 0.05
attr(,"Degree of freedom")
[1] 54.65

$mean_table
  Column   Mean      SE       Df LL(95%) UL(95%)
1      1 8.2214 0.31662 54.64679  7.5868  8.8561
2      2 8.4708 0.39168 54.64679  7.6857  9.2558
3      3 8.3779 0.39315 54.64679  7.5900  9.1659
4      4 7.9721 0.26648 54.64679  7.4380  8.5063
5      5 7.8166 0.26646 54.64679  7.2825  8.3507
6      6 8.7141 0.31653 54.64679  8.0797  9.3486
library(emmeans)
emmeans(object = fm8.2, specs = ~Contcompf|Standard)
NOTE: A nesting structure was detected in the fitted model:
    Standard %in% Contcompf
Contcompf = 1, Standard = 0:
 emmean    SE   df lower.CL upper.CL
   8.91 0.117 65.9     8.67     9.14

Contcompf = 0, Standard = UG323:
 emmean    SE   df lower.CL upper.CL
   8.97 0.770 55.6     7.43    10.51

Contcompf = 0, Standard = U6:
 emmean    SE   df lower.CL upper.CL
   6.55 0.770 55.5     5.01     8.10

Contcompf = 0, Standard = PN14:
 emmean    SE   df lower.CL upper.CL
   7.70 0.771 55.8     6.16     9.25

Contcompf = 0, Standard = SSOseed:
 emmean    SE   df lower.CL upper.CL
   6.08 0.770 55.5     4.54     7.63

Results are averaged over the levels of: Repl, Column 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

带有

run.dontrun=FALSE
选项

example(
    topic          = "Exam8.2"
  , package        = "eda4treeR"
  , lib.loc        = NULL
  , character.only = c(TRUE, FALSE)[2]
  , give.lines     = c(TRUE, FALSE)[2]
  , local          = c(TRUE, FALSE)[2]
  , type           = c("console", "html")[2]
  , echo           = c(TRUE, FALSE)[1]
  , verbose        = getOption("verbose")
  , setRNG         = c(TRUE, FALSE)[1]
  , ask            = getOption("example.ask")
  , prompt.prefix  = NULL
  , run.dontrun    = c(TRUE, FALSE)[2]
  , run.donttest   = c(TRUE, FALSE)[2]
  )

### ** Examples

library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
library(supernova)

data(DataExam8.2)

# Pg.
fm8.2  <-
  lmer(
    formula = dbhmean ~ Repl + Column + Contcompf + Contcompf:Standard +
              (1|Repl:Row ) + (1|Repl:Column ) + (1|Contcompv:Clone)
  , data    = DataExam8.2
    )
fixed-effect model matrix is rank deficient so dropping 5 columns / coefficients
## Not run: 
##D varcomp(fm8.2)
## End(Not run)
anova(fm8.2)
Missing cells for: Contcompf0:Standard0, Contcompf1:StandardUG323, Contcompf1:StandardU6, Contcompf1:StandardPN14, Contcompf1:StandardSSOseed.  
Interpret type III hypotheses with care.
Type III Analysis of Variance Table with Satterthwaite's method
                    Sum Sq Mean Sq NumDF   DenDF F value
Repl                3.2720  0.8180     4  26.467  2.0489
Column              3.1018  0.6204     5  19.545  1.5539
Contcompf           5.3203  5.3203     1  54.905 13.3265
Contcompf:Standard 20.6587  6.8862     3 207.152 17.2488
                            Pr(>F)    
Repl                     0.1162606    
Column                   0.2194719    
Contcompf                0.0005845 ***
Contcompf:Standard 0.0000000004896 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(fm8.2, type = "II", test.statistic = "Chisq")
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: dbhmean
                     Chisq Df Pr(>Chisq)    
Repl                8.1957  4    0.08467 .  
Column              7.7694  5    0.16941    
Contcompf           4.6841  1    0.03044 *  
Contcompf:Standard 51.7463  3  3.392e-11 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
predictmeans(model = fm8.2, modelterm = "Repl")
Warning in Kmatrix(model, modelterm, covariate, prtnum = prtnum):
Missing treatments' combination appeared, predicted means maybe
misleading!
Warning in Kmatrix(model, modelterm): Missing treatments' combination
appeared, predicted means maybe misleading!
$`Predicted Means`
Repl
     1      2      3      4      5 
7.8926 8.2070 8.3429 8.4604 8.5464 

$`Standard Error of Means`
Repl
      1       2       3       4       5 
0.33123 0.33126 0.32992 0.32992 0.32992 

$`Standard Error of Differences`
  Max.SED   Min.SED  Aveg.SED 
0.2239675 0.2167320 0.2196681 

$LSD
 Max.LSD  Min.LSD Aveg.LSD 
 0.44792  0.43345  0.43932 
attr(,"Significant level")
[1] 0.05
attr(,"Degree of freedom")
[1] 60.56

$mean_table
  Repl   Mean      SE       Df LL(95%) UL(95%)
1    1 7.8926 0.33123 60.55892  7.2302  8.5551
2    2 8.2070 0.33126 60.55892  7.5445  8.8695
3    3 8.3429 0.32992 60.55892  7.6831  9.0027
4    4 8.4604 0.32992 60.55892  7.8006  9.1202
5    5 8.5464 0.32992 60.55892  7.8866  9.2062
predictmeans(model = fm8.2, modelterm = "Column")
Warning in Kmatrix(model, modelterm, covariate, prtnum = prtnum):
Missing treatments' combination appeared, predicted means maybe
misleading!

Warning in Kmatrix(model, modelterm, covariate, prtnum = prtnum):
Missing treatments' combination appeared, predicted means maybe
misleading!
$`Predicted Means`
Column
     1      2      3      4      5      6 
8.2214 8.4708 8.3779 7.9721 7.8166 8.7141 

$`Standard Error of Means`
Column
      1       2       3       4       5       6 
0.31662 0.39168 0.39315 0.26648 0.26646 0.31653 

$`Standard Error of Differences`
  Max.SED   Min.SED  Aveg.SED 
0.2714760 0.2102583 0.2373610 

$LSD
 Max.LSD  Min.LSD Aveg.LSD 
 0.54413  0.42143  0.47575 
attr(,"Significant level")
[1] 0.05
attr(,"Degree of freedom")
[1] 54.65

$mean_table
  Column   Mean      SE       Df LL(95%) UL(95%)
1      1 8.2214 0.31662 54.64679  7.5868  8.8561
2      2 8.4708 0.39168 54.64679  7.6857  9.2558
3      3 8.3779 0.39315 54.64679  7.5900  9.1659
4      4 7.9721 0.26648 54.64679  7.4380  8.5063
5      5 7.8166 0.26646 54.64679  7.2825  8.3507
6      6 8.7141 0.31653 54.64679  8.0797  9.3486
library(emmeans)
emmeans(object = fm8.2, specs = ~Contcompf|Standard)
NOTE: A nesting structure was detected in the fitted model:
    Standard %in% Contcompf
Contcompf = 1, Standard = 0:
 emmean    SE   df lower.CL upper.CL
   8.91 0.117 65.9     8.67     9.14

Contcompf = 0, Standard = UG323:
 emmean    SE   df lower.CL upper.CL
   8.97 0.770 55.6     7.43    10.51

Contcompf = 0, Standard = U6:
 emmean    SE   df lower.CL upper.CL
   6.55 0.770 55.5     5.01     8.10

Contcompf = 0, Standard = PN14:
 emmean    SE   df lower.CL upper.CL
   7.70 0.771 55.8     6.16     9.25

Contcompf = 0, Standard = SSOseed:
 emmean    SE   df lower.CL upper.CL
   6.08 0.770 55.5     4.54     7.63

Results are averaged over the levels of: Repl, Column 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95
r documentation document example eda4treer
1个回答
0
投票

感谢您为我更新问题,这似乎是一个

utils::example
R 函数问题。

我发现您遇到的问题只有在您使用

type="html"
时才存在,并且
type="console"
工作得很好。

我可以在我的上重现

library(eda4treeR)
example(
    topic = "Exam8.2",
    package = "eda4treeR", 
    run.dontrun = c(TRUE, FALSE)[1], 
    type = c("console", "html")[1]
)
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.0

我进一步调查它并进入

utils::example
的内部结构。 对于 HTML 类型输出,该函数使用每个包的 HTML 项目(如演示/示例/文档)访问 R DB。该数据库是使用默认设置构建的,因此
run.dontrun
不会对结果产生任何影响。

例如,我可以使用

mice::mice
访问
http://127.0.0.1:24851/library/mice/Example/mice
示例 你应该能够通过
port <- tools::startDynamicHelp(NA)

获得端口
© www.soinside.com 2019 - 2024. All rights reserved.