我有一個問題,提取函數的參數在R.正則表達式來提取函數的參數中的R
x="theme(legend.position='bottom',
legend.margin=(t=0,r=0,b=0,l=0,unit='mm'),
legend.background=element_rect(fill='red',size=rel(1.5)),
panel.background=element_rect(fill='red'),
legend.position='bottom')"
我要的是:
[1]legend.position='bottom'
[2]legend.margin=(t=0,r=0,b=0,l=0,unit='mm')
[3]legend.background=element_rect(fill='red',size=rel(1.5))
[4]panel.background=element_rect(fill='red')
[5]legend.position='bottom'
我試了幾個正則表達式都沒有成功,包括以下:
strsplit(x,",(?![^()]*\\))",perl=TRUE)
請幫幫我!
我會帶你回去一步。你是如何以R/ggplot代碼保存爲文本的?我猜在這裏首先應該有一個更簡單的方法.. – thelatemail
其實我正在製作一個閃亮的godget來教ggplot2。我將把這個閃亮的應用程序變成RStudio插件包,並在幾天內在CRAN上發佈。 –
我在嘗試,但它有點複雜 – pirs