Hello, I'm fairly new to R and I can't work out how to produce a double inequality like (LaTeX) $0 \leq x \leq 1$ in the legend of a graph. If I try> legend(50, 0.1, legend = c(expression(0 <= x <= 1), c(2 <= x <= 3)), pch = c(1,1), col = c(2, 3))then I get an error message "unexpected '<=' in ...". I've checked the help files for plotmath and expression, but could not find a solution. I would appreciate any help you can give. Thanks, Mark
On 21/01/2010 3:50 PM, Mark Seeto wrote:> Hello, > > I'm fairly new to R and I can't work out how to produce a double > inequality like (LaTeX) $0 \leq x \leq 1$ in the legend of a graph. If > I try > > > legend(50, 0.1, legend = c(expression(0 <= x <= 1), c(2 <= x <= 3)), pch = c(1,1), col = c(2, 3)) > > then I get an error message "unexpected '<=' in ...". I've checked the > help files for plotmath and expression, but could not find a solution. >That's not legal R syntax, so you have to cheat. For example, legend(50, 0.1, legend = expression(paste(0 <= x) <= 1, paste(2 <= x) <= 3), pch = c(1,1), col = c(2, 3)) Duncan Murdoch
Reasonably Related Threads
- puzzled with plotmath II
- Which package/function for solving weighted linear least squares with inequality and equality constraints?
- Using \leq for <= in Rd files
- global optimisation with inequality constraints
- least squares regression using (inequality) restrictions