Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将PlayGetId中的ID输出到R中的向量_R_Indexing_Output_Interactive - Fatal编程技术网

将PlayGetId中的ID输出到R中的向量

将PlayGetId中的ID输出到R中的向量,r,indexing,output,interactive,R,Indexing,Output,Interactive,这是一组x和y对: x = c( 3, 1, 2, 10, 9, 8, 6, 7, 5, 4) y = c(15, 5, 10, 50, 45, 40, 30, 35, 25, 20) 我希望能够以交互方式识别这些数据的索引,并按照识别顺序存储已识别点的索引 尽管identify()说它将使用pos=FALSE来完成此操作,但我无法让它工作 如果可能的话,我更喜欢使用playwith——它可以很容易地放大到点密度高的区域,选择点,缩小,然后继续选择点 这是一个很好的开始,借用“c

这是一组x和y对:

x = c( 3, 1,  2, 10,  9,  8,  6,  7,  5,  4)
y = c(15, 5, 10, 50, 45, 40, 30, 35, 25, 20)
我希望能够以交互方式识别这些数据的索引,并按照识别顺序存储已识别点的索引

尽管
identify()
说它将使用
pos=FALSE
来完成此操作,但我无法让它工作

如果可能的话,我更喜欢使用playwith——它可以很容易地放大到点密度高的区域,选择点,缩小,然后继续选择点

这是一个很好的开始,借用“copeg”:

加载打印后,选择点,然后单击

 index <- playGetIDs()

index如果使用非模式窗口,playwith函数将立即返回,返回一个playState对象

ps = playwith(xyplot(y ~ x, main = "Select Points to Delete, then close"),
    width = 4, height = 3.5, show.toolbars = FALSE,
    click.mode = "Brush")
selectedIDs = playGetIDs(ps);
然后可以选择绘图中的点,完成后从playState对象获取ID

ps = playwith(xyplot(y ~ x, main = "Select Points to Delete, then close"),
    width = 4, height = 3.5, show.toolbars = FALSE,
    click.mode = "Brush")
selectedIDs = playGetIDs(ps);
或者,zoom软件包有一个zm()函数来缩放绘图,可以与Identity一起使用,尽管调用必须是独立的:

library(zoom)
plot(x,y)
zm()
#use mouse or keys to navigate and zoom, then exit
chosen = identify(x,y) 
zm()
#zoom to another location if needed
chosen = c(chosen, identify(x,y))
#etc...

请注意,我发现这个软件包的功能依赖于R版本(我有2.1、2.14和3.2,它只适用于3.2)

我对playwith软件包非常感兴趣-GUI非常友好。但是,如果我无法理解playwith out,那么您的建议是一个很好的选择——您的代码在3.1.2中几乎可以正常工作,但实际上并不是这样。我将尝试更新。请参阅编辑。如果不需要模态,可以使用非模态对话框并从playState objectNice收集绘图信息;那个特定的代码对我不起作用,但我能够用
ind-Wait填充一个向量,你的代码也对我起作用。当我将两行作为一个块运行时,它不起作用,但是如果我运行绘图,然后运行playGetId(),它就可以正常工作。仍然不确定如何解决订购问题。默认值的顺序似乎是从最小标记到最大标记。