Recent changes to read.spss() in the foreign package return a dataframe
containing additional attributes.  For example,

 

>TEMP<-read.spss(choose.files(), to.data.frame=T,use.value.labels=F)

 

> str(TEMP)

`data.frame':   780 obs. of  8 variables:

 $ EXPOS01: atomic  1 1 2 1 2 3 2 4 2 1 ...

  ..- attr(*, "value.labels")= Named num  5 4 3 2 1

  .. ..- attr(*, "names")= chr  "Yes, experienced it with Extreme
Impact" "Yes, experienced it with Moderate Impact" "Yes, experienced it
with A Little Impact" "Yes, experienced it with No Impact" ...

 $ EXPOS02: atomic  1 1 1 1 1 1 1 1 1 1 ...

  ..- attr(*, "value.labels")= Named num  5 4 3 2 1

  .. ..- attr(*, "names")= chr  "Yes, experienced it with Extreme
Impact" "Yes, experienced it with Moderate Impact" "Yes, experienced it
with A Little Impact" "Yes, experienced it with No Impact" ...

 

 

Unfortunately, these changes may be ahead of their time (certainly ahead
of several functions).  For instance edit balks at the changes:

 

> edit(TEMP)

Error in edit.data.frame(TEMP) : can only handle vector and factor
elements

 

It used to be that the command "as.data.frame" or "data.frame" would
return a fairly basic data.frame and "fix" the problem.  However, this
does not work (obviously because TEMP is already a data.frame).  For
example,

 

> TEMP<-as.data.frame(TEMP)

> edit(TEMP)

Error in edit.data.frame(TEMP) : can only handle vector and factor
elements

 

It is possible to use "as.matrix", and then "data.frame" the result of
"as.matrix", but this gets a bit cumbersome.

 

The question is:  Is there a simple command to strip additional
attribute characteristics from a data.frame and get a simple, easy to
use, uncomplicated data.frame?

 

On a related note, do other users routinely use read.spss with the
defaults of  "to.data.frame=F" or "use.value.labels=T"?  My experience
is that I am always using the non-default values in which case it would
be helpful to change the defaults to "to.data.frame=T" and
"use.value.labels=F".  It would also probably make sense to change the
default for "trim.factor.names=T".  Interested in others' perspective.

 

Appreciate all the great work Saikat DebRoy has done...just trying to
improve an already useful function.

 

Paul

 

 

 


	[[alternative HTML version deleted]]


