sorting - R plot in ascending order -
is there way sort r plot(x,y) in ascending order? sorted data frame this: sortuncharted <- uncharted[order(uncharted$v2),]
name = sortuncharted$v1
averages = sortuncharted$v2
even though table sorted,
plot(name,averages)
doesn't come sorted. table looks like:
8825 wnt10b_121975.2341 0.0000000 0 8906 grp_1.1021 0.0000000 0 1598 crebbp_147639.3240 0.1911765 0 8845 wnt3_161926.10289 0.1948718 0 3533 hoxa13_76141.2.5002 0.2253521 0 3621 hspg2_3089.11773 0.2432432 0 but plot on place
the problem name not ordered factor. when plotting, r orders data based on ordering of factor levels. need reorder leves:
sortuncharted$v1 <- reorder(sortuncharted$v1, new.order = sortuncharted$v1) another option make ordered factor ( different output regression operations , not understand output since create polynomial contrasts.):
sortuncharted$v1 <- factor(sortuncharted$v1, levels = sortuncharted$v1, ordered = true) also try provide smaller example can reproduced if doesn't help.
Comments
Post a Comment