Github user sun-rui commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9654#discussion_r45290804
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -293,6 +294,121 @@ setMethod("names<-",
                 }
               })
     
    +#' @rdname columns
    +#' @name colnames
    +setMethod("colnames",
    +          signature(x = "DataFrame"),
    +          function(x, do.NULL = TRUE, prefix = "col") {
    +            columns(x)
    +          })
    +
    +#' @rdname columns
    +#' @name colnames<-
    +setMethod("colnames<-",
    +          signature(x = "DataFrame", value = "character"),
    +          function(x, value) {
    +            sdf <- callJMethod(x@sdf, "toDF", as.list(value))
    +            dataFrame(sdf)
    +          })
    +
    +#' coltypes
    +#'
    +#' Get column types of a DataFrame
    +#'
    +#' @name coltypes
    +#' @param x (DataFrame)
    +#' @return value (character) A character vector with the column types of 
the given DataFrame
    +#' @rdname coltypes
    +#' @family DataFrame functions
    +#' @export
    +#' @examples
    +#'\dontrun{
    +#' irisDF <- createDataFrame(sqlContext, iris)
    +#' coltypes(irisDF)
    +#'}
    +setMethod("coltypes",
    +          signature(x = "DataFrame"),
    +          function(x) {
    +            # Get the data types of the DataFrame by invoking dtypes() 
function
    +            types <- sapply(dtypes(x), function(x) {x[[2]]})
    +
    +            # Map Spark data types into R's data types using DATA_TYPES 
environment
    +            rTypes <- sapply(types, USE.NAMES=F, FUN=function(x) {
    +              # Check for primitive types
    +              type <- PRIMITIVE_TYPES[[x]]
    +
    +              if (is.null(type)) {
    +                # Check for complex types
    +                for (t in names(COMPLEX_TYPES)) {
    +                  if (substring(x, 1, nchar(t)) == t) {
    +                    type <- COMPLEX_TYPES[[t]]
    +                    break
    +                  }
    +                }
    +
    +                if (is.null(type)) {
    +                  stop(paste("Unsupported data type: ", x))
    +                }
    +              }
    +              type
    +            })
    +
    +            # Find which types don't have mapping to R
    +            naIndices <- which(is.na(rTypes))
    +
    +            # Assign the original scala data types to the unmatched ones
    +            rTypes[naIndices] <- types[naIndices]
    +
    +            rTypes
    +          })
    +
    +#' coltypes
    +#'
    +#' Set the column types of a DataFrame.
    +#'
    +#' @name coltypes<-
    --- End diff --
    
    I mean make the style consistent with others. for example,
    @param x (DataFrame)  -> @param x A DataFrame. 
    



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to