GithubHelp home page GithubHelp logo

Compability with oneway.test about broom HOT 3 CLOSED

tidymodels avatar tidymodels commented on August 20, 2024
Compability with oneway.test

from broom.

Comments (3)

artemklevtsov avatar artemklevtsov commented on August 20, 2024

Quick fix. In the tidy.htest add:

    if (length(x$parameter) > 1) {
        ret$parameter <- NULL
        ret <- c(ret, x$parameter[1], x$parameter[2])
    }

Result:

> tidy(oneway.test(extra ~ group, data = sleep))
  statistic p.value num.df denom.df
1     3.463 0.07939             1             17.78

Another way:

    if (length(x$parameter) > 1) {
        ret$parameter <- NULL
        ret <- append(ret, c(x$parameter[1], x$parameter[2]), after = 1)
    }

As result more clear output:

> tidy(oneway.test(extra ~ group, data = sleep))
  statistic num.df denom.df p.value
1     3.463      1    17.78 0.07939

from broom.

artemklevtsov avatar artemklevtsov commented on August 20, 2024

Also we can totally rewrite tidy.htest function. For example:

tidy.htest <- function(x) {
    to.drop <- c("method", "data.name", "null.value", "alternative") # place here what you want
    res <- x[-pmatch(to.drop, names(x))]
    res <- unlist(res)
    # cleanup names
    names(res) <- gsub("(statistic|parameter|estimate)\\.", "", names(res))
    names(res) <- gsub("conf.int1", "conf.low", names(res))
    names(res) <- gsub("conf.int2", "conf.high", names(res))
    res <- as.data.frame(as.list(res))
    rownames(res) <- x$data.name
    return(res)
}

Note, in this variant we preserve an original names of tests.

Examples:

> tidy(cor.test(~ CONT + INTG, data = USJudgeRatings))
                    t df p.value     cor conf.low conf.high
CONT and INTG -0.8605 41  0.3945 -0.1332  -0.4169    0.1741
> tidy(t.test(extra ~ group, data = sleep))
                    t    df p.value conf.low conf.high mean.in.group.1 mean.in.group.2
extra by group -1.861 17.78 0.07939   -3.365    0.2055            0.75            2.33

from broom.

github-actions avatar github-actions commented on August 20, 2024

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

from broom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.