Hi, 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. I will appreciate any help ?for dummies? you can give me. Also, if you know any other way to identify outliers, or to use Cook dimension to identify them, I will really appreciate. Thanks, Monica Monica Palaseanu-Lovejoy University of Manchester School of Geography Mansfield Cooper Building Oxford Road, Manchester M13 9PL, UK. email: monica.palaseanu-lovejoy at stud.man.ac.uk
"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/
"Monica Palaseanu-Lovejoy" <monica.palaseanu-lovejoy at stud.man.ac.uk> writes:> Hi, > > 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. > > I will appreciate any help ?for dummies? you can give me. Also, > if you know any other way to identify outliers, or to use Cook > dimension to identify them, I will really appreciate.You don't need data() that's just to get some standard data for the boxplot() example. What you need is mydata <- read.delim(...whatever...) attach(mydata) boxplot(V5) # or whatever col.5 is called or with(mydata, boxplot(V5)) or boxplot(mydata$V5) (Almost all the boxplot examples appear to be using the formula interface, which doesn't work without a grouping variable, and only the formula interface allows you to give a data= argument to boxplot(). At least one of those should probably be fixed.) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
If you read the data into a data frame, you should be able to simply pass the name of the data frame in a call to boxplot. my.data <- read.delim("mytext.txt") boxplot(my.data) If you only want a boxplot of column 5 boxplot(my.data[,5]) See ?boxplot for other options to make the boxplot look the way you like. HTH, Jim James W. MacDonald Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623>>> "Monica Palaseanu-Lovejoy" <monica.palaseanu-lovejoy at stud.man.ac.uk> 08/28/03 09:35AM >>>Hi, 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. I will appreciate any help "for dummies" you can give me. Also, if you know any other way to identify outliers, or to use Cook dimension to identify them, I will really appreciate. Thanks, Monica Monica Palaseanu-Lovejoy University of Manchester School of Geography Mansfield Cooper Building Oxford Road, Manchester M13 9PL, UK. email: monica.palaseanu-lovejoy at stud.man.ac.uk ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
"A Guide for the Unwilling S User" would help orient you to how R works. It is meant to do that as quickly and painlessly as possible. Patrick Burns Burns Statistics patrick at burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") Monica Palaseanu-Lovejoy wrote:>Hi, > >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. > >I will appreciate any helpfor dummies you can give me. Also,>if you know any other way to identify outliers, or to use Cook >dimension to identify them, I will really appreciate. > >Thanks, > >Monica > > >Monica Palaseanu-Lovejoy >University of Manchester >School of Geography >Mansfield Cooper Building >Oxford Road, Manchester >M13 9PL, UK. >email: monica.palaseanu-lovejoy at stud.man.ac.uk > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > > >