Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to st numerical values to factors #7

Open
yoditkebede opened this issue Jan 30, 2017 · 1 comment
Open

How to st numerical values to factors #7

yoditkebede opened this issue Jan 30, 2017 · 1 comment

Comments

@yoditkebede
Copy link

Hi all,

Please refer to the attached document for figures.

Figure 1 :
image

I have been trying to make a boxplot using ggplot a graph representing the edge density in (y axis) per land cover type (x axis) for 3 different moments in time (fill=Year). After adding the data in r, I saw that year was appearing as a numerical variable, therefore I renamed it precising that it is a factor. But when plotting the graph this information is not taken into account, I should have something like Figure 2.

Figure 2:
image

Figure 3:
image
Numerical variable to factor in ggplot_issues.docx

I tried the same kind of graph but per District (so character variable) identified directly as a factor when reading the data, then it works. So what should I do to set the year variable as a factor more than I already did: renaming it by setting it as a factor.

An other thing, as you can see in the attached document figure 3: I get rid of the outliers of the boxplot by plotting them in white...which made them invisible on the white background but how can I do do that more properly...??

@thijsfijen
Copy link

thijsfijen commented Jan 31, 2017

The factor per year should be inserted in the geom_boxplot(aes(colour = Year)) and not as fill in ggplot().
For omitting outliers on plots, use outlier.size = NA in geom_boxplot()
EDIT: additionally you can add geom_boxplot(aes(colour = Year, fill = Year)) to fill the boxes with a colour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants