[R] Numeric class and sasxport.get

Sebastien Bihorel Sebastien.Bihorel at cognigencorp.com
Wed Feb 4 16:05:49 CET 2009

Thanks a lot Frank,

One last question, though. I was tempted to remove all attributes of my 
variables after the sasxport.get call using
foo <- sasxport.get(...)
foo <- as.data.frame(lapply(unclass(foo),as.vector))
Since I never worked with the objects of class 'labeled', I was 
wondering what I will loose by removing this attribute.

*Sebastien Bihorel, PharmD, PhD*
PKPD Scientist
Cognigen Corp
Email: sebastien.bihorel at cognigencorp.com 
<mailto:sebastien.bihorel at cognigencorp.com>
Phone: (716) 633-3463 ext. 323

Frank E Harrell Jr wrote:
> Sebastien.Bihorel at cognigencorp.com wrote:
>> The problem is actually not related to a broken command but a attempt of
>> operational qualification of R. A few years ago, my company developed a
>> set of scripts for the 'operational qualification' of Splus. We are
>> switching to R so I am currently trying to port the scripts to R.
>> All Splus scripts imported SAS data using the importData function, 
>> which I
>> substituted by sasxport.get. One particular script returns the class of
>> each variable of the imported data frame; the output must match the
>> expected values: numeric, factor, integer, etc... The R 'translation' 
>> with
>> sasxport.get is thus problematic.
>> If there is no easy tweak of the function, we will probably have to 
>> remove
>> this script from our list of 'qualification' scripts.
>> Although it would be nice
> Then my advice is to write your own wrapper function for sasxport.get 
> that takes its output, looks for labelled variables, and adds a new 
> class of your choosing depending on properties of the variable, making 
> sure that you write methods needed for that class (if any).  Then test 
> your new function, not sasxport.get explicitly.
> Frank
>>> Sebastien Bihorel wrote:
>>>> Frank,
>>>> It is a non existing issue for me if the variables of class "labelled"
>>>> (and only "labelled") can only be numerical variables (integer or
>>>> numeric).
>>>> Sebastien
>>> 'labelled' can apply to any type of vector.  I'm not clear on the
>>> problem this causes you.  Please provide a command that is broken by
>>> this behavior.
>>> Frank
>>>> Frank E Harrell Jr wrote:
>>>>> Sebastien Bihorel wrote:
>>>>>> Dear R-users,
>>>>>> The sasxport.get function (from the Hmisc package) automatically
>>>>>> defines the class of imported variables. I have noticed that the
>>>>>> class of theoretically numeric variables is simply "labelled",
>>>>>> although character variables might end up been defined as "labelled"
>>>>>> "Date" or "labelled" "factor".
>>>>>> Is there a way to tell sasxport.get to define numeric variable as
>>>>>> "labelled" "integer" or "labelled" "numeric"?
>>>>> Sebastien,
>>>>> If that would fix a problem you're having we could look into it.
>>>>> Otherwise I'd tend to leave well enough alone.
>>>>> Frank
>>>>>> Thank you
>>>>>> Sebastien
>>>>>> ______________________________________________
>>>>>> 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.
>>> -- 
>>> Frank E Harrell Jr   Professor and Chair           School of Medicine
>>>                       Department of Biostatistics   Vanderbilt 
>>> University

More information about the R-help mailing list