Github user olarayej commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53375517
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    --- End diff --
    
    The reason I added this was because of this:
    
    > colnames(iris) <- 1
    Error in `colnames<-`(`*tmp*`, value = 1) : 
      'dimnames' applied to non-array
    
    After I ran that, I saw this:
    > showMethods("colnames<-")
    Function: colnames<- (package SparkR)
    x="ANY", value="ANY"
    x="DataFrame", value="character"
    x="DataFrame", value="numeric"
        (inherited from: x="ANY", value="ANY")
    
    So looks like R automatically adds definitions of colnames<- if value is 
other than character.
    
    This does not happen with coltypes<-, as it's not part of base package and 
doesn't have an (ANY,ANY) signature.
    
    > coltypes(irisDF) <- 1
    Error in (function (classes, fdef, mtable)  : 
      unable to find an inherited method for function ‘coltypes<-’ for 
signature ‘"DataFrame", "numeric"’


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to