Scatterplot: Error in FUN(X[[i]], ...) : object 'Group' not found
aesthetics
are inherited by default. The geom_path
is trying to look for the Group
variable on the path
dataset to get the color. You should use inherit.aes = FALSE
on the geom_path
:
geom_path(data = path, aes(x = x,y = y), inherit.aes = FALSE )
Error in FUN(X[[i]], ...) : object 'a' not found
In your initial ggplot()
, you specify that y = a
. This mapping is forwarded until it is overwritten. When the error occurs, you specify data that does not contain a
yet a
is still mapped onto y
. Try to set y = NULL
explicitly to overwrite the mapping.
Unable to plot a matrix using ggplotr : Error in FUN(X[[i]], ...) : object 'Var1' not found
I had found a possible solution :
m1 <-structure(list(Sensitivity = c(0, 0.701244813278008, 0.701244813278008,
0.705394190871369, 0.711297071129707, 0.711297071129707, 0.7125,
0.714876033057851), Specificity = c(0, 0.295454545454545, 0.295454545454545,
0.318181818181818, 0.347826086956522, 0.347826086956522, 0.355555555555556,
0.372093023255814), `Pos Pred Value` = c(0, 0.845, 0.845, 0.85,
0.85, 0.85, 0.855, 0.865), `Neg Pred Value` = c(0, 0.152941176470588,
0.152941176470588, 0.164705882352941, 0.188235294117647, 0.188235294117647,
0.188235294117647, 0.188235294117647), Precision = c(0, 0.845,
0.845, 0.85, 0.85, 0.85, 0.855, 0.865), Recall = c(0, 0.701244813278008,
0.701244813278008, 0.705394190871369, 0.711297071129707, 0.711297071129707,
0.7125, 0.714876033057851), F1 = c(0, 0.766439909297052, 0.766439909297052,
0.770975056689342, 0.774487471526196, 0.774487471526196, 0.777272727272727,
0.782805429864253), Prevalence = c(0, 0.845614035087719, 0.845614035087719,
0.845614035087719, 0.83859649122807, 0.83859649122807, 0.842105263157895,
0.849122807017544), `Detection Rate` = c(0, 0.592982456140351,
0.592982456140351, 0.596491228070175, 0.596491228070175, 0.596491228070175,
0.6, 0.607017543859649), `Detection Prevalence` = c(0, 0.701754385964912,
0.701754385964912, 0.701754385964912, 0.701754385964912, 0.701754385964912,
0.701754385964912, 0.701754385964912), `Balanced Accuracy ` = c(0,
0.498349679366277, 0.498349679366277, 0.511788004526594, 0.529561579043114,
0.529561579043114, 0.534027777777778, 0.543484528156833)), row.names = c("m_metric",
"X", "X.1", "X.2", "X.3", "X.4", "X.5", "X.6"), class = "data.frame")
rownames(m1)<-NULL
print(m1)
print(colnames(m1))
library(ggplot2)
library(reshape2)
print(melt(m1))
V1=nrow(melt(m1))/length(which(melt(m1)[,"variable"] == "Sensitivity"))
melted=cbind(Var1=rep(which(melt(m1)[,"variable"] == "Sensitivity"),V1),melt(m1))
ggplot(melted, aes(x=Var1, y=value, group=variable, color=variable))+geom_line()+ labs(title = "TITLE", x = "X", y = "Y", color = "COLOR")
plot(melt(m1)[1:16,2],type="s")
This gives :
Error in FUN(X[[i]], ...) : object 'X' not found
it seems that it's just a case letter problem.
In the code where you got error, you replaced x by X in your sum function.
Please try the following:
p.sh = aggregate(x = list(SACRIFICE.HIT = e.2015.1990$SH.FLAG), by = list(GAME.ID = e.2015.1990$GAME.ID, PLAYER.ID = e.2015.1990$BATTER), FUN = function(x) sum(x == "TRUE"))
p.so = aggregate(x = list(STRIKE.OUT = e.2015.1990$EVENT.TYPE), by = list(GAME.ID = e.2015.1990$GAME.ID, PLAYER.ID = e.2015.1990$RES.PITCHER), FUN = function(x) sum(x == 3))
p.ha = aggregate(x = list(HITS.ALLOWED = e.2015.1990$EVENT.TYPE), by = list(GAME.ID = e.2015.1990$GAME.ID, PLAYER.ID = e.2015.1990$RES.PITCHER), FUN = function(x) sum(x > 1))
p.hb = aggregate(x = list(HIT.BATSMAN = e.2015.1990$EVENT.TYPE), by = list(GAME.ID = e.2015.1990$GAME.ID, PLAYER.ID = e.2015.1990$RES.PITCHER), FUN = function(x) sum(x == 16))
Related Topics
Concatenate Values Across Columns in Data.Table, Row by Row
Alpha Aesthetic Shows Arrow's Skeleton Instead of Plain Shape - How to Prevent It
How to Force Seasonality from Auto.Arima
How to Simultaneously Apply Color/Shape/Size in a Scatter Plot Using Plotly
How to Change the Size of the Strip on Facets in a Ggplot
How to Hide/Toggle Legends Based on Addlayercontrol() in Leaflet for R
Knitr Inline Chunk Options (No Evaluation) or Just Render Highlighted Code
Split a File Path into Folder Names Vector
Organize Text on Geom_Point Using Geom_Text
R Looping Through in Survey Package
How to Turn the Filename into a Variable When Reading Multiple CSVS into R
As.Posixct Gives an Unexpected Timezone
Error: X Must Be Atomic for 'Sort.List'
How to Scale the Size of Line and Point Separately in Ggplot2
Count Consecutive True Values Within Each Block Separately
Finding Unique Combinations Irrespective of Position