Skip to content

Conversation

@mkcor
Copy link
Contributor

@mkcor mkcor commented Jan 22, 2015

Sorry, the branch name has become unrelated to the PR.

inherits() checks the class. It's pretty frustrating that I cannot just do

is.null(class(myObject))

!! Class is returned as a string, so it's "NULL", not NULL. Line 52, I'm basically checking for the existence of dimension x.name or y.name. (Don't be confused, the period does not mean anything here!)

The whitespaces are just for styling.

Thanks! @theengineear

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two if statements without an else. is something bad going to happen if data.vec isn't set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, well, if data.vec is not set, it's NULL and it's still okay because I try() in subsequent operations (https://github.com/ropensci/plotly/blob/master/R/trace_generation.R#L56, etc.). So the exceptions are handled.

My initial intention was to leave line 50

data.vec <- l$data[[col.name]]

and follow with

if (is.null(data.vec)) {
  if (!inherits(g$data[[paste0(a, ".name")]], "NULL") && (class(g$data[[a]]) != class(g$data[[paste0(a, ".name")]]))) {
    g$data[[a]] <- g$data[[paste0(a, ".name")]]
    data.vec <- g$data[[a]]
  }
}

The else being, well, leave it alone (it will remain NULL). Do you think this would convey more meaning?

The two ifs really mean one condition (i.e., the two columns are of different non-null classes) but I split them for readability, also to save one check if the first condition is not even met.

@theengineear
Copy link

@mkcor , if the logic is ok with it being left undefined, its seems good : D

🎉

mkcor added a commit that referenced this pull request Jan 23, 2015
Support as.Date() conversion within ggplot code
@mkcor mkcor merged commit 3abd3f6 into master Jan 23, 2015
@mkcor mkcor deleted the marianne-improve-group2NA branch January 23, 2015 05:57
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

Successfully merging this pull request may close these issues.

3 participants