##########################################################################################################
#' data.frame veya tible formundaki tabloları haftalık veya kendi data formatında xts objesine çevirmektedir.
#'
#'
#' @export
m_dplyr2Xts <- function(data, period=NULL, ohlc=TRUE) {
library(xts)
library(dplyr)
library(PerformanceAnalytics)
data <- as.data.frame(data)
data <- na.exclude(data)
if(!is.null(period)){
if(period == "weeks"){
rown <- data[,1]
df <- xts(data[,-1], order.by = rown)
df <- to.period(df, period = "weeks", k = 1, OHLC = ohlc)
}
} else {
rown <- data[,1]
df <- xts(data[,-1], order.by = rown)
if(ncol(df)==1){
colnames(df) <- "df"
}
}
return(df)
}
##########################################################################################################
#' xts objesini data.frame veya tibble data formatına çevirmektedir.
#'
#'
#' @export
m_xts2Dplyr <- function(data, dplyr=TRUE) {
library(xts)
library(dplyr)
df <- data.frame(date=index(data), coredata(data))
if(dplyr) df <- df %>% tbl_df()
return(df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.