[R] 'x' values must be positive.
(Ted Harding)
ted.harding at wlandres.net
Wed Mar 16 15:48:50 CET 2011
On 16-Mar-11 13:28:00, rens wrote:
>> b
> [1] "2" "1" "1" "1" "1" "1"
>> pie(b)
> Error in pie(b) : 'x' values must be positive.
>
> Can someone help me?
>
> And sorry i am an beginner
The problem (as indicated by the "" marks around each value)
is that the variable 'b' is a vector of *characters*, not of
numbers.
Compare the result of
x <- c(2,1,1,1,1,1)
x
# [1] 2 1 1 1 1 1
pie(x)
with the result of
b <- c("2","1","1","1","1","1")
b
# [1] "2" "1" "1" "1" "1" "1"
pie(b)
# Error in pie(b) : 'x' values must be positive.
and:
typeof(x)
# [1] "double"
typeof(b)
# [1] "character"
The underlying important question is:
How was the vector 'b' constructed?
You clearly expect 'b' to be numeric, but it is of
type character. The reason for this is what you need
to find out!
Hoping this helps,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 16-Mar-11 Time: 14:48:47
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list