Deviation chart in base graphicsDrawing line segments in RIndicate the range used for curve-fitting in R plotsPlot a line chart with conditional colors depending on valuesPlot the Profile Deviance for a GLM fit in RGantt style time line plot (in base R)ggplot2 line and dot, auto zero valueplotting a boxplot and a line plot in the same graph using ggplotGraphing Segments in RUnordered and repeated values on x-axis in a chart in xlsxwriterGraphics with multiple plots, multiple conditions and multiple linesSwift Charts with logarithmic axis

I just found out that my recent promotion comes with an unexpected 24/7/365 on-call status

Is it standard to have the first week's pay indefinitely withheld?

Why do academics prefer Mac/Linux?

Gaussian kernel density estimation with data from file

Is it a good idea to teach algorithm courses using pseudocode?

Can I modify the report menu?

Cycling to work - 30mile return

Failing students when it might cause them economic ruin

Can more than one instance of Bend Luck be applied to the same roll?

I recently started my machine learning PhD and I have absolutely no idea what I'm doing

Should all adjustments be random effects in a mixed linear effect?

multicol package causes underfull hbox

Why are there five extra turns in tournament Magic?

How come Arya Stark wasn't hurt by this in Game of Thrones Season 8 Episode 5?

Are spiritual pleasures > carnal pleasures, according to Catholicism?

Combining two Lorentz boosts

Why does a table with a defined constant in its index compute 10X slower?

Would a "ring language" be possible?

pwaS eht tirsf dna tasl setterl fo hace dorw

mirror damper material

How would fantasy dwarves exist, realistically?

How do you cope with rejection?

Who is frowning in the sentence "Daisy looked at Tom frowning"?

How to draw pentagram-like shape in Latex?



Deviation chart in base graphics


Drawing line segments in RIndicate the range used for curve-fitting in R plotsPlot a line chart with conditional colors depending on valuesPlot the Profile Deviance for a GLM fit in RGantt style time line plot (in base R)ggplot2 line and dot, auto zero valueplotting a boxplot and a line plot in the same graph using ggplotGraphing Segments in RUnordered and repeated values on x-axis in a chart in xlsxwriterGraphics with multiple plots, multiple conditions and multiple linesSwift Charts with logarithmic axis






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I need to do a deviance chart (lollipop chart with lines from the mean to values above / below the mean). From this question and answer Drawing line segments in R, it is clear that I need to plot segments and then add the points. However, my x axis is a factor and the solution fails.



This works:



df <- data.frame(ID = c(1, 2, 3),
score = c(30, 42, 48))
mid <- mean(df$score)

plot(range(df$ID), range(df$score),type="n")
segments(df$ID, df$score, df$ID, mid)


But changing my identifier variable into a factor breaks it.



df$ID2 <- factor(df$ID)
plot(range(df$ID2), range(df$score),type="n")
segments(df$ID2, df$score, df$ID2, mid)


How can I set up the plot area and x-axis values to deal with a factor?



Note that I need a base graphics solution to fit with the other charts in a dashboard style report.










share|improve this question




























    0















    I need to do a deviance chart (lollipop chart with lines from the mean to values above / below the mean). From this question and answer Drawing line segments in R, it is clear that I need to plot segments and then add the points. However, my x axis is a factor and the solution fails.



    This works:



    df <- data.frame(ID = c(1, 2, 3),
    score = c(30, 42, 48))
    mid <- mean(df$score)

    plot(range(df$ID), range(df$score),type="n")
    segments(df$ID, df$score, df$ID, mid)


    But changing my identifier variable into a factor breaks it.



    df$ID2 <- factor(df$ID)
    plot(range(df$ID2), range(df$score),type="n")
    segments(df$ID2, df$score, df$ID2, mid)


    How can I set up the plot area and x-axis values to deal with a factor?



    Note that I need a base graphics solution to fit with the other charts in a dashboard style report.










    share|improve this question
























      0












      0








      0








      I need to do a deviance chart (lollipop chart with lines from the mean to values above / below the mean). From this question and answer Drawing line segments in R, it is clear that I need to plot segments and then add the points. However, my x axis is a factor and the solution fails.



      This works:



      df <- data.frame(ID = c(1, 2, 3),
      score = c(30, 42, 48))
      mid <- mean(df$score)

      plot(range(df$ID), range(df$score),type="n")
      segments(df$ID, df$score, df$ID, mid)


      But changing my identifier variable into a factor breaks it.



      df$ID2 <- factor(df$ID)
      plot(range(df$ID2), range(df$score),type="n")
      segments(df$ID2, df$score, df$ID2, mid)


      How can I set up the plot area and x-axis values to deal with a factor?



      Note that I need a base graphics solution to fit with the other charts in a dashboard style report.










      share|improve this question














      I need to do a deviance chart (lollipop chart with lines from the mean to values above / below the mean). From this question and answer Drawing line segments in R, it is clear that I need to plot segments and then add the points. However, my x axis is a factor and the solution fails.



      This works:



      df <- data.frame(ID = c(1, 2, 3),
      score = c(30, 42, 48))
      mid <- mean(df$score)

      plot(range(df$ID), range(df$score),type="n")
      segments(df$ID, df$score, df$ID, mid)


      But changing my identifier variable into a factor breaks it.



      df$ID2 <- factor(df$ID)
      plot(range(df$ID2), range(df$score),type="n")
      segments(df$ID2, df$score, df$ID2, mid)


      How can I set up the plot area and x-axis values to deal with a factor?



      Note that I need a base graphics solution to fit with the other charts in a dashboard style report.







      r plot






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 17:07









      JenBJenB

      9,44511037




      9,44511037






















          1 Answer
          1






          active

          oldest

          votes


















          2














          You can convert the factor in a numeric variable, supress the x-axis and then add the correct labels to the plot:



          df$ID2 <- factor(letters[df$ID]) # Use letters to show that this is working

          plot(range(as.numeric(df$ID2)), range(df$score), type = "n", xaxt = "n")
          segments(as.numeric(df$ID2), df$score, as.numeric(df$ID2), mid)
          axis(1, at = seq_along(levels(df$ID2)), labels = levels(df$ID2))


          enter image description here






          share|improve this answer























            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%2f55316273%2fdeviation-chart-in-base-graphics%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            You can convert the factor in a numeric variable, supress the x-axis and then add the correct labels to the plot:



            df$ID2 <- factor(letters[df$ID]) # Use letters to show that this is working

            plot(range(as.numeric(df$ID2)), range(df$score), type = "n", xaxt = "n")
            segments(as.numeric(df$ID2), df$score, as.numeric(df$ID2), mid)
            axis(1, at = seq_along(levels(df$ID2)), labels = levels(df$ID2))


            enter image description here






            share|improve this answer



























              2














              You can convert the factor in a numeric variable, supress the x-axis and then add the correct labels to the plot:



              df$ID2 <- factor(letters[df$ID]) # Use letters to show that this is working

              plot(range(as.numeric(df$ID2)), range(df$score), type = "n", xaxt = "n")
              segments(as.numeric(df$ID2), df$score, as.numeric(df$ID2), mid)
              axis(1, at = seq_along(levels(df$ID2)), labels = levels(df$ID2))


              enter image description here






              share|improve this answer

























                2












                2








                2







                You can convert the factor in a numeric variable, supress the x-axis and then add the correct labels to the plot:



                df$ID2 <- factor(letters[df$ID]) # Use letters to show that this is working

                plot(range(as.numeric(df$ID2)), range(df$score), type = "n", xaxt = "n")
                segments(as.numeric(df$ID2), df$score, as.numeric(df$ID2), mid)
                axis(1, at = seq_along(levels(df$ID2)), labels = levels(df$ID2))


                enter image description here






                share|improve this answer













                You can convert the factor in a numeric variable, supress the x-axis and then add the correct labels to the plot:



                df$ID2 <- factor(letters[df$ID]) # Use letters to show that this is working

                plot(range(as.numeric(df$ID2)), range(df$score), type = "n", xaxt = "n")
                segments(as.numeric(df$ID2), df$score, as.numeric(df$ID2), mid)
                axis(1, at = seq_along(levels(df$ID2)), labels = levels(df$ID2))


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 23 at 17:30









                kathkath

                5,0231026




                5,0231026





























                    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%2f55316273%2fdeviation-chart-in-base-graphics%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

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해