//
archives

axis label

This tag is associated with 1 post

ggplot2 change y-axis label to non-scientific format

Below is a kmeans implementation, plotted with ggplot2. To change the y label values (because they are large, they are automatically formatted to scientific type i.e. exponential powers of n). To ‘unpower’ the values, you need to load the scales library and add the necessary in ggplot’s scale_y_continuous.

# K-Means Cluster Analysis
m <- mplayer    # matrix type
df <- player    # dataframe type
fit <- kmeans(m, 3)                          
aggregate(m,by=list(fit$cluster),FUN=mean)   # get cluster means
fit$size
fit$withinss

# Cluster graphing
df$cluster <- factor(fit$cluster)
centers <- as.data.frame(fit$centers)

library(ggplot2)
library(scales)   # needed for formatting y-axis labels to non-scientific type
ggplot(data=df, aes(x=Experience, y=Career_salary, color=cluster )) + 
  geom_point() + scale_y_continuous(labels = comma) +
  geom_point(data=centers, aes(x=Experience, y=Career_salary, color='Center')) +
  geom_point(data=centers, aes(x=Experience, y=Career_salary, color='Center'), size=52, alpha=.3, show_guide=FALSE)
Advertisements
mathbabe

Exploring and venting about quantitative issues

The Stone and the Shell

Using large digital libraries to advance literary history

Hi. I'm Hilary Mason.

Zoom out, zoom in, zoom out.

Introduction to Data Science, Columbia University

Blog to document and reflect on Columbia Data Science Class

statMethods blog

A Quick-R Companion

the Tarzan

[R] + applied economics.

4D Pie Charts

Scientific computing, data viz and general geekery, with examples in R and MATLAB.