Hi I'm trying to use ggplot2 to chart a dataset that I've drawn in from excel. When I run the qplot command, I get the following error message:
Error: ggplot2 doesn't know how to deal with data of class character It feels like I need to coerce one of the fields in my data frame. Here's the code, which is short: #draw data in from network location setwd("S:\\790\\Actuarial\\KFC\\609 Kernel\\Sensitivity Tests\\Stressed ESG inputs") input<-read.csv("yieldcurve plus 1pct abs.csv",header=FALSE) #label columns colnames(input)<-c("scenID","yrs_ahead",0.5,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0) #create a data frame that i hope! will work with ggplot.. flat_data<-data.frame(cbind(input[1:2],stack(input[3:15]))) colnames(flat_data)<-c("scenID","yrs_ahead","yield","time") #plot library(ggplot2) qplot(time,yield,data="flat_data",facets = yrs_ahead~.) now the error. In terms of the data format, head(flat data) returns the following: > head(flat_data) scenID yrs_ahead yield time 1 1 0 0.01637218 0.5 2 1 1 0.02446376 0.5 3 1 2 0.04501267 0.5 4 1 3 0.06947724 0.5 5 1 4 0.08262982 0.5 6 1 5 0.09761927 0.5 1) Am I right that it's about coercion of variable type? 2) Any ideas how to proceed? Many thanks, Dave ______________________________________________ R-help@r-project.org mailing list 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.