[R] Novice users in need of urgent help with boxplots

David L Carlson dcarlson at tamu.edu
Tue Feb 28 21:19:07 CET 2017


As Mark and Wray have indicated, you have not told us what you have actually tried other than search the internet. If you spent 3 days learning R and don't know how to import a .csv file from Excel, you should be emailing the instructor of the course. Use Save As in Excel to save your spreadsheet file as a .csv (comma separated values) file and then start R and use read.csv() to create a data frame. 

The first two commands create a sample data frame. The third command plots the columns of the data frame as side-by-side box plots:

set.seed(42)
logs <- data.frame(matrix(rnorm(250, 20, 5), 25, 10))
boxplot(logs)

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Marc Schwartz
Sent: Tuesday, February 28, 2017 1:06 PM
To: Ashley Patton <ashley.patton at aol.co.uk>
Cc: R-help <r-help at r-project.org>
Subject: Re: [R] Novice users in need of urgent help with boxplots


> On Feb 28, 2017, at 8:11 AM, Ashley Patton via R-help <r-help at r-project.org> wrote:
> 
> 
> Hi, please forgive me but I am completely new to R and have no experience with it other than a 3 day training course but I need to use it for an urgent project and don't have time to learn a whole new language before the deadline, although I hope to get there soon.
> 
> 
> My question is this. I have a dataset in Excel containing data from 20 sites. The data comes from loggers recording every half hour for a year. So my Excel file has 20 columns each with the name of the site as the header and each column contains the data recorded throughout the year. What I want to do is show the variation in that data at each site. So I would have a boxplot showing site 1, site 2, site 3... etc across the x axis and then the variable data (which in this case in air temperature) on the y axis so I can see what range in temperatures occurred throughout the year, what where the max, min, outliers etc. I have trawled the Internet looking for a code that will allow me to do this but all I can find is plots that refer to data where you are looking at a range in data with a category (like range in mpg with cylinder size) whereas I want to so look at the data for all of my sites just on one plot. I know this is possible because I have seen it down by someone else!
  b!
> ut I don't know where to start. Does anyone have any code that would do this or at least know where I could go? Like I say, I am a complete begging so writing code is a brand new thing for me. Many, many thanks to anyone who helps me with this one.
> 
> 
> Many thanks
> 
> 
> A


Hi,

First, please post in plain text, not HTML/RTF, as the formatting of the text above is problematic for reading.

Second, posting "urgent" requests to an e-mail list with thousands of **volunteer** subscribers to meet your deadline, is an expectation that is not reasonable. You don't need to learn the entire language to complete your task, but learning pretty basic commands would be required.

I am surprised that a three day intro to R course would not have covered the basics of importing data into R from common sources, such as Excel, CSV files, etc, along with basic plot operations, which in your case, would be using the boxplot() function. From my perspective, you or your employer did not get your money's worth.

See the help page for the boxplot function for examples (accessed by typing ?boxplot in the R console), notably with a formula to specify the data to be plotted. 

The basic incantation for the boxplot for you would be something along the lines of:

  boxplot(AirTemp ~ Site, data = DataFrameContainingYourData)

where AirTemp and Site are replaced by the actual column names for the temperature data and site grouping variables, respectively. DataFrameContainingYourData is the data frame that results from importing your data into R.

Also, there is a general framework for getting help with R, that is linked from the R home page:

  https://www.r-project.org/help.html

Specifically, there is a dedicated Data Import/Export manual here:

  https://cran.r-project.org/manuals.html

along with other basic R manuals listed there (notably An Introduction to R), that you should avail yourself of, along with any materials that the course itself provided.

Regards,

Marc Schwartz

______________________________________________
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.



More information about the R-help mailing list