How do I get discrete factor levels to be treated as continuous?

筅森魡賤 提交于 2019-11-28 10:08:39

I think you can do this simply by transforming the variable to numeric:

mdf$variable <- as.numeric(as.character(mdf$variable))

g <- ggplot(mdf,aes(variable,value,group=variable,colour=t))
g +
    geom_point() +
    #scale_x_continuous() +
    opts()

You need to convert your factor into numeric:

mdf$numVariable <- as.numeric(as.character(mdf$variable))

g <- ggplot(mdf,aes(numVariable,value,group=variable,colour=t))
g +
    geom_point() +
    #scale_x_continuous() +
    opts()

Or just do the conversion in the call to ggplot:

g <- ggplot(mdf,aes(as.numeric(as.character(variable)),value,group=variable,colour=t))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!