-1

I am quite new in using R I would like to plot specific variables which are in one main column nominated "Variable".

ID Sex Variables Value Condition ValueMin

library ("ggplot")
EF<-ggplot(antdata, aes (variable$EF1, variable$EF6.1, variables$EF6.2, EF11.1, EF 11.2, ValueMIN, fill = ConditionCode)    

Unfortunately this does not work.

Any suggestions?

Frank
  • 66,179
  • 8
  • 96
  • 180
user4842944
  • 11
  • 1
  • 2
  • What is `EF11.1, EF 11.2`? What is `ID Sex Variables Value Condition ValueMin`? – tumultous_rooster Apr 28 '15 at 16:34
  • Why is there a space here: `aes (` ? – tumultous_rooster Apr 28 '15 at 16:35
  • 2
    Can you elaborate on "*this does not work*"? – Wai Ha Lee Apr 28 '15 at 16:38
  • 1
    Welcome to StackOverflow! Please read the info about [how to ask a question](http://stackoverflow.com/help/how-to-ask) and how to produce a [minimal reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). This will make it much easier for others to help you. – Jaap Apr 28 '15 at 16:40
  • 1
    "variable" != "variables" or for that matter "Variable". "Condition" != "ConditionCode". Put more effort into checking your question for accuracy. – IRTFM Apr 28 '15 at 17:21

1 Answers1

0

I'm not 100% sure I understand the visualization you are attempting to create, but here is what I would do:

  1. Create a new data.frame that filters the variables you want to plot. I would use the filter function from the dplyr package -- i.e. filter(df,variable=="EF1") -- to do this, though there are of course many ways.

  2. You can then use ggplot to render the new data.frame you have created. Remember that you need to specify x and y values in ggplot, and anything else you want to specify needs to be done via the fill and shape specifications. So often you need to reshape your data to have it fit. The melt function from the reshape2 package is one I've found very useful when doing work with ggplot (though I think you can get by with just the filter function for your specific example provided here).

Richard Erickson
  • 2,568
  • 8
  • 26
  • 39
simitpatel
  • 641
  • 5
  • 9
  • Welcome to SO and thanks for posting an answer. As a tip, use the back quote to include code in text. – Richard Erickson Apr 28 '15 at 18:15
  • Sorry if the post was confusing. Here more details. – user4842944 Apr 29 '15 at 18:59
  • ID ConditionCode Sex Horn EF ValueEF EB ValueEB 1 1 1 2 1 EFBaseline 18.96 EBBaseline 6 2 2 1 2 2 EFBaseline 33.6 EBBaseline 8.53 – user4842944 Apr 29 '15 at 19:02
  • this is my data base a small portion called antdata. I would like to plot (bar or boxplot) ValueEf across EF taking into account ConditionCode (5 level). library(ggplot2) EF<-ggplot(antdata, aes(antdata$EF, antdata$ValueEF, fill = CnditionCode)) – user4842944 Apr 29 '15 at 19:14