Skip to content

Deal with Dates in Basic-Excel-R-toolkit, can't plot gantt chart and display dates! #212

@ArjunSharma382

Description

@ArjunSharma382

Wrote a simple function to print Data-Frame in excel, one of the column in is Date format it doesn't gets printed with date.
Tried many version. this the function (=R.data.frame(J2:J9,K2:K9,L2:L9))
image

data.frame <- function(x,y,z){
#y <- as.character(y);
y <- as.Date(y,format="%m/%d/%Y")
as.data.frame(cbind(x,y,z))
}

get following error message:
Error in as.Date.numeric(y, format = "%m/%d/%Y") :
'origin' must be supplied

If someone can help to deal with dates while taking date as an input from excel and write R functions accordingly.

facing similar issue while plotting Gantt chart:

gantt_plt <- function(Task, Start, Duration, Resource){
# link the graphics to the calling cell, so it won't get erased

when another cell draws a plot

Task <- unlist(Task[!is.na(Task)]);
Start <- (unlist(Start[!is.na(Start)]));
Duration = as.numeric(unlist(Duration[!is.na(Duration)]));
Resource <- unlist(Resource[!is.na(Resource)]);
BERT.graphics.device(cell=T);
#Start <- as.Date(Start, format = "%m/%d/%Y");
fig <- plot_ly();
for(i in 1:(length(Task) - 1)){
fig <- add_trace(fig,
x = c(Start[i], Start[i] + Duration[i]), # x0, x1
y = c(i, i), # y0, y1
mode = "lines",
#line = list(color = df$color[i], width = 20),
showlegend = F,
hoverinfo = "text",

               # Create custom hover text
               
               text = paste("Task: ", Task[i], "<br>",
                            "Duration: ", Duration[i], "days<br>",
                            "Resource: ", Resource[i]),
               
               evaluate = T  # needed to avoid lazy loading

);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions