[R] int vector

PIKAL Petr petr.pikal at precheza.cz
Wed Sep 11 17:40:57 CEST 2013


Hi

data, data, data. Use dput(head(data,10)) if the data frame is too big.

zdrz <- structure(list(sklon = c(10, 10, 10, 10, 20, 20, 20, 20, 20, 
40, 40, 40, 40, 95, 95), ot = c(0.8, 1.5, 4, 10, 15, 1.5, 4, 
10, 15, 1.5, 4, 10, 15, 4, 15), doba = c(140, 111, 42.8, 20.3, 
15, 88, 38.25, 17.33333333, 12.5, 65.16666667, 27, 12.5, 9.166666667, 
15.75, 5.883333333)), .Names = c("sklon", "ot", "doba"), row.names = c(NA, 
15L), class = "data.frame")


> sapply(zdrz, class)
    sklon        ot      doba 
"integer" "numeric" "numeric" 
> dotchart(zdrz$sklon)
> fix(zdrz)
> sapply(zdrz, class)
    sklon        ot      doba 
"numeric" "numeric" "numeric" 
> dotchart(zdrz$sklon)

fix changes column class to numeric but dotchart looks same to me

Regards
Petr

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Giles Crane
> Sent: Wednesday, September 11, 2013 5:21 PM
> To: r-help at r-project.org
> Subject: [R] int vector
> 
> 
> class int seems to interact oddly with fix() and dotchart().
> 
> Reading a .csv file when there are no decimal points in an item,
> results in a data.frame having a column of class int.  The mode,
> however, is numeric.
> 
> fix() does not recognize int "vectors",
> and thus does not spread its sheet.
> 
> dotchart() displays a 1 above the labels on the plot.
> 
> Converting the int column to numeric using as.numeric() cures the
> problems.  However, the behavior of the int class seems inconsistent.
> 
> R Version 3.01 (2013-05-16)
> 
> Thank you for your consideration.
> 
> Cordially,
> Giles
> 
> 
> --
> Giles L Crane, MPH, ASA, NJPHA
> Statistical Consultant and R Instructor
> 621 Lake Drive
> Princeton, NJ  08540
> Phone: 609 924-0971
> Email: gilescrane at verizon.net
> 
> ______________________________________________
> 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