我正在寻找R中的一个函数,它可以准确再现Matlab的挤压函数。有人知道吗?
答案 0 :(得分:1)
(我曾经想过,提问者应该解释Sub RemoveInvalidCharacters()
Dim sCharOK As String, s As String
Dim r As Range, rc As Range
Dim j As Long
Dim badchar As Boolean
sCharOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789, `~!@#$%^&*()_+-=[]\{}|;':"",./<>?™®"
Set r = Worksheets("features").UsedRange.SpecialCells(xlCellTypeConstants, xlTextValues)
' loop through all the cells with text constant values and
' deletes the invalid characters not in sCharOK from each Value property
For Each rc In r
badchar = False
s = rc.Value
For j = 1 To Len(s)
If InStr(sCharOK, Mid(s, j, 1)) = 0 Then
badchar = True
s = Replace(s, Mid(s, j, 1), "")
End If
Next j
If badchar Then
rc.Value = s
End If
Next rc
End Sub
实际上做了什么 - 放弃单身尺寸。)
请参阅R中squeeze
函数的帮助;这也会降低单身尺寸。