updateCATickets | R Documentation |
updateCATickets(obj)
obj |
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (obj)
{
tickets <- as.character(read.csv("objTickets.csv")[[1]])
newObj <- new.env()
count <- NROW(tickets)
for (ticket in tickets) {
tryCatch({
print(ticket)
dataRange <- obj[[ticket]][!is.na(obj[[ticket]]$Ticket),
]
newObj[[ticket]]$Date <- dataRange$Date
newObj[[ticket]]$CA <- sapply(1:nrow(dataRange),
function(x) {
ve <- as.data.frame(dataRange[x:(x + 7), ])
return(summary(lm(ve$Ticket ~ index(ve$Ticket)))$coefficients[2])
})
print(count)
count <- count - 1
write.csv(newObj[[ticket]], file = paste("Analises/Tendencias/CAs/",
ticket, ".csv", sep = ""), row.names = FALSE)
}, error = function(e) {
print(paste("Error:", e))
})
}
return(newObj)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.