Error in x - from[1] : non-numeric argument to binary operator

243 views
Skip to first unread message

Vivek

unread,
Feb 11, 2009, 12:09:51 AM2/11/09
to ggplot2
Hi,

I have a simple X-Y plot. I keep getting the following error. Data
is below. Any help is appreciated. It works fine with Lattice.

Vivek



> qplot(col1, col2, data = ofa1)
Error in x - from[1] : non-numeric argument to binary operator


> ofa1
col1 col2
1 A 1864.9
2 A 1298.1
3 A 3401.5
4 A 2762.4
5 A 1654.3
6 A 1547.6
7 A 1655.3
8 A 1684.3
9 A 1682.2
10 A 872.8
11 A 1851.6
12 A 2500.9
13 A 2054.8
14 A 391.1
15 B 1831.5
16 B 3232.3
17 B 2652.6
18 B 1407.7
19 B 426.4
20 B 1617.8
21 B 2071.0
22 B 2750.2
23 B 2681.7
24 B 3411.6
25 B 4247.7
26 B 2448.6
27 B 2335.0
28 B 1720.5

Dan Gunter

unread,
Feb 11, 2009, 12:32:27 PM2/11/09
to Vivek, ggplot2
Hi Vivek,

I can't reproduce this [R version 2.8.1 (2008-12-22) ; ggplot2 version
0.8.1]. But one thing you could try to narrow such problems down, in
general, is to enter 'debug qplot' before the qplot command. Then you
can step through and see which line causes the error.

Another tip to help get a better answer is to provide the exact
version of R/ggplot2 you're using, as I did above (?qplot will show
the version at the bottom; printing R.version will show your version
of R).

-Dan

p.s. the following approximation of your data works for me:
> data <- data.frame(col1=rep(c("A","B"),each=14),
col2=runif(28,0,2000))
> qplot(col1, col2, data=data)
> data
col1 col2
1 A 67.46417
2 A 1605.44209
3 A 132.06546
4 A 1696.63465
5 A 211.12864
6 A 370.71728
7 A 831.33455
8 A 1475.61061
9 A 609.25893
10 A 296.38245
11 A 1307.06623
12 A 1585.12141
13 A 1783.51058
14 A 709.02952
15 B 1563.12863
16 B 275.72321
17 B 1335.47414
18 B 977.30843
19 B 1380.40053
20 B 272.61117
21 B 1109.50546
22 B 404.20452
23 B 1970.26309
24 B 1761.53914
25 B 383.17820
26 B 870.65384
27 B 777.08975
28 B 351.26829

Vivek

unread,
Feb 11, 2009, 2:57:11 PM2/11/09
to ggplot2
Thanks for the suggestions.

I did have the latest version of ggplot2 and R. Running on a MAC
OSX10.5

The sample code from Dan and Rob gave me the same error.

So I un-installed and re-installed R and that fixed the problem.

Cheers,
Vivek
Reply all
Reply to author
Forward
0 new messages