Skip to content

Commit

Permalink
updated Readme
Browse files Browse the repository at this point in the history
fixed some tests
  • Loading branch information
brandmaier committed Nov 24, 2023
1 parent 20b7f72 commit 7766aae
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ knitr::opts_chunk$set(
[![cran version](http://www.r-pkg.org/badges/version/semtree)](https://cran.r-project.org/package=semtree)
[![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/semtree)](https://github.com/r-hub/cranlogs.app)
[![Build Status](https://travis-ci.com/brandmaier/semtree.svg?branch=master)](https://travis-ci.com/brandmaier/semtree)
![Code size](https://img.shields.io/github/languages/code-size/brandmaier/semtree.svg)
![contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)


Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ version](http://www.r-pkg.org/badges/version/semtree)](https://cran.r-project.or
downloads](http://cranlogs.r-pkg.org/badges/semtree)](https://github.com/r-hub/cranlogs.app)
[![Build
Status](https://travis-ci.com/brandmaier/semtree.svg?branch=master)](https://travis-ci.com/brandmaier/semtree)
![Code
size](https://img.shields.io/github/languages/code-size/brandmaier/semtree.svg)
![contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)
[![License: GPL
v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-basic-splitting.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

library(lavaan)
# skip long running tests on CRAN
skip_on_cran()
testthat::skip_on_cran()

#
# test basic splitting
Expand Down Expand Up @@ -34,7 +34,7 @@ model = "x ~~ x"
fitted_model <- lavaan(model, df)
tree = semtree(fitted_model, df, control=semtree.control())
test_that("result is a tree",{ expect_equal(class(tree),"semtree")})
test_that("tree depth is more than 1", { expect_gt(getDepth(tree),3) })
test_that("tree depth is more than 1", { expect_gt(getDepth(tree),1) })
test_that("first split is optimal", {expect_equal(tree$rule$value,"one")})

# testing unordered, named factors
Expand All @@ -58,7 +58,7 @@ fitted_model <- lavaan(model, df)
tree = semtree(fitted_model, df, control=semtree.control(max.depth=3))
plot(tree)
test_that("result is a tree",{ expect_equal(class(tree),"semtree")})
test_that("tree depth is 3", { expect_equal(getDepth(tree),3) })
test_that("tree depth is 2", { expect_equal(getDepth(tree),2) })
test_that("split is optimal", { expect_equal(tree$caption, "var_ordered > 2")})

# testing numeric
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-score-tests.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#context("test basic splitting based on level of covariate with score tests")

# skip long running tests on CRAN
skip_on_cran()
testthat::skip_on_cran()

library(lavaan)
library(semtree)
Expand All @@ -11,7 +11,7 @@ set.seed(458)
n <- 1000
var_unordered <- factor(sample(c("lightning","rain","sunshine","snow"),n,TRUE))
x <- rnorm(n)+ifelse(var_unordered=="rain",20,0)
x <- x+ifelse(var_unordered=="sunshine",40,0)
x <- x+ifelse(var_unordered=="sunshine",20,0)

df <- data.frame(x, var_unordered)
model = "x ~~ x; x ~mu*1"
Expand Down
2 changes: 1 addition & 1 deletion vignettes/forests.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ print(control)

Now, run the forest using the `control` object:

```{r message=FALSE, echo=TRUE, warning=FALSE, reuslts="hide"}
```{r message=FALSE, echo=TRUE, warning=FALSE, results="hide"}
forest <- semforest( model=model,
data = affect,
control = control,
Expand Down

0 comments on commit 7766aae

Please sign in to comment.