hi every one,
i have a excel sheet like this
labels starts ends
1 first task 1-Jan-04 3-Mar-04
2 second task 2-Feb-04 5-May-04
3 third task 3-Mar-04 6-Jun-04
4 fourth task 4-Apr-04 8-Aug-04
5 fifth task 5-May-04 9-Sep-04
now i converted this excel sheet into csv file and i read the csv file into
R with the below code.
my.gantt.info<-read.csv("C:/Documents and
Settings/balakrishna/Desktop/one.csv").
and for create gantt chart i used below code.
gantt.chart("my.gantt.info").
if i run this above code i am getting the error like this
Error in x$starts : $ operator is invalid for atomic vectors.
can anybody help in this aspect it would be very appreciable.
Thanks in Advance.
--
View this message in context:
http://www.nabble.com/error-in-creating-gantt-chart.-tp25115102p25115102.html
Sent from the R help mailing list archive at Nabble.com.
On Aug 24, 2009, at 8:22 AM, rajclinasia wrote:> > hi every one, > i have a excel sheet like this > > labels starts ends > 1 first task 1-Jan-04 3-Mar-04 > 2 second task 2-Feb-04 5-May-04 > 3 third task 3-Mar-04 6-Jun-04 > 4 fourth task 4-Apr-04 8-Aug-04 > 5 fifth task 5-May-04 9-Sep-04 > > now i converted this excel sheet into csv file and i read the csv > file into > R with the below code. > > my.gantt.info<-read.csv("C:/Documents and > Settings/balakrishna/Desktop/one.csv").> my.gantt.info<-read.csv(textConnection(" labels starts ends + 1 first task 1-Jan-04 3-Mar-04 + 2 second task 2-Feb-04 5-May-04 + 3 third task 3-Mar-04 6-Jun-04 + 4 fourth task 4-Apr-04 8-Aug-04 + 5 fifth task 5-May-04 9-Sep-04")) > my.gantt.info labels...starts.....ends 1 1 first task 1-Jan-04 3-Mar-04 2 2 second task 2-Feb-04 5-May-04 3 3 third task 3-Mar-04 6-Jun-04 4 4 fourth task 4-Apr-04 8-Aug-04 5 5 fifth task 5-May-04 9-Sep-04 So that may look successful to you but that data.frame contains all of that data in a single (character) column. Why? Because a function was expecting commas on a file that did not have any. You will probably get further along if you use read.table with header=TRUE. Maybe you did something different or the file did have commas. With such a small file, you really should present the results of dput(my.gantt.info) That will contain all the values and attributes of the R object ... no more guessing, which is what we are doing now.> > and for create gantt chart i used below code. > > gantt.chart("my.gantt.info").That looks wrong. my.gantt.info is an R object. Is gantt.chart (from whatever unspecified package) really expecting to have its arguments quoted? I would bet against that possibility. I would also guess that, even if the data input issues are not a problem and the quotes are removed, you still have not converted those character values that you think look like dates into objects that R will interpret as dates. ?as.Date> > if i run this above code i am getting the error like this > > Error in x$starts : $ operator is invalid for atomic vectors. > > can anybody help in this aspect it would be very appreciable. > Thanks in Advance.David Winsemius, MD Heritage Laboratories West Hartford, CT
On Mon, 24 Aug 2009 05:22:17 -0700 (PDT) rajclinasia <raj at clinasia.com>
wrote:
R> my.gantt.info<-read.csv("C:/Documents and
R> Settings/balakrishna/Desktop/one.csv").
R>
R> and for create gantt chart i used below code.
R>
R> gantt.chart("my.gantt.info").
This again is why others have pointed you first to have a look at the
basics of R which can be read at:
http://cran.r-project.org/manuals.html
or more extensively in:
http://cran.r-project.org/other-docs.html
You start to program without knowing the very basics of R. Which is in
this case the data structures. my.gantt.info is a data frame. But with
the quotation marks you don't even give this as an object to
gantt.chart because with the quotation mark you have created a single
variable with a single value which is the characters between the
quotation marks that have nothing to do with the data - hence the atomic
stuff error message...
If you would have taken the real data you need the objects name which
is: gantt.chart(my.gantt.info) but this would not work either since
as I have already pointed out in an earlier mail lase week: you need a
list but not a data.frame. So please also consider the documentation
which you can do with
?gantt.chart
which directly points you towards this.
So what you need is a list. What that is you can see either in the
example of
example(gantt.chart)
what is a list? thats basics. Its an object type (there is data.frame,
matrix, list and so on)
?list
?as.list
Please learn the basics before asking such questions because you
save a lot of time for yourself and we do as well because we would not
need to answer such questions.
Stefan
rajclinasia wrote:> hi every one, > i have a excel sheet like this > > labels starts ends > 1 first task 1-Jan-04 3-Mar-04 > 2 second task 2-Feb-04 5-May-04 > 3 third task 3-Mar-04 6-Jun-04 > 4 fourth task 4-Apr-04 8-Aug-04 > 5 fifth task 5-May-04 9-Sep-04 > > now i converted this excel sheet into csv file and i read the csv file into > R with the below code. > > my.gantt.info<-read.csv("C:/Documents and > Settings/balakrishna/Desktop/one.csv"). > > and for create gantt chart i used below code. > > gantt.chart("my.gantt.info"). > > if i run this above code i am getting the error like this > > Error in x$starts : $ operator is invalid for atomic vectors. > > can anybody help in this aspect it would be very appreciable. >Hi Raj, My apologies for not testing the solution I sent. The dates in the spreadsheet were converted to character strings, then factors in the input stage. If you reconvert them as follows: my.gantt.info$starts<-as.POSIXct(strptime(my.gantt.info$starts,"%d-%b-%y")) my.gantt.info$ends<-as.POSIXct(strptime(my.gantt.info$ends,"%d-%b-%y")) things should work properly. Jim