1

I use this code to read an spss file:

dt<-read.spss("dt.sav",to.data.frame = TRUE,use.value.labels = TRUE)

But I got this error:

Warning message:

In levels<-(*tmp*, value = if (nl == nL) as.character(labels) else paste0(labels, : duplicated levels in factors are deprecated

I didn't find anything about it. Could anyone help me?

demongolem
  • 9,474
  • 36
  • 90
  • 105
RMteam
  • 113
  • 1
  • 12
  • I think you have a variable in your SPSS file were there is a duplicate value label. for example 1 = 'male' 2 = 'female' 3 = 'male'. You should check that in SPSS. – Wietze314 Jan 10 '17 at 15:11
  • @Wietze314 i cheked it and i dont have duplicate values but i have two var whit same labels... Can it be because of this? – RMteam Jan 10 '17 at 15:59
  • Strange I would not expect that. We might need the spss file to understand what is going on – Wietze314 Jan 10 '17 at 16:42
  • Take a look at this, it may be the cause of that warning. [Warning when defining factor: duplicated levels in factors are deprecated](http://stackoverflow.com/questions/38931194/warning-when-defining-factor-duplicated-levels-in-factors-are-deprecated) – Juan Bosco Jan 10 '17 at 18:14
  • @Wietze314 Hi yes i had a duplicate value label.. but i have new problem now. My spss dataset have factor (with value labels) and string variables (like cities) when i use use.value.lables=TRUE , all string variables are factor but i dont want it... i would ask what is the best way to import spss data in R – RMteam Jan 15 '17 at 01:54
  • I have issues loading SPSS data in R as well, so I have not perfected it yet. Try using the parameter `max.value.labels` option, to prevent heterogeneous string columns to be converted to factors. Otherwise choose to (1) import data without the labels and make factors yourself in R. (2) convert the unwanted factors back to strings with `as.character()` – Wietze314 Jan 16 '17 at 13:04

1 Answers1

1

According to the error message, it seems that you have duplicated factors.

You should use:

dt<-read.spss("dt.sav",to.data.frame = TRUE,use.value.labels = TRUE,duplicated.value.labels="append")
Dave
  • 359
  • 2
  • 16