[R] Graph is without line
PIKAL Petr
petr.pikal at precheza.cz
Wed Sep 25 09:16:50 CEST 2013
Hi
It is mostly question of personal preference. Factors have some nice features when manipulating with levels, sorting, and/or using numeric annotation. However when you want to add some new value to factor it is trickier than with plain string vectors. Maybe it is time to look into R-intro explanation of object differences.
Petr
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of mohan.radhakrishnan at polarisft.com
> Sent: Wednesday, September 25, 2013 6:13 AM
> To: Jim Lemon
> Cc: r-help at r-project.org
> Subject: Re: [R] Graph is without line
>
> Hi,
> Yes. It worked. Is 'stringAsFactors=FALSE' the switch to
> use when reading data into a frame ? All the values I use are either
> numbers or dates or strings. Sometimes while I manipulate the data by
> filtering, the values seem to become factors ?
>
> Thanks,
> Mohan
>
>
>
> From: Jim Lemon <jim at bitwrit.com.au>
> To: mohan.radhakrishnan at polarisft.com
> Cc: r-help at r-project.org
> Date: 09/25/2013 05:56 AM
> Subject: Re: [R] Graph is without line
>
>
>
> On 09/24/2013 10:46 PM, mohan.radhakrishnan at polarisft.com wrote:
> > Hi,
> > Sometimes I get a graph like the attached one. The data type
> could
> > have something to do with it. This graph does not use the color and
> > does not draw a line. Earlier I used to convert the factors in the
> > data frame to
> another
> > data type and drew the correct graphs.
> >
> > Any idea why this happens ?
> >
> > Thanks,
> > Mohan
> >
> > Var1 Freq
> > 1 10.1.17.10 205
> > 2 10.1.17.15 216
> > 3 10.1.17.17 79
> > 4 10.1.17.23 76
> > 5 10.1.17.24 209
> > 6 10.1.17.5 244
> > 7 10.1.17.6 178
> > 8 10.1.17.7 165
> > 9 10.1.17.8 146
> >
> >
> >
> > #prints factor
> > print(class(data$Var1))
> >
> >
> plot(data$Var1,data$Freq,ylim=c(0,700),col="green",type="o",ylab="",xla
> b="",las=2,lwd=2.5,xaxt="n")
> > title("Estimation of concurrent connections",cex.main=3)
> > library(plotrix)
> > staxlab(at=data$Var1,
> > labels=as.character(data$Var1),nlines=3,srt=90)
> >
> Hi Mohan,
> If you pass a factor as the "x" value to plot, it assumes that the
> values of the factor are nominal or at best ordinal and does not try to
> connect them into a metric scale. You can get a "line" with:
>
> plot(as.numeric(data$Var1),data$Freq,ylim=c(0,700),col="green",type="o"
> ,
> ylab="",xlab="",las=2,lwd=2.5,xaxt="n")
> ...
>
> but think carefully about whether this means anything sensible.
>
> Jim
>
>
>
>
> This e-Mail may contain proprietary and confidential information and is
> sent for the intended recipient(s) only. If by an addressing or
> transmission error this mail has been misdirected to you, you are
> requested to delete this mail immediately. You are also hereby notified
> that any use, any form of reproduction, dissemination, copying,
> disclosure, modification, distribution and/or publication of this e-
> mail message, contents or its attachment other than by its intended
> recipient/s is strictly prohibited.
>
> Visit us at http://www.polarisFT.com
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
More information about the R-help
mailing list