How to resolve variable length differ issue?The difference between bracket [ ] and double bracket [[ ]] for accessing the elements of a list or dataframeHow to sort a dataframe by multiple column(s)How to join (merge) data frames (inner, outer, left, right)How to sum a variable by groupWhat are the differences between “=” and “<-” in R?What is the difference between require() and library()?How to make a great R reproducible exampleHow to check if object (variable) is defined in R?How to find the length of a string in RHow can we make xkcd style graphs?

LED glows slightly during soldering

Why is the ladder of the LM always in the dark side of the LM?

How to tell someone I'd like to become friends without letting them think I'm romantically interested in them?

Why isn't pressure filtration popular compared to vacuum filtration?

When an electron changes its spin, or any other intrinsic property, is it still the same electron?

Are there any balance issues in allowing two half-feats to be taken without the Ability Score Increase instead of a feat?

How can a dictatorship government be beneficial to a dictator in a post-scarcity society?

Employers keep telling me my college isn't good enough - is there any way to fix this?

Is anyone advocating the promotion of homosexuality in UK schools?

What does the phrase "head down the rat's hole" mean here?

How can I effectively communicate to recruiters that a phone call is not possible?

Is a request to book a business flight ticket for a graduate student an unreasonable one?

Extract string from each line of a file

Sharing shapefile collection

GDPR rights when subject dies; does family inherit subject rights?

Can Jimmy hang on his rope?

Great Unsolved Problems in O.R

Plotting a function defined by equation without closed form solution

How do we handle pauses in a dialogue?

Is it OK to leave real names & info visible in business card portfolio?

What is this little owl-like bird?

Is "De qui parles-tu" (for example) as formal as it is in English, or is it normal for the French to casually say that

Is there a strong legal guarantee that the U.S. can give to another country that it won't attack them?

Why weren't bootable game disks ever common on the IBM PC?



How to resolve variable length differ issue?


The difference between bracket [ ] and double bracket [[ ]] for accessing the elements of a list or dataframeHow to sort a dataframe by multiple column(s)How to join (merge) data frames (inner, outer, left, right)How to sum a variable by groupWhat are the differences between “=” and “<-” in R?What is the difference between require() and library()?How to make a great R reproducible exampleHow to check if object (variable) is defined in R?How to find the length of a string in RHow can we make xkcd style graphs?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a dataset that looks like this, I am trying to perform the Kruskal Wallis test on it



enter image description here



The r code for it is as follows:



my_data <- read.csv('NBvariants_KWtest.csv',header = TRUE)
head(my_data)
levels(my_data$NaiveBayesvariant)
my_data$NaiveBayesvariant <- ordered(my_data$NaiveBayesvariant,
levels = c("I", "II", "III","IV","V","VI"))
library(dplyr)
group_by(my_data, NaiveBayesvariant) %>%
summarise(
count = n(),
mean = mean(accuracy, na.rm = TRUE),
sd = sd(accuracy, na.rm = TRUE),
median = median(accuracy, na.rm = TRUE),
IQR = IQR(accuracy, na.rm = TRUE)
)

library("ggpubr")
ggboxplot(my_data, x = "NaiveBayesvariant", y = "Accuracy",
color = "NaiveBayesvariant", palette = c("#00AFBB", "#E7B800", "#FC4E07","#00AFBB", "#E7B800", "#FC4E07"),
order = c("I", "II", "III","IV","V","VI"),
ylab = "Accuracy", xlab = "Naive Bayes variant")

ggline(my_data, x = "NaiveBayesvariant", y = "Accuracy",
add = c("mean_se", "jitter"),
order = c("I", "II", "III","IV", "V", "VI"),
ylab = "Naive Bayes variant", xlab = "Accuracy")


kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data)


However, I am getting this error:



> kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data)
Error in model.frame.default(formula = accuracy ~ NaiveBayesvariant, data = my_data) :
variable lengths differ (found for 'NaiveBayesvariant')
> kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data









share|improve this question

















  • 2





    Please include reproducible and copy&paste-able sample data (using e.g. dput). Screenshots of data/code are never a good idea as we can't extract information from an image. Also please don't post code that is not relevant to your issue. For example, the plotting seems to have nothing to do with your issue. Ditto for the summarisation.

    – Maurits Evers
    Mar 26 at 1:35







  • 2





    I would add that you should post only a minimum, complete, and verifiable example (MCVE). No need to share your ggboxplot code or other irrelevant calculations.

    – Dan Y
    Mar 26 at 2:01







  • 1





    A KW test is usually a two sample test and you don't seem to ahve that setup. Can you clearly state the hypothesis you are hoping to test? (I suspect not.) So it may not be helpful to post data in text form, since it's not clear you have a firm grasp on statistical issues. Other issue might be "Accuracy" != "accuracy"

    – 42-
    Mar 26 at 2:24


















0















I have a dataset that looks like this, I am trying to perform the Kruskal Wallis test on it



enter image description here



The r code for it is as follows:



my_data <- read.csv('NBvariants_KWtest.csv',header = TRUE)
head(my_data)
levels(my_data$NaiveBayesvariant)
my_data$NaiveBayesvariant <- ordered(my_data$NaiveBayesvariant,
levels = c("I", "II", "III","IV","V","VI"))
library(dplyr)
group_by(my_data, NaiveBayesvariant) %>%
summarise(
count = n(),
mean = mean(accuracy, na.rm = TRUE),
sd = sd(accuracy, na.rm = TRUE),
median = median(accuracy, na.rm = TRUE),
IQR = IQR(accuracy, na.rm = TRUE)
)

library("ggpubr")
ggboxplot(my_data, x = "NaiveBayesvariant", y = "Accuracy",
color = "NaiveBayesvariant", palette = c("#00AFBB", "#E7B800", "#FC4E07","#00AFBB", "#E7B800", "#FC4E07"),
order = c("I", "II", "III","IV","V","VI"),
ylab = "Accuracy", xlab = "Naive Bayes variant")

ggline(my_data, x = "NaiveBayesvariant", y = "Accuracy",
add = c("mean_se", "jitter"),
order = c("I", "II", "III","IV", "V", "VI"),
ylab = "Naive Bayes variant", xlab = "Accuracy")


kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data)


However, I am getting this error:



> kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data)
Error in model.frame.default(formula = accuracy ~ NaiveBayesvariant, data = my_data) :
variable lengths differ (found for 'NaiveBayesvariant')
> kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data









share|improve this question

















  • 2





    Please include reproducible and copy&paste-able sample data (using e.g. dput). Screenshots of data/code are never a good idea as we can't extract information from an image. Also please don't post code that is not relevant to your issue. For example, the plotting seems to have nothing to do with your issue. Ditto for the summarisation.

    – Maurits Evers
    Mar 26 at 1:35







  • 2





    I would add that you should post only a minimum, complete, and verifiable example (MCVE). No need to share your ggboxplot code or other irrelevant calculations.

    – Dan Y
    Mar 26 at 2:01







  • 1





    A KW test is usually a two sample test and you don't seem to ahve that setup. Can you clearly state the hypothesis you are hoping to test? (I suspect not.) So it may not be helpful to post data in text form, since it's not clear you have a firm grasp on statistical issues. Other issue might be "Accuracy" != "accuracy"

    – 42-
    Mar 26 at 2:24














0












0








0








I have a dataset that looks like this, I am trying to perform the Kruskal Wallis test on it



enter image description here



The r code for it is as follows:



my_data <- read.csv('NBvariants_KWtest.csv',header = TRUE)
head(my_data)
levels(my_data$NaiveBayesvariant)
my_data$NaiveBayesvariant <- ordered(my_data$NaiveBayesvariant,
levels = c("I", "II", "III","IV","V","VI"))
library(dplyr)
group_by(my_data, NaiveBayesvariant) %>%
summarise(
count = n(),
mean = mean(accuracy, na.rm = TRUE),
sd = sd(accuracy, na.rm = TRUE),
median = median(accuracy, na.rm = TRUE),
IQR = IQR(accuracy, na.rm = TRUE)
)

library("ggpubr")
ggboxplot(my_data, x = "NaiveBayesvariant", y = "Accuracy",
color = "NaiveBayesvariant", palette = c("#00AFBB", "#E7B800", "#FC4E07","#00AFBB", "#E7B800", "#FC4E07"),
order = c("I", "II", "III","IV","V","VI"),
ylab = "Accuracy", xlab = "Naive Bayes variant")

ggline(my_data, x = "NaiveBayesvariant", y = "Accuracy",
add = c("mean_se", "jitter"),
order = c("I", "II", "III","IV", "V", "VI"),
ylab = "Naive Bayes variant", xlab = "Accuracy")


kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data)


However, I am getting this error:



> kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data)
Error in model.frame.default(formula = accuracy ~ NaiveBayesvariant, data = my_data) :
variable lengths differ (found for 'NaiveBayesvariant')
> kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data









share|improve this question














I have a dataset that looks like this, I am trying to perform the Kruskal Wallis test on it



enter image description here



The r code for it is as follows:



my_data <- read.csv('NBvariants_KWtest.csv',header = TRUE)
head(my_data)
levels(my_data$NaiveBayesvariant)
my_data$NaiveBayesvariant <- ordered(my_data$NaiveBayesvariant,
levels = c("I", "II", "III","IV","V","VI"))
library(dplyr)
group_by(my_data, NaiveBayesvariant) %>%
summarise(
count = n(),
mean = mean(accuracy, na.rm = TRUE),
sd = sd(accuracy, na.rm = TRUE),
median = median(accuracy, na.rm = TRUE),
IQR = IQR(accuracy, na.rm = TRUE)
)

library("ggpubr")
ggboxplot(my_data, x = "NaiveBayesvariant", y = "Accuracy",
color = "NaiveBayesvariant", palette = c("#00AFBB", "#E7B800", "#FC4E07","#00AFBB", "#E7B800", "#FC4E07"),
order = c("I", "II", "III","IV","V","VI"),
ylab = "Accuracy", xlab = "Naive Bayes variant")

ggline(my_data, x = "NaiveBayesvariant", y = "Accuracy",
add = c("mean_se", "jitter"),
order = c("I", "II", "III","IV", "V", "VI"),
ylab = "Naive Bayes variant", xlab = "Accuracy")


kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data)


However, I am getting this error:



> kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data)
Error in model.frame.default(formula = accuracy ~ NaiveBayesvariant, data = my_data) :
variable lengths differ (found for 'NaiveBayesvariant')
> kruskal.test(accuracy ~ NaiveBayesvariant, data = my_data






r kruskal-wallis






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 1:25









IronMaidenIronMaiden

7510 bronze badges




7510 bronze badges







  • 2





    Please include reproducible and copy&paste-able sample data (using e.g. dput). Screenshots of data/code are never a good idea as we can't extract information from an image. Also please don't post code that is not relevant to your issue. For example, the plotting seems to have nothing to do with your issue. Ditto for the summarisation.

    – Maurits Evers
    Mar 26 at 1:35







  • 2





    I would add that you should post only a minimum, complete, and verifiable example (MCVE). No need to share your ggboxplot code or other irrelevant calculations.

    – Dan Y
    Mar 26 at 2:01







  • 1





    A KW test is usually a two sample test and you don't seem to ahve that setup. Can you clearly state the hypothesis you are hoping to test? (I suspect not.) So it may not be helpful to post data in text form, since it's not clear you have a firm grasp on statistical issues. Other issue might be "Accuracy" != "accuracy"

    – 42-
    Mar 26 at 2:24













  • 2





    Please include reproducible and copy&paste-able sample data (using e.g. dput). Screenshots of data/code are never a good idea as we can't extract information from an image. Also please don't post code that is not relevant to your issue. For example, the plotting seems to have nothing to do with your issue. Ditto for the summarisation.

    – Maurits Evers
    Mar 26 at 1:35







  • 2





    I would add that you should post only a minimum, complete, and verifiable example (MCVE). No need to share your ggboxplot code or other irrelevant calculations.

    – Dan Y
    Mar 26 at 2:01







  • 1





    A KW test is usually a two sample test and you don't seem to ahve that setup. Can you clearly state the hypothesis you are hoping to test? (I suspect not.) So it may not be helpful to post data in text form, since it's not clear you have a firm grasp on statistical issues. Other issue might be "Accuracy" != "accuracy"

    – 42-
    Mar 26 at 2:24








2




2





Please include reproducible and copy&paste-able sample data (using e.g. dput). Screenshots of data/code are never a good idea as we can't extract information from an image. Also please don't post code that is not relevant to your issue. For example, the plotting seems to have nothing to do with your issue. Ditto for the summarisation.

– Maurits Evers
Mar 26 at 1:35






Please include reproducible and copy&paste-able sample data (using e.g. dput). Screenshots of data/code are never a good idea as we can't extract information from an image. Also please don't post code that is not relevant to your issue. For example, the plotting seems to have nothing to do with your issue. Ditto for the summarisation.

– Maurits Evers
Mar 26 at 1:35





2




2





I would add that you should post only a minimum, complete, and verifiable example (MCVE). No need to share your ggboxplot code or other irrelevant calculations.

– Dan Y
Mar 26 at 2:01






I would add that you should post only a minimum, complete, and verifiable example (MCVE). No need to share your ggboxplot code or other irrelevant calculations.

– Dan Y
Mar 26 at 2:01





1




1





A KW test is usually a two sample test and you don't seem to ahve that setup. Can you clearly state the hypothesis you are hoping to test? (I suspect not.) So it may not be helpful to post data in text form, since it's not clear you have a firm grasp on statistical issues. Other issue might be "Accuracy" != "accuracy"

– 42-
Mar 26 at 2:24






A KW test is usually a two sample test and you don't seem to ahve that setup. Can you clearly state the hypothesis you are hoping to test? (I suspect not.) So it may not be helpful to post data in text form, since it's not clear you have a firm grasp on statistical issues. Other issue might be "Accuracy" != "accuracy"

– 42-
Mar 26 at 2:24













0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348597%2fhow-to-resolve-variable-length-differ-issue%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348597%2fhow-to-resolve-variable-length-differ-issue%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript