R: geom_histogram (stat = "identity), missing argument" env "

I want to make a colored histogram and am facing a problem.

I am using ggplot on R 3.1.1

The initial attempt below worked just fine as long as they indicators

were numerical. When changing line indicators

to line, to make the chart easier to understand, the order in which the bars are located is scrambled.

ggplot(df_2,aes(hard_failures,fill=indicator)) + geom_histogram() 

      

The next step was to add stat="identity"

ggplot(df_2,aes(hard_failures,fill=indicator)) + geom_histogram(stat="identity")

      

Now I am getting the following error which I don't know how to fix.

Existence error (name, envir = env, mode = mode): no "env" argument, no default

Does anyone know how to fix the error message?

Alternatively, does anyone know how to change what is written next to the colors on the side, so that I can save the number indicators

and just edit the graph after that?

Sorry for the way I entered the data. I don't know how I should be putting the data.

hard_failures   indicator   
  36    2   
  3     1   
  46    2  
  36    2   
  54    2   
  3     1  
  6     1  
  47    2

hard_failures   indicator   
  36    "Time-Rule"     
  3     "Voltage-Rule"  
  46    "Time-Rule"  
  36    "Time-Rule"     
  54    "Time-Rule"     
  3     "Voltage-Rule"  
  6     Voltage-Rule  
  47    Time-Rule

      

Edit: Output signal dput(head(yourData, 10))

when data is numeric.

structure(list(hard_failures = c(36, 3, 46, 36, 54, 3, 6, 47, 
55, 2), indicator = structure(c(2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 
2L, 1L), .Label = c("1", "2"), class = "factor")), .Names =  c("hard_failures", 
"indicator"), row.names = c(NA, 10L), class = "data.frame")`

      

Output dput(head(yourData, 10))

for data that is in strings.

structure(list(hard_failures = structure(c(21L, 14L, 32L, 21L, 
41L, 14L, 43L, 33L, 42L, 8L), .Label = c("0", "1", "10", "11", 
"12", "14", "19", "2", "20", "21", "23", "28", "29", "3", "30", 
"31", "32", "33", "34", "35", "36", "37", "38", "39", "4", "40", 
"41", "42", "43", "44", "45", "46", "47", "48", "49", "5", "50", 
"51", "52", "53", "54", "55", "6", "7", "8", "9"), class = "factor"), 
 indicator = structure(c(1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 
 2L), .Label = c("Time-Rule", "Voltage-Rule"), class = "factor")), .Names >= c("hard_failures", 
"indicator"), row.names = c(NA, 10L), class = "data.frame")`

      

+3


source to share





All Articles