如何在数据框列中存储“仪表上标减 3”

问题描述

更新:底部的会话信息

我想在数据框中 mutate 包含“m-³”的列。减号和 3 都应该是上标:

数据框:

df <- tribble(
  ~x,"m³","m³"
)
  1. 我可以通过键盘得到 m³ -> 列 x
  2. 我可以通过 unicode "\U006D\U00B3"

但减号 (unicode = "\U207B") 是不可能的。

到目前为止我已经尝试过:

df %>% 
  mutate(x1 = "\U006D\U00B3") %>%  #      unicode 
  mutate(x2 = "\U006D\U207B\U00B3") 

# Output:
  x     x1    x2   
  <chr> <chr> <chr>
1 m³    m³    m<U+207B>³  
2 m³    m³    m<U+207B>³  
3 m³    m³    m<U+207B>³  
4 m³    m³    m<U+207B>³ 

我知道 expressionparse 函数但没有成功。

> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

attached base packages:
[1] stats     graphics  Grdevices utils     datasets  methods   base     

other attached packages:
 [1] rlang_0.4.11     caret_6.0-86     lattice_0.20-41  lubridate_1.7.10 forcats_0.5.1   
 [6] stringr_1.4.0    dplyr_1.0.5      purrr_0.3.4      readr_1.4.0      tidyr_1.1.3     
[11] tibble_3.1.1     ggplot2_3.3.3    tidyverse_1.3.1 

loaded via a namespace (and not attached):
 [1] httr_1.4.2           pkgload_1.2.1        jsonlite_1.7.2       splines_4.0.5       
 [5] foreach_1.5.1        prodlim_2019.11.13   modelr_0.1.8         assertthat_0.2.1    
 [9] stats4_4.0.5         cellranger_1.1.0     ipred_0.9-11         pillar_1.6.1        
[13] backports_1.2.1      glue_1.4.2           pROC_1.17.0.1        digest_0.6.27       
[17] rvest_1.0.0          colorspace_2.0-0     recipes_0.1.16       Matrix_1.3-2        
[21] plyr_1.8.6           timeDate_3043.102    pkgconfig_2.0.3      broom_0.7.6         
[25] haven_2.4.1          scales_1.1.1         gower_0.2.2          lava_1.6.9          
[29] mgcv_1.8-34          generics_0.1.0       farver_2.1.0         ellipsis_0.3.2      
[33] withr_2.4.2          nnet_7.3-15          cli_2.5.0            survival_3.2-10     
[37] magrittr_2.0.1       Crayon_1.4.1         readxl_1.3.1         fs_1.5.0            
[41] fansi_0.4.2          nlme_3.1-152         MASS_7.3-53.1        xml2_1.3.2          
[45] class_7.3-18         tools_4.0.5          data.table_1.14.0    hms_1.0.0           
[49] lifecycle_1.0.0      munsell_0.5.0        reprex_2.0.0         compiler_4.0.5      
[53] grid_4.0.5           iterators_1.0.13     rstudioapi_0.13      labeling_0.4.2      
[57] testthat_3.0.2       gtable_0.3.0         ModelMetrics_1.2.2.2 codetools_0.2-18    
[61] DBI_1.1.1            reshape2_1.4.4       R6_2.5.0             utf8_1.2.1          
[65] rprojroot_2.0.2      desc_1.3.0           stringi_1.5.3        Rcpp_1.0.6          
[69] vctrs_0.3.8          rpart_4.1-15         dbplyr_2.1.1         tidyselect_1.1.1  

解决方法

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

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

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...