Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bar Chart for Categorical Data

    I am trying to create a bar chart to represent the frequencies of grades for 20 students. I created a variable in the data editor called Letter_Grade and input the 20 letter grades in the column. However, I can't figure out how to get stata to treat each of the grades differently and display the frequency counts for A, B, C, D, F grades. Do I need to create individual variables for each grade? Very new to stata...

  • #2
    See -help graph bar- . Please read the -FAQ Section- on how to make meaningful post and provide data examples so that people can help you.
    Roman

    Comment


    • #3
      That doesn't help, this isn't an issue of not knowing the correct code line, it's a question of correct variable usage. I have 20 letter grades (A,B,C,D,F) and need to create a bar graph that displays their frequency relative to one another. When I create the bar graph, it just shows one column with a frequency count of 20, when instead I want it to have 5 different columns for each grade. But this would require 5 variables, but I only want one variable, the letter grade. I have been unable to find any previous answers on how to deal with this.

      Comment


      • #4
        as Roman says, reading the FAQ and posting a better question would help us help you; however, my guess is that you want something like
        Code:
        gr bar, over(Letter_Grade)

        Comment


        • #5
          I am trying to use stata and it's data editor program to create a vertical bar chart that displays the frequencies of each letter grade, A , B, C, D, F. I can't figure out how to do this. How would I go about doing this?
          Click image for larger version

Name:	stata question.png
Views:	1
Size:	11.3 KB
ID:	1355841

          Comment


          • #6
            After Rich, another wild guess from me. Install the program first and run the command:

            Code:
            ssc install catplot
            
            catplot Letter_Grade, recast(bar)
            Roman

            Comment


            • #7
              For the bar graph, the default option is to give you the frequency of each category in the code provided by Rich. A slight modification to his suggestion gives you frequencies instead.

              gr bar (count), over(Letter_Grade)

              And similarly, -gr pie, over(Letter_Grade)-

              Comment


              • #8
                Thanks to Rich and Leonardo, Rich's code created a percentage for each letter grade while Leonardo's created an actual count, or frequency, of each grade. Why/how did you know that modifying the code from simply listing the variable and instead adding the over(variable) would deal with the issue of the graph simply displaying a single vertical bar?

                Comment


                • #9
                  It may help to read the documentation for the bar graph by typing -help graph bar-. Likewise, you can look up help/documentation for every command by using the -help- command. You can even learn more about help by typing -help help- (help about help).

                  Comment


                  • #10
                    I agree with Leonardo - I knew the answer because I looked at the help file, especially the examples

                    Comment

                    Working...
                    X