How to present a good look result?How to sort a dataframe by multiple column(s)How to make a great R reproducible exampleprop.test on single observationsWhat's the lowest number R will present before rounding to 0?Standard Chi Squared Test in R?comparing two distributions with chi-square testChi-squared Test in R (to compare real data to theoretical normal distribution)add results of chi square test to each rowApplying a Bonferroni Correction on a chi square test result Rsignificance stars in the goodness-of-fit section

What's the difference between soft PWM and PWM

Is the Gungan military rank of Bombad General roughly equivalent in stature to General in other militaries?

How can I legally visit the United States Minor Outlying Islands in the Pacific?

How would someone destroy a black hole that’s at the centre of a planet?

Meaning of 準備ができたものから

Do native speakers use ZVE or CPU?

When is pointing out a person's hypocrisy not considered to be a logical fallacy?

How might the United Kingdom become a republic?

What's the point of this scene involving Flash Thompson at the airport?

Nested-Loop-Join: How many comparisons and how many pages-accesses?

Why is dry soil hydrophobic? Bad gardener paradox

Crab Nebula short story from 1960s or '70s

Redox reactions redefined

Are lithium batteries allowed in the International Space Station?

What caused Windows ME's terrible reputation?

Back to the nineties!

Will it hurt my career to work as a graphic designer in a startup for beauty and skin care?

Integral clarification

Filtering fine silt/mud from water (not necessarily bacteria etc.)

Won 50K! Now what should I do with it

Are villager price increases due to killing them temporary?

What is the closed form of the following recursive function?

Equivalent definitions of total angular momentum

mhchem - bold part of equation typeset with ce



How to present a good look result?


How to sort a dataframe by multiple column(s)How to make a great R reproducible exampleprop.test on single observationsWhat's the lowest number R will present before rounding to 0?Standard Chi Squared Test in R?comparing two distributions with chi-square testChi-squared Test in R (to compare real data to theoretical normal distribution)add results of chi square test to each rowApplying a Bonferroni Correction on a chi square test result Rsignificance stars in the goodness-of-fit section






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








0















I would like to present a good look result for my own functions.



I create my own function to solve some chi-square test exercises, and the result looks like that:



enter image description here



Here is my own function:



chisq.poly = function(prob, freq, significance.level = 0.95) 

#calculate chi-squared value
expect_freq<-prob*sum(freq)
dif_freq<-freq-expect_freq
dif_freq_sq<-((freq-expect_freq)^2)/expect_freq
chi_square<-sum(dif_freq_sq)
chi_square_crit<-qchisq(significance.level, length(freq)-1, lower.tail=TRUE)

#we put all necessary values into a dataframe (good for display) and then rename headers
chi_table<-data.frame(prob,freq,expect_freq,dif_freq)
colnames(chi_table)<-c("Probability","Frequency","Expected frequency","Difference")

#Finally, we show the result of test
hypothesis<-"H0: The experimental data is like the statemnent."
result<-if (chi_square>chi_square_crit) "Reject the null hypothesis. The experimental data is not like the statemnent."

else "cannot reject null hypothesis"

warning_test<-if (abs(sum(expect_freq-freq))<sum(abs(expect_freq-freq))) "The expected frequency value may be less than 5, the result cannot be properly."

else "Something good so far."

O<-list(chi_table,chi_square,chi_square_crit,hypothesis,result,warning_test)

names(O)<-c('Table','Chi_square','Critical Chi_square','Hypothesis','Result','Warning')

return(O)



And I want to fix it like this or better:



enter image description here










share|improve this question
























  • Have a look at S3 classes and create a print function for your result as described here adv-r.had.co.nz/S3.html

    – drmariod
    Mar 26 at 6:43











  • Instead of reinventing the wheel take a look at the broom library. In my opinion, your "good look result" is not very good looking, and -- perhaps more importantly -- not precise/correct from a statistical point of view. For example what does "The experimental data is not like the statement" even mean? Data are what they are! I guess you meant to say that the probability for observing data (frequencies) as extreme or more extreme (i.e. the p value) is small.

    – Maurits Evers
    Mar 26 at 7:25












  • Thank you @drmariod

    – Vĩnh Vũ Quang
    Mar 26 at 8:07











  • Thank you@MauritsEvers. My own function is about Goodness-of-Fit Test for polynomial distribution, and my bad vocabularies mislead you, sorry for this. I will try your suggestions, good guys :)

    – Vĩnh Vũ Quang
    Mar 26 at 8:14











  • stargazerit is also a good library for your purposes!

    – LocoGris
    Mar 26 at 9:41

















0















I would like to present a good look result for my own functions.



I create my own function to solve some chi-square test exercises, and the result looks like that:



enter image description here



Here is my own function:



chisq.poly = function(prob, freq, significance.level = 0.95) 

#calculate chi-squared value
expect_freq<-prob*sum(freq)
dif_freq<-freq-expect_freq
dif_freq_sq<-((freq-expect_freq)^2)/expect_freq
chi_square<-sum(dif_freq_sq)
chi_square_crit<-qchisq(significance.level, length(freq)-1, lower.tail=TRUE)

#we put all necessary values into a dataframe (good for display) and then rename headers
chi_table<-data.frame(prob,freq,expect_freq,dif_freq)
colnames(chi_table)<-c("Probability","Frequency","Expected frequency","Difference")

#Finally, we show the result of test
hypothesis<-"H0: The experimental data is like the statemnent."
result<-if (chi_square>chi_square_crit) "Reject the null hypothesis. The experimental data is not like the statemnent."

else "cannot reject null hypothesis"

warning_test<-if (abs(sum(expect_freq-freq))<sum(abs(expect_freq-freq))) "The expected frequency value may be less than 5, the result cannot be properly."

else "Something good so far."

O<-list(chi_table,chi_square,chi_square_crit,hypothesis,result,warning_test)

names(O)<-c('Table','Chi_square','Critical Chi_square','Hypothesis','Result','Warning')

return(O)



And I want to fix it like this or better:



enter image description here










share|improve this question
























  • Have a look at S3 classes and create a print function for your result as described here adv-r.had.co.nz/S3.html

    – drmariod
    Mar 26 at 6:43











  • Instead of reinventing the wheel take a look at the broom library. In my opinion, your "good look result" is not very good looking, and -- perhaps more importantly -- not precise/correct from a statistical point of view. For example what does "The experimental data is not like the statement" even mean? Data are what they are! I guess you meant to say that the probability for observing data (frequencies) as extreme or more extreme (i.e. the p value) is small.

    – Maurits Evers
    Mar 26 at 7:25












  • Thank you @drmariod

    – Vĩnh Vũ Quang
    Mar 26 at 8:07











  • Thank you@MauritsEvers. My own function is about Goodness-of-Fit Test for polynomial distribution, and my bad vocabularies mislead you, sorry for this. I will try your suggestions, good guys :)

    – Vĩnh Vũ Quang
    Mar 26 at 8:14











  • stargazerit is also a good library for your purposes!

    – LocoGris
    Mar 26 at 9:41













0












0








0








I would like to present a good look result for my own functions.



I create my own function to solve some chi-square test exercises, and the result looks like that:



enter image description here



Here is my own function:



chisq.poly = function(prob, freq, significance.level = 0.95) 

#calculate chi-squared value
expect_freq<-prob*sum(freq)
dif_freq<-freq-expect_freq
dif_freq_sq<-((freq-expect_freq)^2)/expect_freq
chi_square<-sum(dif_freq_sq)
chi_square_crit<-qchisq(significance.level, length(freq)-1, lower.tail=TRUE)

#we put all necessary values into a dataframe (good for display) and then rename headers
chi_table<-data.frame(prob,freq,expect_freq,dif_freq)
colnames(chi_table)<-c("Probability","Frequency","Expected frequency","Difference")

#Finally, we show the result of test
hypothesis<-"H0: The experimental data is like the statemnent."
result<-if (chi_square>chi_square_crit) "Reject the null hypothesis. The experimental data is not like the statemnent."

else "cannot reject null hypothesis"

warning_test<-if (abs(sum(expect_freq-freq))<sum(abs(expect_freq-freq))) "The expected frequency value may be less than 5, the result cannot be properly."

else "Something good so far."

O<-list(chi_table,chi_square,chi_square_crit,hypothesis,result,warning_test)

names(O)<-c('Table','Chi_square','Critical Chi_square','Hypothesis','Result','Warning')

return(O)



And I want to fix it like this or better:



enter image description here










share|improve this question
















I would like to present a good look result for my own functions.



I create my own function to solve some chi-square test exercises, and the result looks like that:



enter image description here



Here is my own function:



chisq.poly = function(prob, freq, significance.level = 0.95) 

#calculate chi-squared value
expect_freq<-prob*sum(freq)
dif_freq<-freq-expect_freq
dif_freq_sq<-((freq-expect_freq)^2)/expect_freq
chi_square<-sum(dif_freq_sq)
chi_square_crit<-qchisq(significance.level, length(freq)-1, lower.tail=TRUE)

#we put all necessary values into a dataframe (good for display) and then rename headers
chi_table<-data.frame(prob,freq,expect_freq,dif_freq)
colnames(chi_table)<-c("Probability","Frequency","Expected frequency","Difference")

#Finally, we show the result of test
hypothesis<-"H0: The experimental data is like the statemnent."
result<-if (chi_square>chi_square_crit) "Reject the null hypothesis. The experimental data is not like the statemnent."

else "cannot reject null hypothesis"

warning_test<-if (abs(sum(expect_freq-freq))<sum(abs(expect_freq-freq))) "The expected frequency value may be less than 5, the result cannot be properly."

else "Something good so far."

O<-list(chi_table,chi_square,chi_square_crit,hypothesis,result,warning_test)

names(O)<-c('Table','Chi_square','Critical Chi_square','Hypothesis','Result','Warning')

return(O)



And I want to fix it like this or better:



enter image description here







r displayobject






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 6:31









Uwe Keim

28.1k32 gold badges141 silver badges225 bronze badges




28.1k32 gold badges141 silver badges225 bronze badges










asked Mar 26 at 6:30









Vĩnh Vũ QuangVĩnh Vũ Quang

112 bronze badges




112 bronze badges












  • Have a look at S3 classes and create a print function for your result as described here adv-r.had.co.nz/S3.html

    – drmariod
    Mar 26 at 6:43











  • Instead of reinventing the wheel take a look at the broom library. In my opinion, your "good look result" is not very good looking, and -- perhaps more importantly -- not precise/correct from a statistical point of view. For example what does "The experimental data is not like the statement" even mean? Data are what they are! I guess you meant to say that the probability for observing data (frequencies) as extreme or more extreme (i.e. the p value) is small.

    – Maurits Evers
    Mar 26 at 7:25












  • Thank you @drmariod

    – Vĩnh Vũ Quang
    Mar 26 at 8:07











  • Thank you@MauritsEvers. My own function is about Goodness-of-Fit Test for polynomial distribution, and my bad vocabularies mislead you, sorry for this. I will try your suggestions, good guys :)

    – Vĩnh Vũ Quang
    Mar 26 at 8:14











  • stargazerit is also a good library for your purposes!

    – LocoGris
    Mar 26 at 9:41

















  • Have a look at S3 classes and create a print function for your result as described here adv-r.had.co.nz/S3.html

    – drmariod
    Mar 26 at 6:43











  • Instead of reinventing the wheel take a look at the broom library. In my opinion, your "good look result" is not very good looking, and -- perhaps more importantly -- not precise/correct from a statistical point of view. For example what does "The experimental data is not like the statement" even mean? Data are what they are! I guess you meant to say that the probability for observing data (frequencies) as extreme or more extreme (i.e. the p value) is small.

    – Maurits Evers
    Mar 26 at 7:25












  • Thank you @drmariod

    – Vĩnh Vũ Quang
    Mar 26 at 8:07











  • Thank you@MauritsEvers. My own function is about Goodness-of-Fit Test for polynomial distribution, and my bad vocabularies mislead you, sorry for this. I will try your suggestions, good guys :)

    – Vĩnh Vũ Quang
    Mar 26 at 8:14











  • stargazerit is also a good library for your purposes!

    – LocoGris
    Mar 26 at 9:41
















Have a look at S3 classes and create a print function for your result as described here adv-r.had.co.nz/S3.html

– drmariod
Mar 26 at 6:43





Have a look at S3 classes and create a print function for your result as described here adv-r.had.co.nz/S3.html

– drmariod
Mar 26 at 6:43













Instead of reinventing the wheel take a look at the broom library. In my opinion, your "good look result" is not very good looking, and -- perhaps more importantly -- not precise/correct from a statistical point of view. For example what does "The experimental data is not like the statement" even mean? Data are what they are! I guess you meant to say that the probability for observing data (frequencies) as extreme or more extreme (i.e. the p value) is small.

– Maurits Evers
Mar 26 at 7:25






Instead of reinventing the wheel take a look at the broom library. In my opinion, your "good look result" is not very good looking, and -- perhaps more importantly -- not precise/correct from a statistical point of view. For example what does "The experimental data is not like the statement" even mean? Data are what they are! I guess you meant to say that the probability for observing data (frequencies) as extreme or more extreme (i.e. the p value) is small.

– Maurits Evers
Mar 26 at 7:25














Thank you @drmariod

– Vĩnh Vũ Quang
Mar 26 at 8:07





Thank you @drmariod

– Vĩnh Vũ Quang
Mar 26 at 8:07













Thank you@MauritsEvers. My own function is about Goodness-of-Fit Test for polynomial distribution, and my bad vocabularies mislead you, sorry for this. I will try your suggestions, good guys :)

– Vĩnh Vũ Quang
Mar 26 at 8:14





Thank you@MauritsEvers. My own function is about Goodness-of-Fit Test for polynomial distribution, and my bad vocabularies mislead you, sorry for this. I will try your suggestions, good guys :)

– Vĩnh Vũ Quang
Mar 26 at 8:14













stargazerit is also a good library for your purposes!

– LocoGris
Mar 26 at 9:41





stargazerit is also a good library for your purposes!

– LocoGris
Mar 26 at 9:41












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%2f55351027%2fhow-to-present-a-good-look-result%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%2f55351027%2fhow-to-present-a-good-look-result%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

Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴