-
Notifications
You must be signed in to change notification settings - Fork 20
Description
There may already be a nice way to do this, but I didn't see any examples actually using the formula method for rect and segments.
Using the example from type_segments:
df <- data.frame(x0 = c(0, .1), y0 = c(.2,1), x1 = c(1, .9
), y1 = c(.75, 0))I would expect, I can do something like:
tinyplot(xmin=x0, ymin=y0, xmax=x1, ymax
=y1, data = df, type = "segments")This fails with x0 not found because, of course, I need xthe first argument to be a formula to get into the tinyplot.formula method.
Putting a placeholder formula does work:
tinyplot(y1~x1, xmin=x0, ymin=y0, xmax=x1, ymax=y1, data =
df, type = "segments")But this y1~x1 looks meaningful even though it isn't and therefore may confuse future readers of the code.
Here are some ideas that would make it more clear that the formula is a placeholder:
tinyplot(as.formula(NULL), xmin=x0, ymin=y0, xmax=x1, ymax
=y1, data = df, type = "segments")tinyplot:::tinyplot.formula(xmin=x0, ymin=y0, xmax=x1, ymax =y1, data = df, type = "segments")tinyplot( ~1, xmin=x0, ymin=y0, xmax=x1, ymax=y1, data = df, type = "segments")All three of these currently error out. Maybe there is some other clear formula placeholder already in the package that I haven't thought of, if so, it would be nice to document it more clearly and add it in an example to rect and segments help pages.