Hi
In fact, I  searching for a simpler solution. I remember that I have done
this without these functions (but I forgot)
simply, is there any function that "force" R to take variable a  as table ?

Regards
Adel



> a=read.table("dureetasks.txt")
> summary(a)
       V1
 Min.   :      1
 1st Qu.:     77
 Median :   2658
 Mean   :  25802
 3rd Qu.:  42558
 Max.   :1575814
> hist(a);
Error in hist.default(a) : 'x' must be numeric



2010/8/21 Gavin Simpson <gavin.simpson@ucl.ac.uk>

> On Sat, 2010-08-21 at 11:37 +0200, Adel ESSAFI wrote:
> > Hi list
> >
> > I loaded the content  of a file dureetasks.txt to variable a. This file
> > contains an interger per line.
> > when I print a vector, it displays correctly.
> > however, when I  try to print the histogram, I get this error message
> >
> > > a=read.table("dureetasks.txt")
> > > hist(a)
> > Error in hist.default(a) : 'x' must be numeric
> >
> > Can you help please?
>
> class(a)
>
> str(a)
>
> > a <- data.frame(x = rnorm(100))
> > hist(a)
> Error in hist.default(a) : 'x' must be numeric
>
> So I suspect a is a data frame with a single column/variable. You need
> to pass hist the vector from /inside/ a that you want to plot:
>
> > with(a, hist(x))
>
> is one way to do that. Note that 'x' is used because that is the name of
> the variable (component really) in a that I want to plot:
>
> > names(a)
> [1] "x"
>
> You will need to work out what the correct name is for the component you
> want to plot. If there was no header to your text file then IIRC the
> variable will be named X1, but run names(a) and see what it returns.
>
> Because we don't have your dureetasks.txt file, there is no way for me
> to clarify that this is the problem and nothing else. If you can't send
> us data at the very least use tools like str(a) and class(a), and
> head(a) to show us what the data look like.
>
> HTH
>
> G
>
> >
> > regards
> >
> >
> >
> >
> > ______________________________________________
> > R-help@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.
>
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
>  ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
>  Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/<http://www.ucl.ac.uk/%7Eucfagls/>
>  UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>
>


-- 
PhD candidate in Computer Science
Address
3 avenue lamine, cité ezzahra, Sousse 4000
Tunisia
tel: +216 97 246 706 (+33640302046 jusqu'au 15/6)
fax: +216 71 391 166

	[[alternative HTML version deleted]]

