How can I store "meter superscript minus 3" in a dataframe column

Viewed 112

Update: Session info at the bottom

I want to mutate a column with "m-³" in a dataframe. Both the minus sign and 3 should be superscript:

The dataframe:

df <- tribble(
  ~x, 
  "m³",  
  "m³",  
  "m³",  
  "m³"
)
  1. I can get m³ by the keyboard -> column x
  2. I can get m³ by unicode "\U006D\U00B3"

But a minus (unicode = "\U207B") is not possible.

I have tried so far:

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>³ 

I am aware of expression and parse function but had no success.

> 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  
0 Answers
Related