[R] trouble with plotting data- possible bug?

sachinthaka.abeywardana at allianz.com.au sachinthaka.abeywardana at allianz.com.au
Thu Nov 11 01:16:37 CET 2010


Hi all,

When I write out some values and then use 'plot' and 'lines' respectively I
can get R to plot me two lines. However when I get the data from a csv file
and run it I only manage to get one line running (whichever was invoked
first). The sample files are attached below and I've reproduced the code
below with the suspicious part marked as #??? (not even sure if thats
actually whats wrong).

Thanks in advance.
Sachin

A<-read.csv("small_table.csv", stringsAsFactors = FALSE);
A$period[nchar(A$period)==5]<-paste("0",A$period[nchar(A
$period)==5],sep="");
A$period<-as.Date(strptime(A$period,("%y%m%d")));

#get all unique names
name<-unique(A$LEVEL);

#create a table for each manager for discount_count_percentage
level=6;
month<-as.numeric(A$Month[A$LEVEL==name[level]]);
month3<-as.numeric(A$Month3[A$LEVEL==name[level]]);

period<-A$period[A$LEVEL==name[level]];
#???why is this part going wrong?
plot(period, month, type='l');
lines(period, month3, col=2);

p.s. sorry about corporate notice

 (See attached file: small_table.csv)(See attached file: test.R)
--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is confidential, may contain personal information and may be subject to legal professional privilege. Unauthorised use is strictly prohibited and may be unlawful. If you have received this by mistake, confidentiality and any legal privilege are not waived or lost and we ask that you contact the sender and delete and destroy this and any other copies. In relation to any legal use you may make of the contents of this email, you must ensure that you comply with the Privacy Act (Cth) 1988 and you should note that the contents may be subject to copyright and therefore may not be reproduced, communicated or adapted without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, interruption, delay, computer virus or unauthorised access or amendment to the contents of this email. If this email is a commercial electronic message and you would prefer not to receive further commercial electronic messages from Allianz, please forward a copy of this email to unsubscribe at allianz.com.au with the word unsubscribe in the subject header. 


More information about the R-help mailing list