有人可以编辑这个看起来更好吗?谢谢!
我正在尝试使用一个十六进制值的字符串,但它由第三方设置(不是代码本身)并将其设置回int但仍然是十六进制值。如果前面有0x,那么C#会让你有一个等于十六进制的int。
代码:
library(dplyr)
library(tidyverse) # for separate_rows
library(reshape) #for separate to separate columns
library(stringr) # for string manipulations i.e. remove tralining and leading white spaces
# data frame from your data
df_1 <- data.frame(col1='[[131 22 2 "male"] [123 23 2 "female"] [232 21 2 "male"] [132 21 2 "male"]]' , stringsAsFactors = FALSE)
# separate rows on closing brackets
df_2 <- df_1 %>% separate_rows(col1, sep = "]")
# remove other remaining brackets and leading and triling white space
df_2["col1"] <- gsub("\\[|\\]", "", str_trim(df_2[["col1"]], "both") )
# separate the single column data to multiple columns
df_2 %>% separate(col = col1, into = c("ID", "Num1","Num2", "Gender"), sep = " ") %>% na.omit() %>% select(1,4)
当我尝试这个时,我得到:'输入字符串的格式不正确。'
答案 0 :(得分:1)
您可以通过添加此app()->version()
:
System.Globalization.NumberStyles.HexNumber
希望它有所帮助!