Hi Sarah Thank you very much for your pointers. Is there a way to specify the date string as POSIXct when reading in? I have tried the following (very inelegant way) and still have no luck. --- Begin Code --- # 1st read in the spreadsheet with stringsAsFactors set to FALSE> abc <- read.csv("gntr1.csv", header=TRUE, stringsAsFactors=FALSE) > abccode tasks.labels start end depends done 1 101 task 1 2018-04-01 2018-04-15 101 100 2 102 task2 2018-04-15 2018-05-31 101 50 3 103 task 3 2018-06-01 2018-06-30 102 0 # Next convert the date strings to POSIXct format: # The Idea here is to take each of the individual columns in the spreadsheet # and convert them to the required format and then assemble the dataframe back again:> c1d1 <- abc$tasks.labels > c1d1[1] "task 1" "task2" "task 3"> c2d1 <- as.POSIXct(abc$start) > c2d1[1] "2018-04-01 EDT" "2018-04-15 EDT" "2018-06-01 EDT"> c3d1 <- as.POSIXct(abc$end) > c3d1[1] "2018-04-15 EDT" "2018-05-31 EDT" "2018-06-30 EDT"> cdfg <- data.frame(c1d1,c2d1,c3d1) > cdfgc1d1 c2d1 c3d1 1 task 1 2018-04-01 2018-04-15 2 task2 2018-04-15 2018-05-31 3 task 3 2018-06-01 2018-06-30 # But still no luck !> gantt.chart(cdfg)Error in `$<-.data.frame`(`*tmp*`, "priorities", value = numeric(0)) : replacement has 0 rows, data has 3> str(cdfg)'data.frame': 3 obs. of 3 variables: $ c1d1: Factor w/ 3 levels "task 1","task 3",..: 1 3 2 $ c2d1: POSIXct, format: "2018-04-01" "2018-04-15" "2018-06-01" $ c3d1: POSIXct, format: "2018-04-15" "2018-05-31" "2018-06-30"> dput(cdfg)structure(list(c1d1 = structure(c(1L, 3L, 2L), .Label = c("task 1", "task 3", "task2"), class = "factor"), c2d1 = structure(c(1522555200, 1523764800, 1527825600), class = c("POSIXct", "POSIXt"), tzone = ""), c3d1 = structure(c(1523764800, 1527739200, 1530331200), class = c("POSIXct", "POSIXt"), tzone = "")), .Names = c("c1d1", "c2d1", "c3d1" ), row.names = c(NA, -3L), class = "data.frame")>----- End Code --- Thank you and Regards Indr -----Original Message----- From: Sarah Goslee <sarah.goslee at gmail.com> To: bbb_aaa <bbb_aaa at verizon.net> Cc: David Winsemius <dwinsemius at comcast.net>; r-help <r-help at r-project.org> Sent: Sun, Apr 22, 2018 6:30 pm Subject: Re: [R] Gantt Chart Using Plotrix Hi, The help file for gantt.chart states that dates must be in POSIXct format, and the example shows how to do that. There's no reason that I can see that you can't use a data frame as input to gantt.chart, but you need to be very careful that your data frame matches the correct format. I bet also that your character fields were imported as factors, because you didn't specify not to. Try running the first couple lines of the example code, then compare str(abc) with str(gantt.info) and adjust the format of your dataset as necessary. If you still can't figure it out, then use dput(abc) to provide a reproducible example, and submit that to the list. We can't tell the format of the various columns from a copy and paste. Sarah On Sun, Apr 22, 2018 at 6:10 PM, <bbb_aaa at verizon.net> wrote:> From the help file for plotrix: > " ... x - a list of task labels, start/end times and task priorities as returned by get.gantt.info ..." > > So I try to create an object that will contain this information. > > abc <- read.csv("gntr1a.csv") > > # The above csv file was generated from MS .xlsx file containing the tasks and corresponding dates > >> abc > code tasks.labels start end depends done > 1 101 task 1 2018/04/01 2018/04/15 NA 100 > 2 102 task2 2018/04/15 2018/05/31 101 50 > 3 103 task 3 2018/06/01 2018/06/30 102 0 >> gantt.chart(abc) > Error in `$<-.data.frame`(`*tmp*`, priorities, value = numeric(0)) : > replacement has 0 rows, data has 3 >> > > Manually adding the required tasks and dates (as given in the help file example) is not practical for my situation .... > > > > > > -----Original Message----- > From: David Winsemius <dwinsemius at comcast.net> > To: bbb_aaa <bbb_aaa at verizon.net> > Cc: r-help <r-help at r-project.org> > Sent: Sun, Apr 22, 2018 4:31 pm > Subject: Re: [R] Gantt Chart Using Plotrix > > >> On Apr 22, 2018, at 11:50 AM, bbb_aaa at verizon.net wrote: >> >> Hi >> >> I am trying to generate a complex Gantt chart using the gantt.chart function in the plotrix package. >> >> Ideally I would like to use a spreadsheet to populate the activities (tasks) and start and end dates that this function expects and then export the spreadsheet file as a .CSV text file so I can read in this file to generate the gantt chart. Reading through the help file I have not been able to see what exactly this spreadsheet should like. The example provided with the "gantt.chart" function seems to indicate all the information needs to be hand coded. Because of the complexity of my chart this is not only very error prone but also is impractical. >> >> Can anyone help me with this? There is also a "get.gantt.info" function for creating a gantt object but the help on this is almost next to nothing ! >> >> Any help you can provide on this would be great. >> >> There is another R package called "plan" which is very user friendly but for my purpose this doesn't have all the functionality I am looking for. > > The method to generate the most interest and attention to a question is to post a reproducible example with a clear description of the desired "functionality". > >> >> Thanks >> indr >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > David Winsemius > Alameda, CA, USA > > 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law >-- Sarah Goslee http://www.functionaldiversity.org
> On Apr 22, 2018, at 4:50 PM, bbb_aaa at verizon.net wrote: > > > Hi Sarah > > Thank you very much for your pointers. > > Is there a way to specify the date string as POSIXct when reading in?Please read the Arguments and Details sections of the help page for read.csv with particular attention to the colClasses argument options. -- David.> > I have tried the following (very inelegant way) and still have no luck. > > --- Begin Code --- > > # 1st read in the spreadsheet with stringsAsFactors set to FALSE > >> abc <- read.csv("gntr1.csv", header=TRUE, stringsAsFactors=FALSE) >> abc > code tasks.labels start end depends done > 1 101 task 1 2018-04-01 2018-04-15 101 100 > 2 102 task2 2018-04-15 2018-05-31 101 50 > 3 103 task 3 2018-06-01 2018-06-30 102 0 > > > # Next convert the date strings to POSIXct format: > # The Idea here is to take each of the individual columns in the spreadsheet > # and convert them to the required format and then assemble the dataframe back again: > > >> c1d1 <- abc$tasks.labels >> c1d1 > [1] "task 1" "task2" "task 3" >> c2d1 <- as.POSIXct(abc$start) >> c2d1 > [1] "2018-04-01 EDT" "2018-04-15 EDT" "2018-06-01 EDT" >> c3d1 <- as.POSIXct(abc$end) >> c3d1 > [1] "2018-04-15 EDT" "2018-05-31 EDT" "2018-06-30 EDT" >> cdfg <- data.frame(c1d1,c2d1,c3d1) >> cdfg > c1d1 c2d1 c3d1 > 1 task 1 2018-04-01 2018-04-15 > 2 task2 2018-04-15 2018-05-31 > 3 task 3 2018-06-01 2018-06-30 > > > # But still no luck ! > >> gantt.chart(cdfg) > Error in `$<-.data.frame`(`*tmp*`, "priorities", value = numeric(0)) : > replacement has 0 rows, data has 3 >> str(cdfg) > 'data.frame': 3 obs. of 3 variables: > $ c1d1: Factor w/ 3 levels "task 1","task 3",..: 1 3 2 > $ c2d1: POSIXct, format: "2018-04-01" "2018-04-15" "2018-06-01" > $ c3d1: POSIXct, format: "2018-04-15" "2018-05-31" "2018-06-30" >> dput(cdfg) > structure(list(c1d1 = structure(c(1L, 3L, 2L), .Label = c("task 1", > "task 3", "task2"), class = "factor"), c2d1 = structure(c(1522555200, > 1523764800, 1527825600), class = c("POSIXct", "POSIXt"), tzone = ""), > c3d1 = structure(c(1523764800, 1527739200, 1530331200), class = c("POSIXct", > "POSIXt"), tzone = "")), .Names = c("c1d1", "c2d1", "c3d1" > ), row.names = c(NA, -3L), class = "data.frame") >> > > ----- End Code --- > > > Thank you and Regards > Indr > > > > > > -----Original Message----- > From: Sarah Goslee <sarah.goslee at gmail.com> > To: bbb_aaa <bbb_aaa at verizon.net> > Cc: David Winsemius <dwinsemius at comcast.net>; r-help <r-help at r-project.org> > Sent: Sun, Apr 22, 2018 6:30 pm > Subject: Re: [R] Gantt Chart Using Plotrix > > Hi, > > The help file for gantt.chart states that dates must be in POSIXct > format, and the example shows how to do that. There's no reason that I > can see that you can't use a data frame as input to gantt.chart, but > you need to be very careful that your data frame matches the correct > format. I bet also that your character fields were imported as > factors, because you didn't specify not to. > > Try running the first couple lines of the example code, then compare > > str(abc) > > with > > str(gantt.info) > > and adjust the format of your dataset as necessary. > > If you still can't figure it out, then use dput(abc) to provide a > reproducible example, and submit that to the list. We can't tell the > format of the various columns from a copy and paste. > > Sarah > > On Sun, Apr 22, 2018 at 6:10 PM, <bbb_aaa at verizon.net> wrote: >> From the help file for plotrix: >> " ... x - a list of task labels, start/end times and task priorities as returned by get.gantt.info ..." >> >> So I try to create an object that will contain this information. >> >> abc <- read.csv("gntr1a.csv") >> >> # The above csv file was generated from MS .xlsx file containing the tasks and corresponding dates >> >>> abc >> code tasks.labels start end depends done >> 1 101 task 1 2018/04/01 2018/04/15 NA 100 >> 2 102 task2 2018/04/15 2018/05/31 101 50 >> 3 103 task 3 2018/06/01 2018/06/30 102 0 >>> gantt.chart(abc) >> Error in `$<-.data.frame`(`*tmp*`, priorities, value = numeric(0)) : >> replacement has 0 rows, data has 3 >>> >> >> Manually adding the required tasks and dates (as given in the help file example) is not practical for my situation .... >> >> >> >> >> >> -----Original Message----- >> From: David Winsemius <dwinsemius at comcast.net> >> To: bbb_aaa <bbb_aaa at verizon.net> >> Cc: r-help <r-help at r-project.org> >> Sent: Sun, Apr 22, 2018 4:31 pm >> Subject: Re: [R] Gantt Chart Using Plotrix >> >> >>> On Apr 22, 2018, at 11:50 AM, bbb_aaa at verizon.net wrote: >>> >>> Hi >>> >>> I am trying to generate a complex Gantt chart using the gantt.chart function in the plotrix package. >>> >>> Ideally I would like to use a spreadsheet to populate the activities (tasks) and start and end dates that this function expects and then export the spreadsheet file as a .CSV text file so I can read in this file to generate the gantt chart. Reading through the help file I have not been able to see what exactly this spreadsheet should like. The example provided with the "gantt.chart" function seems to indicate all the information needs to be hand coded. Because of the complexity of my chart this is not only very error prone but also is impractical. >>> >>> Can anyone help me with this? There is also a "get.gantt.info" function for creating a gantt object but the help on this is almost next to nothing ! >>> >>> Any help you can provide on this would be great. >>> >>> There is another R package called "plan" which is very user friendly but for my purpose this doesn't have all the functionality I am looking for. >> >> The method to generate the most interest and attention to a question is to post a reproducible example with a clear description of the desired "functionality". >> >>> >>> Thanks >>> indr >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >> >> David Winsemius >> Alameda, CA, USA >> >> 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law >> > > -- > Sarah Goslee > http://www.functionaldiversity.org >David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law
Hi, Your attempt didn't work because you didn't do what I suggested, which was make sure that your data frame matched the example given in the help for gantt.chart. Here's what you have:> str(cdfg)'data.frame': 3 obs. of 3 variables: $ c1d1: Factor w/ 3 levels "task 1","task 3",..: 1 3 2 $ c2d1: POSIXct, format: "2018-04-01" "2018-04-15" ... $ c3d1: POSIXct, format: "2018-04-15" "2018-05-31" ... Here's what you should have (constructed from the example in the help file):> str(gantt.info)List of 4 $ labels : chr [1:5] "First task" "Second task" "Third task" "Fourth task" ... $ starts : POSIXct[1:5], format: "2004-01-01" "2004-02-02" ... $ ends : POSIXct[1:5], format: "2004-03-03" "2004-05-05" ... $ priorities: num [1:5] 1 2 3 4 5 You got the dates into the correct format, but the names of the list elements (columns) do not match, and your data.frame() call turned the labels from character into factor while you weren't looking. gantt.chart() has no idea what you're talking about, because it is looking for particular names. If you fix those problems, it works fine. colnames(cdfg) <- c("labels", "starts", "ends") cdfg$labels <- as.character(cdfg$labels) gantt.chart(cdfg) Sarah On Sun, Apr 22, 2018 at 7:50 PM, <bbb_aaa at verizon.net> wrote:> > Hi Sarah > > Thank you very much for your pointers. > > Is there a way to specify the date string as POSIXct when reading in? > > I have tried the following (very inelegant way) and still have no luck. > > --- Begin Code --- > > # 1st read in the spreadsheet with stringsAsFactors set to FALSE > >> abc <- read.csv("gntr1.csv", header=TRUE, stringsAsFactors=FALSE) >> abc > code tasks.labels start end depends done > 1 101 task 1 2018-04-01 2018-04-15 101 100 > 2 102 task2 2018-04-15 2018-05-31 101 50 > 3 103 task 3 2018-06-01 2018-06-30 102 0 > > > # Next convert the date strings to POSIXct format: > # The Idea here is to take each of the individual columns in the spreadsheet > # and convert them to the required format and then assemble the dataframe back again: > > >> c1d1 <- abc$tasks.labels >> c1d1 > [1] "task 1" "task2" "task 3" >> c2d1 <- as.POSIXct(abc$start) >> c2d1 > [1] "2018-04-01 EDT" "2018-04-15 EDT" "2018-06-01 EDT" >> c3d1 <- as.POSIXct(abc$end) >> c3d1 > [1] "2018-04-15 EDT" "2018-05-31 EDT" "2018-06-30 EDT" >> cdfg <- data.frame(c1d1,c2d1,c3d1) >> cdfg > c1d1 c2d1 c3d1 > 1 task 1 2018-04-01 2018-04-15 > 2 task2 2018-04-15 2018-05-31 > 3 task 3 2018-06-01 2018-06-30 > > > # But still no luck ! > >> gantt.chart(cdfg) > Error in `$<-.data.frame`(`*tmp*`, "priorities", value = numeric(0)) : > replacement has 0 rows, data has 3 >> str(cdfg) > 'data.frame': 3 obs. of 3 variables: > $ c1d1: Factor w/ 3 levels "task 1","task 3",..: 1 3 2 > $ c2d1: POSIXct, format: "2018-04-01" "2018-04-15" "2018-06-01" > $ c3d1: POSIXct, format: "2018-04-15" "2018-05-31" "2018-06-30" >> dput(cdfg) > structure(list(c1d1 = structure(c(1L, 3L, 2L), .Label = c("task 1", > "task 3", "task2"), class = "factor"), c2d1 = structure(c(1522555200, > 1523764800, 1527825600), class = c("POSIXct", "POSIXt"), tzone = ""), > c3d1 = structure(c(1523764800, 1527739200, 1530331200), class = c("POSIXct", > "POSIXt"), tzone = "")), .Names = c("c1d1", "c2d1", "c3d1" > ), row.names = c(NA, -3L), class = "data.frame") >> > > ----- End Code --- > > > Thank you and Regards > Indr > > > > > > -----Original Message----- > From: Sarah Goslee <sarah.goslee at gmail.com> > To: bbb_aaa <bbb_aaa at verizon.net> > Cc: David Winsemius <dwinsemius at comcast.net>; r-help <r-help at r-project.org> > Sent: Sun, Apr 22, 2018 6:30 pm > Subject: Re: [R] Gantt Chart Using Plotrix > > Hi, > > The help file for gantt.chart states that dates must be in POSIXct > format, and the example shows how to do that. There's no reason that I > can see that you can't use a data frame as input to gantt.chart, but > you need to be very careful that your data frame matches the correct > format. I bet also that your character fields were imported as > factors, because you didn't specify not to. > > Try running the first couple lines of the example code, then compare > > str(abc) > > with > > str(gantt.info) > > and adjust the format of your dataset as necessary. > > If you still can't figure it out, then use dput(abc) to provide a > reproducible example, and submit that to the list. We can't tell the > format of the various columns from a copy and paste. > > Sarah > > On Sun, Apr 22, 2018 at 6:10 PM, <bbb_aaa at verizon.net> wrote: >> From the help file for plotrix: >> " ... x - a list of task labels, start/end times and task priorities as returned by get.gantt.info ..." >> >> So I try to create an object that will contain this information. >> >> abc <- read.csv("gntr1a.csv") >> >> # The above csv file was generated from MS .xlsx file containing the tasks and corresponding dates >> >>> abc >> code tasks.labels start end depends done >> 1 101 task 1 2018/04/01 2018/04/15 NA 100 >> 2 102 task2 2018/04/15 2018/05/31 101 50 >> 3 103 task 3 2018/06/01 2018/06/30 102 0 >>> gantt.chart(abc) >> Error in `$<-.data.frame`(`*tmp*`, priorities, value = numeric(0)) : >> replacement has 0 rows, data has 3 >>> >> >> Manually adding the required tasks and dates (as given in the help file example) is not practical for my situation .... >> >> >> >> >> >> -----Original Message----- >> From: David Winsemius <dwinsemius at comcast.net> >> To: bbb_aaa <bbb_aaa at verizon.net> >> Cc: r-help <r-help at r-project.org> >> Sent: Sun, Apr 22, 2018 4:31 pm >> Subject: Re: [R] Gantt Chart Using Plotrix >> >> >>> On Apr 22, 2018, at 11:50 AM, bbb_aaa at verizon.net wrote: >>> >>> Hi >>> >>> I am trying to generate a complex Gantt chart using the gantt.chart function in the plotrix package. >>> >>> Ideally I would like to use a spreadsheet to populate the activities (tasks) and start and end dates that this function expects and then export the spreadsheet file as a .CSV text file so I can read in this file to generate the gantt chart. Reading through the help file I have not been able to see what exactly this spreadsheet should like. The example provided with the "gantt.chart" function seems to indicate all the information needs to be hand coded. Because of the complexity of my chart this is not only very error prone but also is impractical. >>> >>> Can anyone help me with this? There is also a "get.gantt.info" function for creating a gantt object but the help on this is almost next to nothing ! >>> >>> Any help you can provide on this would be great. >>> >>> There is another R package called "plan" which is very user friendly but for my purpose this doesn't have all the functionality I am looking for. >> >> The method to generate the most interest and attention to a question is to post a reproducible example with a clear description of the desired "functionality". >> >>> >>> Thanks >>> indr >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >> >> David Winsemius >> Alameda, CA, USA >> >> 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law >> > > -- > Sarah Goslee > http://www.functionaldiversity.org >
Hi Sarah Sorry for the delay in responding. Based on your earlier message I realized that the way I was reading in the data was causing this problem. I also realized that my attempt at fixing the problem (by selecting each of the columns using the $ operator and then changing it to the appropriate format) was not helping and is very clunky. So, I did this: abc <- read.csv("gntr1a.csv", header=TRUE, stringsAsFactors=FALSE, colClasses=c("character","POSIXct","POSIXct","integer")) and this works (I think it is important to make sure the columns in the spreadsheet are named "starts", "ends" , etc. before exporting in order for this to work). So, once again thank you (and also Jim and David). Regards Indr -----Original Message----- From: Sarah Goslee <sarah.goslee at gmail.com> To: bbb_aaa <bbb_aaa at verizon.net> Cc: r-help <r-help at r-project.org> Sent: Mon, Apr 23, 2018 10:34 am Subject: Re: [R] Gantt Chart Using Plotrix Hi, Your attempt didn't work because you didn't do what I suggested, which was make sure that your data frame matched the example given in the help for gantt.chart. Here's what you have:> str(cdfg)'data.frame': 3 obs. of 3 variables: $ c1d1: Factor w/ 3 levels "task 1","task 3",..: 1 3 2 $ c2d1: POSIXct, format: "2018-04-01" "2018-04-15" ... $ c3d1: POSIXct, format: "2018-04-15" "2018-05-31" ... Here's what you should have (constructed from the example in the help file):> str(gantt.info)List of 4 $ labels : chr [1:5] "First task" "Second task" "Third task" "Fourth task" ... $ starts : POSIXct[1:5], format: "2004-01-01" "2004-02-02" ... $ ends : POSIXct[1:5], format: "2004-03-03" "2004-05-05" ... $ priorities: num [1:5] 1 2 3 4 5 You got the dates into the correct format, but the names of the list elements (columns) do not match, and your data.frame() call turned the labels from character into factor while you weren't looking. gantt.chart() has no idea what you're talking about, because it is looking for particular names. If you fix those problems, it works fine. colnames(cdfg) <- c("labels", "starts", "ends") cdfg$labels <- as.character(cdfg$labels) gantt.chart(cdfg) Sarah On Sun, Apr 22, 2018 at 7:50 PM, <bbb_aaa at verizon.net> wrote:> > Hi Sarah > > Thank you very much for your pointers. > > Is there a way to specify the date string as POSIXct when reading in? > > I have tried the following (very inelegant way) and still have no luck. > > --- Begin Code --- > > # 1st read in the spreadsheet with stringsAsFactors set to FALSE > >> abc <- read.csv("gntr1.csv", header=TRUE, stringsAsFactors=FALSE) >> abc > code tasks.labels start end depends done > 1 101 task 1 2018-04-01 2018-04-15 101 100 > 2 102 task2 2018-04-15 2018-05-31 101 50 > 3 103 task 3 2018-06-01 2018-06-30 102 0 > > > # Next convert the date strings to POSIXct format: > # The Idea here is to take each of the individual columns in the spreadsheet > # and convert them to the required format and then assemble the dataframe back again: > > >> c1d1 <- abc$tasks.labels >> c1d1 > [1] "task 1" "task2" "task 3" >> c2d1 <- as.POSIXct(abc$start) >> c2d1 > [1] "2018-04-01 EDT" "2018-04-15 EDT" "2018-06-01 EDT" >> c3d1 <- as.POSIXct(abc$end) >> c3d1 > [1] "2018-04-15 EDT" "2018-05-31 EDT" "2018-06-30 EDT" >> cdfg <- data.frame(c1d1,c2d1,c3d1) >> cdfg > c1d1 c2d1 c3d1 > 1 task 1 2018-04-01 2018-04-15 > 2 task2 2018-04-15 2018-05-31 > 3 task 3 2018-06-01 2018-06-30 > > > # But still no luck ! > >> gantt.chart(cdfg) > Error in `$<-.data.frame`(`*tmp*`, "priorities", value = numeric(0)) : > replacement has 0 rows, data has 3 >> str(cdfg) > 'data.frame': 3 obs. of 3 variables: > $ c1d1: Factor w/ 3 levels "task 1","task 3",..: 1 3 2 > $ c2d1: POSIXct, format: "2018-04-01" "2018-04-15" "2018-06-01" > $ c3d1: POSIXct, format: "2018-04-15" "2018-05-31" "2018-06-30" >> dput(cdfg) > structure(list(c1d1 = structure(c(1L, 3L, 2L), .Label = c("task 1", > "task 3", "task2"), class = "factor"), c2d1 = structure(c(1522555200, > 1523764800, 1527825600), class = c("POSIXct", "POSIXt"), tzone = ""), > c3d1 = structure(c(1523764800, 1527739200, 1530331200), class = c("POSIXct", > "POSIXt"), tzone = "")), .Names = c("c1d1", "c2d1", "c3d1" > ), row.names = c(NA, -3L), class = "data.frame") >> > > ----- End Code --- > > > Thank you and Regards > Indr > > > > > > -----Original Message----- > From: Sarah Goslee <sarah.goslee at gmail.com> > To: bbb_aaa <bbb_aaa at verizon.net> > Cc: David Winsemius <dwinsemius at comcast.net>; r-help <r-help at r-project.org> > Sent: Sun, Apr 22, 2018 6:30 pm > Subject: Re: [R] Gantt Chart Using Plotrix > > Hi, > > The help file for gantt.chart states that dates must be in POSIXct > format, and the example shows how to do that. There's no reason that I > can see that you can't use a data frame as input to gantt.chart, but > you need to be very careful that your data frame matches the correct > format. I bet also that your character fields were imported as > factors, because you didn't specify not to. > > Try running the first couple lines of the example code, then compare > > str(abc) > > with > > str(gantt.info) > > and adjust the format of your dataset as necessary. > > If you still can't figure it out, then use dput(abc) to provide a > reproducible example, and submit that to the list. We can't tell the > format of the various columns from a copy and paste. > > Sarah > > On Sun, Apr 22, 2018 at 6:10 PM, <bbb_aaa at verizon.net> wrote: >> From the help file for plotrix: >> " ... x - a list of task labels, start/end times and task priorities as returned by get.gantt.info ..." >> >> So I try to create an object that will contain this information. >> >> abc <- read.csv("gntr1a.csv") >> >> # The above csv file was generated from MS .xlsx file containing the tasks and corresponding dates >> >>> abc >> code tasks.labels start end depends done >> 1 101 task 1 2018/04/01 2018/04/15 NA 100 >> 2 102 task2 2018/04/15 2018/05/31 101 50 >> 3 103 task 3 2018/06/01 2018/06/30 102 0 >>> gantt.chart(abc) >> Error in `$<-.data.frame`(`*tmp*`, priorities, value = numeric(0)) : >> replacement has 0 rows, data has 3 >>> >> >> Manually adding the required tasks and dates (as given in the help file example) is not practical for my situation .... >> >> >> >> >> >> -----Original Message----- >> From: David Winsemius <dwinsemius at comcast.net> >> To: bbb_aaa <bbb_aaa at verizon.net> >> Cc: r-help <r-help at r-project.org> >> Sent: Sun, Apr 22, 2018 4:31 pm >> Subject: Re: [R] Gantt Chart Using Plotrix >> >> >>> On Apr 22, 2018, at 11:50 AM, bbb_aaa at verizon.net wrote: >>> >>> Hi >>> >>> I am trying to generate a complex Gantt chart using the gantt.chart function in the plotrix package. >>> >>> Ideally I would like to use a spreadsheet to populate the activities (tasks) and start and end dates that this function expects and then export the spreadsheet file as a .CSV text file so I can read in this file to generate the gantt chart. Reading through the help file I have not been able to see what exactly this spreadsheet should like. The example provided with the "gantt.chart" function seems to indicate all the information needs to be hand coded. Because of the complexity of my chart this is not only very error prone but also is impractical. >>> >>> Can anyone help me with this? There is also a "get.gantt.info" function for creating a gantt object but the help on this is almost next to nothing ! >>> >>> Any help you can provide on this would be great. >>> >>> There is another R package called "plan" which is very user friendly but for my purpose this doesn't have all the functionality I am looking for. >> >> The method to generate the most interest and attention to a question is to post a reproducible example with a clear description of the desired "functionality". >> >>> >>> Thanks >>> indr >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >> >> David Winsemius >> Alameda, CA, USA >> >> 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law >> > > -- > Sarah Goslee > http://www.functionaldiversity.org >