rstudio cloud integer64boolean转换为字符串

问题描述

该数据集由12列(年龄,性别,收缩压,舒张压等)中的70,000条患者数据记录组成。所有列均为数字,12个整数和1个十进制数。

我正在尝试将列“ sex”从integer64转换为字符串,以便1可以代表女性“ F”,而2可以代表男性“ M”。 但是,当我尝试执行此操作时,the outputs are long strings

这是我的codes

的照片
# Let's change "1" and "2" to represent F and M: 
cleandf_nomiss <- na.omit(cleandf_sample)             # Remove null values
cleandf_nomiss$sex < toString(cleandf_nomiss$sex)     # Convert int64 to string
head(cleandf_nomiss)                                  # Check
cleandf_nomiss <- cleandf_sample %>%                  # Replace "1"="F" "2"="M"
  mutate(sex = recode_factor(sex,`1` = "F",`2` = "M"))

最后一个替换1 = F和2 = M的代码输出是这样的:

Error: Problem with `mutate()` input `sex`.
x no applicable method for 'recode' applied to an object of class "integer64"
ℹ Input `sex` is `recode_factor(sex,`2` = "M")`.
Run `rlang::last_error()` to see where the error occurred.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)