setwd("C:/Users/Adrián/Desktop/R")
library(haven)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(foreign)
library(car)
#> Loading required package: carData
#>
#> Attaching package: 'car'
#> The following object is masked from 'package:dplyr':
#>
#> recode
library(ggplot2)
library(MASS)
#>
#> Attaching package: 'MASS'
#> The following object is masked from 'package:dplyr':
#>
#> select
library(memisc)
#> Loading required package: lattice
#>
#> Attaching package: 'memisc'
#> The following object is masked from 'package:ggplot2':
#>
#> syms
#> The following object is masked from 'package:car':
#>
#> recode
#> The following objects are masked from 'package:dplyr':
#>
#> collect, recode, rename, syms
#> The following objects are masked from 'package:stats':
#>
#> contr.sum, contr.treatment, contrasts
#> The following object is masked from 'package:base':
#>
#> as.array
library(tidyverse)
library(ggeffects)
CIS3333 <- read.spss("C:/Users/Adrián/Desktop/R/3333.sav", to.data.frame = TRUE, use.value.labels = FALSE)
#> Warning in read.spss("C:/Users/Adrián/Desktop/R/3333.sav", to.data.frame =
#> TRUE, : C:/Users/Adrián/Desktop/R/3333.sav: Unrecognized record type 2
#> Error in read.spss("C:/Users/Adrián/Desktop/R/3333.sav", to.data.frame = TRUE, : error reading system-file header
CIS3333 <- read_sav("C:/Users/Adrián/Desktop/R/3333.sav")
CIS3333$recP2 <- CIS3333$P2
CIS3333$recP2[CIS3333$recP2 >= "8"] <- NA
#> Error in `vec_compare()`:
#> ! Can't combine `..1` <character> and `..2` <double>.
#> Backtrace:
#> ▆
#> 1. ├─base::`[<-`(`*tmp*`, CIS3333$recP2 >= "8", value = `<lgl>`)
#> 2. ├─vctrs:::`[<-.vctrs_vctr`(`*tmp*`, CIS3333$recP2 >= "8", value = `<lgl>`)
#> 3. ├─base::NextMethod()
#> 4. ├─vctrs:::`>=.vctrs_vctr`(CIS3333$recP2, "8")
#> 5. │ └─vctrs::vec_compare(e1, e2)
#> 6. │ └─vctrs:::vec_cast_common_params(!!!args, .to = .ptype)
#> 7. │ └─vctrs:::vec_cast_common_opts(...)
#> 8. │ └─vctrs (local) `<fn>`()
#> 9. │ └─haven:::vec_ptype2.haven_labelled.character(...)
#> 10. │ └─vctrs::vec_ptype2(y, x, ...)
#> 11. │ └─vctrs (local) `<fn>`()
#> 12. │ └─haven:::vec_ptype2.character.haven_labelled(...)
#> 13. │ └─vctrs::vec_ptype2(x, vec_data(y), ...)
#> 14. └─vctrs (local) `<fn>`()
#> 15. └─vctrs::vec_default_ptype2(...)
#> 16. ├─base::withRestarts(...)
#> 17. │ └─base (local) withOneRestart(expr, restarts[[1L]])
#> 18. │ └─base (local) doWithOneRestart(return(expr), restart)
#> 19. └─vctrs::stop_incompatible_type(...)
#> 20. └─vctrs:::stop_incompatible(...)
#> 21. └─vctrs:::stop_vctrs(...)
#> 22. └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)
Created on 2023-11-20 with reprex v2.0.2
Sorry, if I'm making any mistakes because I'm new to this and new to Rstudio.
Thing is when I tried to recode some values I get this message, I tried in different values and getting the same error.
Thanks for your help!
Error in vec_compare()
:
! Can't combine ..1
and ..2
.
Run rlang::last_trace()
to see where the error occurred.