[R] Discrete and Continuous variables

Patrick Burns pburns at pburns.seanet.com
Sun May 18 10:47:56 CEST 2014


Perhaps something involving:

sapply(dataFrame, function(z) length(unique(z)))

Pat

On 17/05/2014 17:31, acos at dpi.inpe.br wrote:
> Hello everybody!
>
> I have a data frame with discrete and continuous variables something
> like this:
>
> 0    1    1.46270716    5309.0171    912.5704    1000.0000
> 1    0    1.55237329    5559.0171    809.0170    1000.0000
> 0    1    1.19595444    5809.0171    750.0000    1000.0000
> 2    2    0.96467876    6059.0171    707.1068    1000.0000
> 1    0    1.46927392    3250.0000    559.0170    750.0000
> 2    0    1.65267885    3500.0000    707.1068    750.0000
>
>
> Discrete variables should be specified as factor >as.factor() and
> continuos variables as numeric >as.numeric().
> The problem is:
> The users that will enter with the variables. Is it possible identify
> which input variable are continuous or discrete?
>
> Thank guys!
>
> ______________________________________________
> 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.
>

-- 
Patrick Burns
pburns at pburns.seanet.com
twitter: @burnsstat @portfolioprobe
http://www.portfolioprobe.com/blog
http://www.burns-stat.com
(home of:
  'Impatient R'
  'The R Inferno'
  'Tao Te Programming')



More information about the R-help mailing list