forked from Tatvic/RGoogleAnalytics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetDataFrame.R
23 lines (19 loc) · 1.1 KB
/
SetDataFrame.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#' To prepare the dataframe by applying the column names and column datatypes
#' to the provided data frame.
#' @keywords internal
#' @param GA.list.param.columnHeaders list includes GA response data, column name, column datatype.
#' @param dataframe.param The reponse data(dimensions and metrics data rows) packed in dataframe without the column names and column types.
#' @return dataframe.param The dataframe attached with the column names and column datatype as per type the Dimensions and metrics
#'
SetDataFrame <- function(GA.list.param.columnHeaders, dataframe.param) {
column.param <- t(sapply(GA.list.param.columnHeaders,
'[',
1 : max(sapply(GA.list.param.columnHeaders,
length))))
col.name <- gsub('ga:', '', as.character(column.param[, 1]))
col.datatype <- as.character(column.param[, 3])
colnames(dataframe.param) <- col.name
dataframe.param <- as.data.frame(dataframe.param)
dataframe.param <- SetColDataType(col.datatype, col.name, dataframe.param)
return(dataframe.param)
}