[R] R-help: beginner question
Douglas Bates
bates at stat.wisc.edu
Thu Aug 28 16:21:35 CEST 2003
"Monica Palaseanu-Lovejoy" <monica.palaseanu-lovejoy at stud.man.ac.uk> writes:
> I am a beginner user of R. I have a trivial question I am almost
> ashamed I cannot figure it out does not matter how many times I
> am reading the help.
> I have a table in .txt format, tab delimited. I can read it with
> read.delim() with no problems.
> Afterwards I would like to use boxplot function to see if there
> are any outliers in the column 5 of my data called TPAH16.ppm
> In the boxplot help I saw that I have to declare my data with
> data(). I am getting errors does not matter how I am calling
> data(), only with the name of the table, with
> data(read.delim()), or in any other way. So in the end I was not
> able to use boxplot at all.
Yours is a common problem for those starting with R. The problem is
that the object that you have read, let's call it `df', is in a
tabular form (called a "data frame" in R) and you need to specify a
single column of that table as an argument to the boxplot function.
There are several ways to do this.
- Use the `with' function to indicate the data frame to use
with(df, boxplot(TPAH16.ppm))
- Use both the name of the data frame and the name of the column,
separated by $
boxplot(df$TPAH16.ppm)
- Attach the data frame before creating the boxplot
attach(df)
boxplot(TPAH16.ppm)
detach()
--
Douglas Bates bates at stat.wisc.edu
Statistics Department 608/262-2598
University of Wisconsin - Madison http://www.stat.wisc.edu/~bates/
More information about the R-help
mailing list