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

Error finding "cubroot function #1

Open
emptyr1 opened this issue Feb 2, 2016 · 6 comments
Open

Error finding "cubroot function #1

emptyr1 opened this issue Feb 2, 2016 · 6 comments

Comments

@emptyr1
Copy link

emptyr1 commented Feb 2, 2016

Hi Solomon,
Might sound silly but I'm not sure what am I missing here..

On evaluating:

q = ggplot( data=diamonds, aes(carat, price, colour=color)) +
  geom_point(alpha = 0.5, size = .75, position="jitter") +
  scale_colour_brewer(type = "div",
                      guide = guide_legend(title = NULL, reverse=T,
                                           override.aes = list(alpha = 1))) +
  scale_x_continuous(trans=cubroot_trans(), limits = c(0.2,3),
                     breaks = c(0.2, 0.5, 1, 2, 3)) +
  scale_y_continuous(trans=log10_trans(), limits = c(350,15000),
                     breaks = c(350, 1000, 5000, 10000, 15000)) +
  theme_bw() + theme(legend.key = element_blank()) +
  ggtitle("Price (log10) by Cube-Root of Carat and Color")

I am getting:

Error in inherits(x, "trans") : could not find function "cubroot_trans"
@emptyr1
Copy link
Author

emptyr1 commented Feb 2, 2016

I'm sorry have you defined any - log10_trans() and trans_new() functions anywhere? Was checking out the blog

@emptyr1 emptyr1 closed this as completed Feb 2, 2016
@emptyr1 emptyr1 reopened this Feb 2, 2016
@emptyr1
Copy link
Author

emptyr1 commented Feb 15, 2016

yes?

@radlinsky
Copy link

I'm having this issue, too. Did Solomon define cubroot_trans() himself?

@radlinsky
Copy link

I found an implementation of the cuberoot_trans function here. Thanks @FrankRuns

Also, note that cubroot_trans != cuberoot_trans... there is a typo!

cuberoot_trans = function() trans_new('cuberoot', transform = function(x) x^(1/3), inverse = function(x) x^3)

@Indodayentsimbi
Copy link

library('scales') #import the library

transformfunc = function(x) {x^(1/3)} #create the transformation function
inversefunc = function(x) {x^3} #create the inverse function

#Create the transforming function that makes use of "trans_new" the above library 'scales' must be called first.
cuberoot_trans = function () {
trans_new('cuberoot',
transform = transformfunc, #this references the function created above
inverse = inversefunc) #this references the function created above
}

ggplot(data = diamonds,mapping = aes(x=carat,y=price)) +
geom_jitter() +
scale_x_continuous(trans = cuberoot_trans(),breaks = c(0.2,0.5,1,2,3)) + #use own built transformation
scale_y_log10() + #use built-in transformation
coord_cartesian(xlim = c(0.2,3),ylim = c(350,15000))

@DCiprut
Copy link

DCiprut commented May 12, 2022

Did you mean : '<-' instead of '=' in your example ?
transformfunc = function(x) {x^(1/3)} #create the transformation function
inversefunc = function(x) {x^3} #create the inverse function

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

4 participants