Say I have a dataframe for plotting scatterplot. The dataframe would be
organized in the following fashion (in CSV format):
name ABC EFG1 32 452 56 67
to, say 200 000 entries
I am going to first do a scatterplot, after which I am going to subset a
portion of the dataset into A using alphahull and export them as XYZ. The
script for doing this:
#plot first plot containing all data
plot(x = X$ABC,
y = X$EFG,
pch=20,)
#subset data using ahull. choose 4 points on the plot
A <- ahull(locator(4, type="p", pch=20), alpha=10000)
#exporting subset
XYZ <- {}for (i in 1:nrow(X)) { if (inahull(A, c(X$ABC[i],X$EFG[i])))
XYZ <- rbind(X,X[i,])}
I am getting the following message if the number of data points in the
subset that I choose is too large:Error in if (p[2] > a + b * p[1]) { :
missing value where TRUE/FALSE needed
Does anyone know what might be causing the problem? Any help is much
appreciated!
[[alternative HTML version deleted]]
David Winsemius
2013-Aug-16 07:04 UTC
[R] Datamatrix in R - extracting data from scatterplot
On Aug 15, 2013, at 11:45 AM, BoonFei Tan wrote:> Say I have a dataframe for plotting scatterplot. The dataframe would be > organized in the following fashion (in CSV format): > > name ABC EFG1 32 452 56 67 > to, say 200 000 entries > > I am going to first do a scatterplot, after which I am going to subset a > portion of the dataset into A using alphahull and export them as XYZ. The > script for doing this: > > #plot first plot containing all data > plot(x = X$ABC, > y = X$EFG, > pch=20,)What's X and why do you have a comma followed by a right-paren?> #subset data using ahull. choose 4 points on the plot > A <- ahull(locator(4, type="p", pch=20), alpha=10000)It is courteous to put the library call that would load the package that has `ahull`.> #exporting subset > XYZ <- {}for (i in 1:nrow(X)) { if (inahull(A, c(X$ABC[i],X$EFG[i]))) > XYZ <- rbind(X,X[i,])}Are there some missing linefeeds here? Did you really want XYZ <- rbind(X,X[i,])} and not XYZ <- rbind(XYZ,X[i,])} ? Perhaps you should learn to post in plain text, as suggested in the Posting Guide.> > I am getting the following message if the number of data points in the > subset that I choose is too large:Error in if (p[2] > a + b * p[1]) { : > missing value where TRUE/FALSE needed > > Does anyone know what might be causing the problem? Any help is much > appreciated! >My vote would be ... missing values. -- David Winsemius Alameda, CA, USA