Hello, I am quite new to R and have high expectations for my future with it. R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) I have stepped back to an earlier tutorial and found an odd inconsistency with one of the examples: plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main "rpois(100, lambda = 5)") I read the local documentation on the plot command and it's arguments.>From that, I learned that 'main' defines the title from a text string. Idecide to modify some values to see how the resulting behavior changes. What I didn't expect was that modifying the text string caused the chart to change greatly. plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main "rpois(100, lambda = 4)") With the previous line, the columns change values. plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main = "hello") This line even adds a 12th column. I return to plot the original and the output has changed again. Here are some screenshots http://timothylegg.com/R/lambda5_.png http://timothylegg.com/R/lambda5.png http://timothylegg.com/R/lambda4.png http://timothylegg.com/R/hello.png What am I doing wrong to get inconsistent results like this? I'm very new to R and really hoping that this is a misunderstanding on my part.
rpois(100, 5) gives a different set of random numbers each time it is called, so if you want repeatable results compute it once and use its value in the calls to plot. E.g., r <- rpois(100, 5) plot(table(r), type="h", col="red", lwd=10, main="hello") Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Nov 24, 2015 at 11:47 AM, Timothy D. Legg <r at timothylegg.com> wrote:> Hello, > > I am quite new to R and have high expectations for my future with it. > > R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" > Copyright (C) 2013 The R Foundation for Statistical Computing > Platform: x86_64-pc-linux-gnu (64-bit) > > I have stepped back to an earlier tutorial and found an odd inconsistency > with one of the examples: > > plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main > "rpois(100, lambda = 5)") > > I read the local documentation on the plot command and it's arguments. > >From that, I learned that 'main' defines the title from a text string. I > decide to modify some values to see how the resulting behavior changes. > What I didn't expect was that modifying the text string caused the chart > to change greatly. > > plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main > "rpois(100, lambda = 4)") > > With the previous line, the columns change values. > > plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main = "hello") > > This line even adds a 12th column. > > I return to plot the original and the output has changed again. Here are > some screenshots > > http://timothylegg.com/R/lambda5_.png > http://timothylegg.com/R/lambda5.png > http://timothylegg.com/R/lambda4.png > http://timothylegg.com/R/hello.png > > What am I doing wrong to get inconsistent results like this? I'm very new > to R and really hoping that this is a misunderstanding on my part. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
... or read about set.seed() and use it. B. On Nov 24, 2015, at 2:58 PM, William Dunlap <wdunlap at tibco.com> wrote:> rpois(100, 5) gives a different set of random numbers each time it is > called, so if you want repeatable results compute it once and use its > value in the calls to plot. E.g., > r <- rpois(100, 5) > plot(table(r), type="h", col="red", lwd=10, main="hello") > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > > On Tue, Nov 24, 2015 at 11:47 AM, Timothy D. Legg <r at timothylegg.com> wrote: >> Hello, >> >> I am quite new to R and have high expectations for my future with it. >> >> R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" >> Copyright (C) 2013 The R Foundation for Statistical Computing >> Platform: x86_64-pc-linux-gnu (64-bit) >> >> I have stepped back to an earlier tutorial and found an odd inconsistency >> with one of the examples: >> >> plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main >> "rpois(100, lambda = 5)") >> >> I read the local documentation on the plot command and it's arguments. >>> From that, I learned that 'main' defines the title from a text string. I >> decide to modify some values to see how the resulting behavior changes. >> What I didn't expect was that modifying the text string caused the chart >> to change greatly. >> >> plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main >> "rpois(100, lambda = 4)") >> >> With the previous line, the columns change values. >> >> plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main = "hello") >> >> This line even adds a 12th column. >> >> I return to plot the original and the output has changed again. Here are >> some screenshots >> >> http://timothylegg.com/R/lambda5_.png >> http://timothylegg.com/R/lambda5.png >> http://timothylegg.com/R/lambda4.png >> http://timothylegg.com/R/hello.png >> >> What am I doing wrong to get inconsistent results like this? I'm very new >> to R and really hoping that this is a misunderstanding on my part. >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Thank you for your suggestions. I am quite grateful to understand that plotting is reliable and consistent in R. I had believed that this was based on a built-in dataset within the R programming language, just as the New Zealand volcano is. I look forward to further participation in R as I continue to develop skills in this arena. Timothy D. Legg> Hello, > > I am quite new to R and have high expectations for my future with it. > > R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" > Copyright (C) 2013 The R Foundation for Statistical Computing > Platform: x86_64-pc-linux-gnu (64-bit) > > I have stepped back to an earlier tutorial and found an odd inconsistency > with one of the examples: > > plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main > "rpois(100, lambda = 5)") > > I read the local documentation on the plot command and it's arguments. >>From that, I learned that 'main' defines the title from a text string. I > decide to modify some values to see how the resulting behavior changes. > What I didn't expect was that modifying the text string caused the chart > to change greatly. > > plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main > "rpois(100, lambda = 4)") > > With the previous line, the columns change values. > > plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main > "hello") > > This line even adds a 12th column. > > I return to plot the original and the output has changed again. Here are > some screenshots > > http://timothylegg.com/R/lambda5_.png > http://timothylegg.com/R/lambda5.png > http://timothylegg.com/R/lambda4.png > http://timothylegg.com/R/hello.png > > What am I doing wrong to get inconsistent results like this? I'm very new > to R and really hoping that this is a misunderstanding on my part. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
But please spend some time with an R tutorial or two (An Intro to R ships with R; there are many more on the Web) before you post further here. Many such elementary confusions and time wasted -- both yours and ours -- will be avoided if you do so. Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Tue, Nov 24, 2015 at 12:43 PM, Timothy D. Legg <r at timothylegg.com> wrote:> Thank you for your suggestions. I am quite grateful to understand that > plotting is reliable and consistent in R. I had believed that this was > based on a built-in dataset within the R programming language, just as the > New Zealand volcano is. > > I look forward to further participation in R as I continue to develop > skills in this arena. > > Timothy D. Legg > >> Hello, >> >> I am quite new to R and have high expectations for my future with it. >> >> R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" >> Copyright (C) 2013 The R Foundation for Statistical Computing >> Platform: x86_64-pc-linux-gnu (64-bit) >> >> I have stepped back to an earlier tutorial and found an odd inconsistency >> with one of the examples: >> >> plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main >> "rpois(100, lambda = 5)") >> >> I read the local documentation on the plot command and it's arguments. >>>From that, I learned that 'main' defines the title from a text string. I >> decide to modify some values to see how the resulting behavior changes. >> What I didn't expect was that modifying the text string caused the chart >> to change greatly. >> >> plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main >> "rpois(100, lambda = 4)") >> >> With the previous line, the columns change values. >> >> plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10, main >> "hello") >> >> This line even adds a 12th column. >> >> I return to plot the original and the output has changed again. Here are >> some screenshots >> >> http://timothylegg.com/R/lambda5_.png >> http://timothylegg.com/R/lambda5.png >> http://timothylegg.com/R/lambda4.png >> http://timothylegg.com/R/hello.png >> >> What am I doing wrong to get inconsistent results like this? I'm very new >> to R and really hoping that this is a misunderstanding on my part. >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.