Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201943

Resolving "Warning in if (stri_startswith_fixed(body, "{")) { :..." when using the plumber library in R

$
0
0

Currently getting this error when I make a POST request in plumber:

Warning in if (stri_startswith_fixed(body, "{")) { :
  the condition has length > 1 and only the first element will be used
Warning in if (stri_startswith_fixed(qs, "?")) { :
  the condition has length > 1 and only the first element will be used

This is what my function looks like:

#' Get results from Two Sample t-test
#' @serializer unboxedJSON
#' @param group:character The group col you would like to group data by
#' @param variable:character The variable you would like to be compared between groups
#' @post /twosamplettest/<group>/<variable>
function(req, group, variable) {
    data_as_df <- fromJSON(req$postBody)

    results <- t.test(get(variable) ~ get(group), data=data_as_df)

    group_mean_df <- extractGroupsAndMeansFromTTestResults(results)

    test_results <- list(pvalue=results$p.value, group_stats=as.data.frame(group_mean_df)))

    test_results
}

The request gets a valid response and everything is all good except for that ugly warning message that shows up in the console for every request made.

Any ideas on how to resolve it?


Viewing all articles
Browse latest Browse all 201943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>