一列具有不同的值,其中一个包含值Array
(
[4] => 4
[5] => 1
[7] => 2
[8] => 1
[9] => 1
[3] => 1
)
。
我想将其替换为If DirectRB.Checked Then
'introRange.Delete()
'Dim ODirect_intropara As Word.Paragraph = oDoc.Paragraphs.Add()
'ODirect_intropara.Range.Font.Name = "Arial Narrow"
'ODirect_intropara.Range.Font.Bold = CInt(False)
'ODirect_intropara.Range.Font.Size = 11
'ODirect_intropara.Format.SpaceAfter = 0
'ODirect_intropara.Range.Text = Direct_introduction
'ODirect_intropara.Range.ParagraphFormat.Alignment =
Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft
'ODirect_intropara.Range.InsertParagraphAfter()
introPara = oDoc.Content.Paragraphs.Add
introPara.Range.Text = Direct_introduction
introPara.Range.Font.Bold = True
introPara.Format.SpaceAfter = 24 '24 pt spacing after
paragraph.
introPara.Range.InsertParagraphAfter()
Rng = oDoc.Range(oDoc.Range.Characters.Count - 1,
oDoc.Range.Characters.Count)
Rng.InsertAfter(vbCrLf & "More text inserted using the range
object")
ElseIf PartnerRB.Checked Then
MessageBox.Show("you checked Partner")
End If
。
数据看起来像这样: 关口 F F G H * Ť *
我尝试了以下选项:
*
两者都不起作用
答案 0 :(得分:0)
replace
需要知道要替换的元素(x == "*"
):
x <- c("*", "a", "*", "a", "*", "a", "*", "a", "B")
replace(x, x == "*", "U")
#[1] "U" "a" "U" "a" "U" "a" "U" "a" "B"
在data.frame
df <- data.frame(x = x, stringsAsFactors = F)
df[df$x == "*", "x"] <- "U"
答案 1 :(得分:0)
不确定*
在数据框中出现的频率,但是您可以使用gsub
替换它的所有实例。
假设您有一列这样的内容:
df <- c("asd*asd", "432*432", "*")
[1] "asd*asd" "432*432" "*"
如果要将所有*
替换为U
,则可以运行此
gsub("\\*", "U", df)
[1] "asdUasd" "432U432" "U"
由于*
是一个特殊字符,因此您必须使用\\
对其进行转义,否则它将无法为您提供所需的内容。