I want to make a log-log plot with a regression line, but I can't figure out what I'm doing wrong. What I'm trying is: plot(mass,area, log="xy", pch=as.numeric(food)) abline(lm(mass~area)) or plot(mass,area, log="xy", pch=as.numeric(food)) islands$logmass <- log(mass) islands$logarea <- log(area) attach(islands) abline(lm(logmass~logarea)) But that does not show a line. Where am I going wrong? data: island, area,species,food,mass Ibiza , 577 , Anser n. sp., herb, 2.0 Ibiza , 577 , Haliaeetus albicilla, carn, 4.8 Mauritius , 1874 , Raphus cucullatus, herb, 19 Mauritius , 1874 , Circus alphonsi, carn, 0.63 Mallorca , 3667 , Myotragus balearicus, herb, 40 Mallorca , 3667 , Aquila chrysaetos, carn, 4.2 Kreta , 8259 , Elephas creutzburgi, herb, 3200 ....... /Par -- Par Leijonhufvud par at hunter-gatherer.org I don't believe in reincarnation. I used to, but that was in another life.
Could you provide a reproducible example even with fake data would be fine or dput() yours. On Thu, Jun 4, 2009 at 10:11 AM, Par Leijonhufvud <par at hunter-gatherer.org> wrote:> I want to make a log-log plot with a regression line, but I can't figure > out what I'm doing wrong. What I'm trying is: > > plot(mass,area, log="xy", pch=as.numeric(food)) > abline(lm(mass~area)) > > or > > plot(mass,area, log="xy", pch=as.numeric(food)) > islands$logmass <- log(mass) > islands$logarea <- log(area) > attach(islands) > abline(lm(logmass~logarea)) > > > But that does not show a line. Where am I going wrong? > > data: > island, area,species,food,mass > Ibiza , 577 , ?Anser n. sp., herb, ?2.0 > Ibiza , 577 , ? ?Haliaeetus albicilla, carn, 4.8 > Mauritius , 1874 , ?Raphus cucullatus, herb, ?19 > Mauritius , 1874 , ?Circus alphonsi, carn, 0.63 > Mallorca , 3667 , Myotragus balearicus, herb, ?40 > Mallorca , 3667 , Aquila chrysaetos, carn, 4.2 > Kreta , 8259 , Elephas creutzburgi, herb, ?3200 > ....... > > /Par > > -- > Par Leijonhufvud ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? par at hunter-gatherer.org > I don't believe in reincarnation. ?I used to, > but that was in another life. > > ______________________________________________ > 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. >-- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
Hi r-help-bounces at r-project.org napsal dne 04.06.2009 16:11:29:> I want to make a log-log plot with a regression line, but I can't figure > out what I'm doing wrong. What I'm trying is: > > plot(mass,area, log="xy", pch=as.numeric(food)) > abline(lm(mass~area))abline(lm(area~mass))> > or > > plot(mass,area, log="xy", pch=as.numeric(food)) > islands$logmass <- log(mass) > islands$logarea <- log(area) > attach(islands) > abline(lm(logmass~logarea))abline(lm(logarea~logmass))> > > But that does not show a line. Where am I going wrong?plot(x,y) but lm(y~x) Regards Petr> > data: > island, area,species,food,mass > Ibiza , 577 , Anser n. sp., herb, 2.0 > Ibiza , 577 , Haliaeetus albicilla, carn, 4.8 > Mauritius , 1874 , Raphus cucullatus, herb, 19 > Mauritius , 1874 , Circus alphonsi, carn, 0.63 > Mallorca , 3667 , Myotragus balearicus, herb, 40 > Mallorca , 3667 , Aquila chrysaetos, carn, 4.2 > Kreta , 8259 , Elephas creutzburgi, herb, 3200 > ....... > > /Par > > -- > Par Leijonhufvud par at hunter-gatherer.org > I don't believe in reincarnation. I used to, > but that was in another life. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
A mix of Petr and William's answers will sort you out. You had two problems: the base 10/e problem and the axes swapping problem. ?dput I didn't know about that one either - very useful! andydolman@gmail.com 2009/6/5 Petr PIKAL <petr.pikal@precheza.cz> Hi> > r-help-bounces@r-project.org napsal dne 04.06.2009 16:11:29: > > > I want to make a log-log plot with a regression line, but I can't figure > > out what I'm doing wrong. What I'm trying is: > > > > plot(mass,area, log="xy", pch=as.numeric(food)) > > abline(lm(mass~area)) > > > abline(lm(area~mass)) > > > > > or > > > > plot(mass,area, log="xy", pch=as.numeric(food)) > > islands$logmass <- log(mass) > > islands$logarea <- log(area) > > attach(islands) > > abline(lm(logmass~logarea)) > > abline(lm(logarea~logmass)) > > > > > > > But that does not show a line. Where am I going wrong? > > plot(x,y) > but > lm(y~x) > > Regards > Petr > > > > > data: > > island, area,species,food,mass > > Ibiza , 577 , Anser n. sp., herb, 2.0 > > Ibiza , 577 , Haliaeetus albicilla, carn, 4.8 > > Mauritius , 1874 , Raphus cucullatus, herb, 19 > > Mauritius , 1874 , Circus alphonsi, carn, 0.63 > > Mallorca , 3667 , Myotragus balearicus, herb, 40 > > Mallorca , 3667 , Aquila chrysaetos, carn, 4.2 > > Kreta , 8259 , Elephas creutzburgi, herb, 3200 > > ....... > > > > /Par > > > > -- > > Par Leijonhufvud par@hunter-gatherer.org > > I don't believe in reincarnation. I used to, > > but that was in another life. > > > > ______________________________________________ > > 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. > > ______________________________________________ > 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. >[[alternative HTML version deleted]]