我需要将一行上的观察分成多行,并且仍然只有一行。
例如
Sub SetInconsistentFormulaErrorsFalse(rng As Range, _
Optional arrErrortypes As Variant = Null, _
Optional bIgnoreErrors As Boolean = True)
Dim cl As Range
Dim i As Integer
If IsNull(arrErrortypes) Then
arrErrortypes = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
End If
For i = 0 To UBound(arrErrortypes) - 1
For Each cl In rng.Cells
cl.Errors(arrErrortypes(i)).Ignore = bIgnoreErrors
Next
Next i
Set cl = Nothing
End Sub
然后我得到DATES with levels()
source<-data.frame("MEASURE"=c("First","First","Second"),"DATE"=c("2017-11-02","2017-12-12","2017-05-15"))
source<-source[source$MEASURE=="First",]
source<-droplevels(source)
然后实现另一个DF:
y<-paste(levels(as.factor(cf$DATE)),collapse=",")
给出了:
s1<-data.frame(matrix(nrow=1, ncol=2))
s1[1,1]<-"Date"
s1[1,2] y
但我需要这样的东西
X1 X2
1 Date 2017-11-02,2017-12-12
要分割的单词可以是1,2或更多。 df仅用于汇总,它将在DT :: renderdataTable()
上用于闪亮任何人都可以帮助我?
答案 0 :(得分:1)
使用参数escape
可能是一个解决方案。您可以在https://rstudio.github.io/DT/第2.9节了解此论点。并用逗号代替断行:
library(dplyr)
library(stringr)
s1$X2 %>% str_replace_all(pattern = "[,]", replacement = "<br/>")
datatable(s1, escape = FALSE)