Hi, I am having trouble with an error I keep getting. I am just trying to create a simple pic chart from a small table. Hope someone can help. I am new to R. Table: Name Votes John 300 Sean 222 Andy 467 Sinead 740 David 124 James 641 William 380 Commands: d <- read.table("C:\\rep.csv", head=TRUE, sep=",")> pie(d$Votes,+ labels=d$Name, + main="Class Rep Results\n(Final Results)") Error: Error in pie(d$votes, labels = d$name, main = "Class Rep Results\n(Final Results)") : 'x' values must be positive. Hope to hear from someone soon.... Best Regards, John. -- View this message in context: http://www.nabble.com/Help-with-Error-tp14923519p14923519.html Sent from the R help mailing list archive at Nabble.com.
> d <- read.table("C:\\rep.csv", head=TRUE, sep=",") > > pie(d$Votes, > + labels=d$Name, > + main="Class Rep Results\n(Final Results)") > > Error: > Error in pie(d$votes, labels = d$name, main = "Class Rep Results\n(Final > Results)") : > 'x' values must be positive.The first input to the pie function represents the size of the pie slice, so it's values must be non-negative. Take a look at what you have stored in the data frame d; it is possible that the data has been read into R incorrectly. Type d and str(d) at the command line to see this. Also, you might want to use read.csv to read in your data if it is comma separated value format. Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}
Thnk you very much! It now works correctly! Much Appreciated, John. hoogeebear wrote:> > Hi, > > I am having trouble with an error I keep getting. I am just trying to > create a simple pic chart from a small table. Hope someone can help. I am > new to R. > > Table: > Name Votes > John 300 > Sean 222 > Andy 467 > Sinead 740 > David 124 > James 641 > William 380 > > Commands: > d <- read.table("C:\\rep.csv", head=TRUE, sep=",") >> pie(d$Votes, > + labels=d$Name, > + main="Class Rep Results\n(Final Results)") > > Error: > Error in pie(d$votes, labels = d$name, main = "Class Rep Results\n(Final > Results)") : > 'x' values must be positive. > > Hope to hear from someone soon.... > > Best Regards, > > John. >-- View this message in context: http://www.nabble.com/Help-with-Error-tp14923519p14925064.html Sent from the R help mailing list archive at Nabble.com.
It looks fine to me. Try str(d) and check to be sure that Votes is a numeric value or integer value. I ran this code with no problem. x <- "Name Votes John 300 Sean 222 Andy 467 Sinead 740 David 124 James 641 William 380 " d <- read.table(textConnection(x), header=TRUE, as.is=TRUE); d pie(d$Votes, labels=d$Name, main="Class Rep Results\n(Final Results)") --- hoogeebear <jack200519 at yahoo.ie> wrote:> Hi, > > I am having trouble with an error I keep getting. I > am just trying to create > a simple pic chart from a small table. Hope someone > can help. I am new to R. > > Table: > Name Votes > John 300 > Sean 222 > Andy 467 > Sinead 740 > David 124 > James 641 > William 380 > > Commands: > d <- read.table("C:\\rep.csv", head=TRUE, sep=",") > > pie(d$Votes, > + labels=d$Name, > + main="Class Rep Results\n(Final Results)") > > Error: > Error in pie(d$votes, labels = d$name, main = "Class > Rep Results\n(Final > Results)") : > 'x' values must be positive. > > Hope to hear from someone soon.... > > Best Regards, > > John. > -- > View this message in context: >http://www.nabble.com/Help-with-Error-tp14923519p14923519.html> Sent from the R help mailing list archive at > Nabble.com. > > ______________________________________________ > R-help at 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. >Instant Messaging, free SMS, sharing photos and more... Try the new Yahoo! Canada Messenger at http://ca.beta.messenger.yahoo.com/