Morning everyone I am relatively new to R and although there are tons of "how to" websites, some are just way over my head. I am currently trying to figure out how to create dot plot graphs with my data, where I have categories (i.e male /female) and values for each. I would like to display this as categories on the x axis and all values for each directly above the applicable category, thus not a scatter graph but in a line above for each. I have attached a quick picture I found on the internet to demonstrate roughly what I would like. Thank you all for your time Juan Scheun Department of Zoology and Entomology University of Pretoria Lynnwood Road Hillcrest Pretoria South Africa 0002 Cell: +27 76 860 3315 Email: jscheun at zoology.up.ac.za --------------------------------------------------------------------- This message and attachments are subject to a disclaimer. Please refer to http://www.it.up.ac.za/documentation/governance/disclaimer/ for full details. / Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule onderhewig. Volledige besonderhede is by http://www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar.
Juan (and probably many others): If you are unwilling or unable to learn R by doing some minimal work on your own, then I think you ought to look for other statistical/data analysis software; or, alternatively, use R from one of several GUI interfaces that are available: R Commander, http://www.rcommander.com/ , is one that is well documented and well developed. Pestering us on this list to tell you how to do everything from the R command line is unfair to us and a foolish strategy for you. IMO only, of course. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Stoll On Mon, Nov 24, 2014 at 1:08 AM, Juan Scheun <jscheun at zoology.up.ac.za> wrote:> Morning everyone > > > I am relatively new to R and although there are tons of "how to" websites, > some are just way over my head. I am currently trying to figure out how to > create dot plot graphs with my data, where I have categories (i.e male > /female) and values for each. I would like to display this as categories > on the x axis and all values for each directly above the applicable > category, thus not a scatter graph but in a line above for each. > > I have attached a quick picture I found on the internet to demonstrate > roughly what I would like. > > Thank you all for your time > Juan Scheun > Department of Zoology and Entomology > University of Pretoria > Lynnwood Road > Hillcrest > Pretoria > South Africa > 0002 > > Cell: +27 76 860 3315 > Email: jscheun at zoology.up.ac.za > > > > > --------------------------------------------------------------------- > This message and attachments are subject to a disclaimer. Please refer to http://www.it.up.ac.za/documentation/governance/disclaimer/ for full details. / Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule onderhewig. Volledige besonderhede is by http://www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar. > > ______________________________________________ > R-help at r-project.org mailing list > 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. >
This example (five groups instead of your two) may be close to what you are looking for: plot( rep(1:5, 20), rnorm(100)) Hopefully the ?trick? is self-evident. (R-help doesn?t pass on most attachments, so I can?t look at your example) To improve the labels I would do something like this: plot( rep(1:5, 20), rnorm(100), xaxt='n') axis(1, at=1:5, labels=letters[1:5]) The help pages you will want to look at include ?plot ?par If you haven?t already, look at the Graphical Procedures section of the R-intro manual that you can download from CRAN. There is a more advanced function called ?dotchart? that creates dotplots. It is nice if you can figure out how to use it. When I tried it, it insisted on being fancier than what I assume you?re looking for. I think the above, which uses base graphics tools, is easier. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 11/24/14, 1:08 AM, "Juan Scheun" <jscheun at zoology.up.ac.za> wrote:>Morning everyone > > >I am relatively new to R and although there are tons of "how to" websites, >some are just way over my head. I am currently trying to figure out how to >create dot plot graphs with my data, where I have categories (i.e male >/female) and values for each. I would like to display this as categories >on the x axis and all values for each directly above the applicable >category, thus not a scatter graph but in a line above for each. > >I have attached a quick picture I found on the internet to demonstrate >roughly what I would like. > >Thank you all for your time >Juan Scheun >Department of Zoology and Entomology >University of Pretoria >Lynnwood Road >Hillcrest >Pretoria >South Africa >0002 > >Cell: +27 76 860 3315 >Email: jscheun at zoology.up.ac.za > > > > >--------------------------------------------------------------------- >This message and attachments are subject to a disclaimer. Please refer to >http://www.it.up.ac.za/documentation/governance/disclaimer/ for full >details. / Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule >onderhewig. Volledige besonderhede is by >http://www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar.
"Some" of the web sites are likely always going to be over your head. The correct strategy is to find some that are within reach, and work your way through them. If you cannot copy some example code into R and execute it from one of the sites that comes up when you search for "R dotplot" (e.g. [1]) then you won't have much success communicating in a mailing list. You really need to be able to give us the sequence of commands you are having trouble with to get useful assistance via email. One of the biggest stumbling blocks for new R users is understanding data, how it is imported, and how it is stored [2]. It might not seem like the most likely place to start, but the Intro to R document and the Importing Data document that come with R have a treasure trove of useful stuff. If you need more handholding than that then there are quite a few books and online courses. [1] http://www.statmethods.net/graphs/dot.html [2] R is interactive.. learn to use the str function and the help system (try typing ?str at the R prompt) to examine variables that examples are using. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On November 24, 2014 1:08:39 AM PST, Juan Scheun <jscheun at zoology.up.ac.za> wrote:>Morning everyone > > >I am relatively new to R and although there are tons of "how to" >websites, >some are just way over my head. I am currently trying to figure out how >to >create dot plot graphs with my data, where I have categories (i.e male >/female) and values for each. I would like to display this as >categories >on the x axis and all values for each directly above the applicable >category, thus not a scatter graph but in a line above for each. > >I have attached a quick picture I found on the internet to demonstrate >roughly what I would like. > >Thank you all for your time >Juan Scheun >Department of Zoology and Entomology >University of Pretoria >Lynnwood Road >Hillcrest >Pretoria >South Africa >0002 > >Cell: +27 76 860 3315 >Email: jscheun at zoology.up.ac.za > > > > >--------------------------------------------------------------------- >This message and attachments are subject to a disclaimer. Please refer >to http://www.it.up.ac.za/documentation/governance/disclaimer/ for full >details. / Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule >onderhewig. Volledige besonderhede is by >http://www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar. > > >------------------------------------------------------------------------ > >______________________________________________ >R-help at r-project.org mailing list >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.
Turns out that stripchart() is the easiest way to get what I believe the OP is looking for. Here is some example data tmp <- data.frame( g=sample(c('M','F'), 25, replace=TRUE), val = runif(25, 1, 10)) Then: stripchart(val ~ g, data=tmp, vertical=TRUE) or with some improvement to aesthetics: stripchart(val ~ g, data=tmp, vertical=TRUE, xlim=c(0.5, 2.5)) This was actually not easy to find, and I am a very experienced R user. help.search('dotplot') did not find it. require(sos) findFn('dotplot') did not find it. This is despite the fact that ?stripchart refers to itself as a function to create "dot plots". (So I do not think the OP should be chided for having difficulty) I did not find dotchart() to be useful, because it has a different concept of "dot plot", and I could not easily find a way to make it do the version I believe the OP wants. Unfortunately, that's what internet searching for "R dotplot" tends to lead to. Of course, if I misunderstand the OP request, this is so much blather! -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 11/24/14, 11:21 AM, "Jeff Newmiller" <jdnewmil at dcn.davis.ca.us> wrote:>"Some" of the web sites are likely always going to be over your head. The >correct strategy is to find some that are within reach, and work your way >through them. If you cannot copy some example code into R and execute it >from one of the sites that comes up when you search for "R dotplot" (e.g. >[1]) then you won't have much success communicating in a mailing list. >You really need to be able to give us the sequence of commands you are >having trouble with to get useful assistance via email. > >One of the biggest stumbling blocks for new R users is understanding >data, how it is imported, and how it is stored [2]. It might not seem >like the most likely place to start, but the Intro to R document and the >Importing Data document that come with R have a treasure trove of useful >stuff. If you need more handholding than that then there are quite a few >books and online courses. > >[1] http://www.statmethods.net/graphs/dot.html >[2] R is interactive.. learn to use the str function and the help system >(try typing ?str at the R prompt) to examine variables that examples are >using. >-------------------------------------------------------------------------- >- >Jeff Newmiller The ..... ..... Go >Live... >DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live >Go... > Live: OO#.. Dead: OO#.. Playing >Research Engineer (Solar/Batteries O.O#. #.O#. with >/Software/Embedded Controllers) .OO#. .OO#. >rocks...1k >-------------------------------------------------------------------------- >- >Sent from my phone. Please excuse my brevity. > >On November 24, 2014 1:08:39 AM PST, Juan Scheun ><jscheun at zoology.up.ac.za> wrote: >>Morning everyone >> >> >>I am relatively new to R and although there are tons of "how to" >>websites, >>some are just way over my head. I am currently trying to figure out how >>to >>create dot plot graphs with my data, where I have categories (i.e male >>/female) and values for each. I would like to display this as >>categories >>on the x axis and all values for each directly above the applicable >>category, thus not a scatter graph but in a line above for each. >> >>I have attached a quick picture I found on the internet to demonstrate >>roughly what I would like. >> >>Thank you all for your time >>Juan Scheun >>Department of Zoology and Entomology >>University of Pretoria >>Lynnwood Road >>Hillcrest >>Pretoria >>South Africa >>0002 >> >>Cell: +27 76 860 3315 >>Email: jscheun at zoology.up.ac.za >> >> >> >> >>--------------------------------------------------------------------- >>This message and attachments are subject to a disclaimer. Please refer >>to http://www.it.up.ac.za/documentation/governance/disclaimer/ for full >>details. / Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule >>onderhewig. Volledige besonderhede is by >>http://www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar. >> >> >>------------------------------------------------------------------------ >> >>______________________________________________ >>R-help at r-project.org mailing list >>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 >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.
No sign of the attached plot. The R-help list is very picky about what files it will accept. IIRC, you usually are able to attach ASCII files with a txt suffix and to attach pdf files so probably you tried to send something like a png or jpeg and the R-help server stripped it away as a possible source of malware. When asking a question on the list it is usually very helpful to send sample data and any (minimal) code that is applicable to the problem. The easiest way to supply data is to use the dput() function. Example with your file named"testfile": dput(testfile) Then copy the output and paste into your email. For large data sets, you can just supply a representative sample. Usually, dput(head(testfile, 100)) will be sufficient. This is particularly important as R has many types of data formats, some of which look the same when printed on the screen, (see example, below) and by supplying the data in dput() format you ensure that R-help readers can load 'exactly' the same data as you are working with. #====================copy and run in R=================# dat1 <- data.frame(aa = as.factor(1:5), bb = 1:5) dat1 # data looks identical on the screen 5*dat1[,"aa"] # oops 5*dat1[, "bb"] # okay str(dat1) #===================================================# Have a look at https://github.com/hadley/devtools/wiki/Reproducibility and http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for some good suggestions on how to frame questions to the list. BTW, did Don McQueen's response help? Welcome to R . John Kane Kingston ON Canada> -----Original Message----- > From: jscheun at zoology.up.ac.za > Sent: Mon, 24 Nov 2014 11:08:39 +0200 > To: r-help at r-project.org > Subject: [R] DOT PLOT help!! > > Morning everyone > > > I am relatively new to R and although there are tons of "how to" > websites, > some are just way over my head. I am currently trying to figure out how > to > create dot plot graphs with my data, where I have categories (i.e male > /female) and values for each. I would like to display this as categories > on the x axis and all values for each directly above the applicable > category, thus not a scatter graph but in a line above for each. > > I have attached a quick picture I found on the internet to demonstrate > roughly what I would like. > > Thank you all for your time > Juan Scheun > Department of Zoology and Entomology > University of Pretoria > Lynnwood Road > Hillcrest > Pretoria > South Africa > 0002 > > Cell: +27 76 860 3315 > Email: jscheun at zoology.up.ac.za > > > > > --------------------------------------------------------------------- > This message and attachments are subject to a disclaimer. Please refer to > http://www.it.up.ac.za/documentation/governance/disclaimer/ for full > details. / Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule > onderhewig. Volledige besonderhede is by > http://www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar. > ______________________________________________ > R-help at r-project.org mailing list > 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.____________________________________________________________ FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!