r - Shiny plot in ggplot not respecting "fill" argument in plot command -


I've included a lot of sample code because I'm new to shiny (and still very early with R) So I 'm not sure where the problem is.

The first two code blocks are UI R and servers. R, with the picture of the output. The problem I am facing is that "filling" argument is not being respected in the ggplot command, and I get a mono-color output in the chart, when the histogram has two different colors on it, DF In the "id" value

The last block of code and image is essentially running the same code in R-studio, with the desired effect. You can see in the included output screenshot that there are two hybrid histogram colors with the value of the "Eyed" column

Thanks for any help!

Example Application:

Server. R

  Library (Bright) Library (ggplot2) id & lt; - Sample (0: 1, 100, replacement = T) Val & lt; - Sample (Seek (1:25), 100, Replacement = T) Val 2 and LT; - Sample (Seek (1:10), 100, Replacement = t) Data & Lt; - Define a server for shinyServer (function (input, output) - # data.frame (id, val, val2) {# We have a plot output $ feature plot & lt; -renderPlot ({# # Histogram Render # Note the readers, the result is the same, even if the command # is written or written: fill = as.factor (id) p & lt; - ggplot (data, aes_string (x = input $ feature, fill) = as Factor (data $ id))) + geom_histogram (alpha = 0.5, aes (y = .. density ..), position = 'detection', binwidth = input $ binSize); print (p)})})  

ui.R

  libraries Rei (shiny) library (ggplot2) id & lt; - Sample (0: 1, 100, Change = T); Val & Lt; - Sample (Seek (1:25), 100, Replacement = t); Val2 & lt; - Sample (seq (1:10), 100, replaced = t); Data & lt; - data.frame (id, val, val2); #Uplus UI shinyUI (fluidPage ("Why, Why not?"), Sidebar Landout (SidebarPaneel (Selection Input ("Feature", "Feature:", Option = Colnames (Data), Selected = 'Wall'), HR Slider Input ("bin size", "size box", min = 1, max = 10, value = 2)), main paneel (plot output ("featureplate")), help text ("Choose a feature to compare" ))))  

App Output : to Output App

I'm the one I want

  # ud For stealing data library (Jijiplot 2) ID & lt; - Sample (0: 1,100, replaced = T) well and lt; - Sample (SEC (1:25), 100, replacement = T) Val 2 and LT; -Sand (Seek (1:10), 100, Replace = t) DF & LT; - Data.frame (id, val, val2) ggplot (df, aes (x = val, fill = esque)) + gom_histogram (alpha = 0.7, aes (y = .. density ..), position = 'Identity', bin-wide = 1)  

You can run the code and see the desired output, but here's just a picture

This is what it should look!

You're setting your fill in a aes_string , but you're a Tring not spend, you had been trying to have a vector AES () and aes_string (). Try to isolate them

  p  

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -