Skip to content

Instantly share code, notes, and snippets.

@cimentadaj
Created August 16, 2016 22:08
Show Gist options
  • Select an option

  • Save cimentadaj/ad0c8de73fa452157ae1b8fe3c4e0994 to your computer and use it in GitHub Desktop.

Select an option

Save cimentadaj/ad0c8de73fa452157ae1b8fe3c4e0994 to your computer and use it in GitHub Desktop.
# We need to use the trans_new() function which is in the scales library. Remember to load that library.
# We create a new function with the _trans suffix. Inside that function we use the trans_new
# function to define the transformation name and the actual transformation. To see why I repeated the
# the transformation check the documentation for trans_new.
mult_trans = function() trans_new("mult", function(x) 1*x, function(x) 1*x)
# If you're planning to use this code to build your own transformations remember to change
# the name of the function(something_trans), the character string inside trans_new and the actual transformation.
# Once that's done, simply call the function with the coord_trans function.
ggplot(housing, aes(x=Land.Price.Index, y=Home.Price.Index)) + geom_point() + coord_trans(x="sqrt", y="mult")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment