r - ggplot, plot subset of data, ERROR -
i have seemingly simple question nonetheless have not been able solve. plot subset of data.frame in ggplot , keep getting error. here code works (with full data set):
ggplot(a2.25, aes(x=v1, y=v2)) + geom_point() + theme(plot.margin = unit(c(0,0,0,0), "lines"), plot.background = element_blank(), axis.title.y = element_blank(), axis.title.x = element_blank()) + ggtitle("a2_25")
but when try plot subset of data via:
ggplot(a2.25, aes(x=v1[2:24], y=v2[2:24])) + geom_point() + theme(plot.margin = unit(c(0,0,0,0), "lines"), plot.background = element_blank(), axis.title.y = element_blank(), axis.title.x = element_blank()) + ggtitle("a2_25")
i following error message: "error in data.frame(x = c(0.04, 0.08, 0.12, 0.16, 0.2, 0.24, 0.28, 0.32, : arguments imply differing number of rows: 23, 26" however, file composed of 26 obs. of 2 variables. when examine length of each column separately there 26 observations in each.
does know causing error/a simple way overcome it? doing exploratory analysis on data , have numerous files , converting , forth between full data set , subsets of it, tedious manually shorten files.
thank you!
here samples data (dput):
structure(list(v1 = c(0, 0.04, 0.08, 0.12, 0.16, 0.2, 0.24, 0.28, 0.32, 0.36, 0.4, 0.44, 0.48, 0.52, 0.56, 0.6, 0.64, 0.68, 0.72, 0.76, 0.8, 0.84, 0.88, 0.92, 0.96, 1), v2 = c(0.9999396, 1.828642e-05, 2.125182e-05, 1.369786e-05, 6.395666e-06, 7.471323e-07, 9.306843e-09, 1.025577e-11, 1.225776e-15, 2.306844e-20, 1.021365e-25, 1.41806e-31, 6.450008e-38, 7.751817e-45, 1.698149e-52, 4.40356e-61, 8.356799e-71, 6.445585e-82, 9.108883e-95, 7.374944e-110, 5.603281e-128, 1.908444e-150, 9.635286e-180, 1.938155e-221, 2.781784e-293, 0)), .names = c("v1", "v2"), class = "data.frame", row.names = c(na, -26l))
if need subset data should done data frame a2.25
not columns inside aes()
.
ggplot(a2.25[2:24,], aes(x=v1, y=v2)) + geom_point()
Comments
Post a Comment