Search code examples
rggplot2stacked-area-chart

how to graph using geom_area?


Does anyone know why my data is not graphing?

data_frame

univ_apps
----------------------------
timeappreceived chr May_12_2002, March_4_2002
bs_ms_phd factor  1 for bs 2 for ms 3 for phd
appid  int   rn89 qw23 et43 

sample data
--------------
timeappreceived   bs_ms_phd   appid

Sept_2_1989          1          rn89
Sept_2_1989          2          dq11
Oct_1_2011           1          bg32

etc

univdata = ggplot(univ_apps, 
   aes(x= yearappreceived, y= appid, fill=as.factor(bs_ms_phd))) +      
geom_area(position="stack")

Am I missing something from the command to graph?


Solution

  • The data frame as you shown, the "timeappreceived" is chr. I guess the data type of "yearappreceived" is the same as "timeappreceived". You should convert it to numeric. Try the following code.

    univdata = ggplot(univ_apps, aes(x= as.integer(yearappreceived),
            y= appid, fill=as.factor(bs_ms_phd))) + geom_area(position="stack"); univdata
    

    By the way, if the appid is not numeric, you shoud convert them too. But the appid is integer, isn't it?