我正在尝试在R中编写一个函数,该函数使我可以使用render() {
const {
checkValue,
changeValue,
label,
meta: { touched, error }
} = this.props;
return (
<Content>
<View>
<View style={{ flexDirection: 'row' }}>
<CheckBox checked={checkValue} onPress={changeValue} />
<Text style={styles.agreementsTextStyle}>{label}</Text>
</View>
{touched && error && <Text style={styles.errorText}>{error}</Text>}
</View>
</Content>
); }}
自动查看数据框。这个想法是,当我想查看数据时,该函数将编写一个临时的csv文件并使用R打开它。这是我的代码:
Libreoffice
并且代码有效。但是,我想使用view <- function(data) {
FILE = "/home/spreadSheetView/temp.csv"
write.csv(data, file = FILE, row.names = F)
system(command = "export $(dbus-launch); \
export NSS_USE_SHARED_DB=ENABLED; \
libreoffice --calc /home/spreadSheetView/temp.csv")
}
或Libreoffice
之类的东西,而不是在$FILE
中打开文件时使用绝对目录,并且最后一行代码如下:< / p>
${FILE}
不幸的是,程序无法通过这种方式找到文件。您能否建议是否有使用这种方法的方法?谢谢!
答案 0 :(得分:2)
您可以使用
command = paste(
"export $(dbus-launch); \
export NSS_USE_SHARED_DB=ENABLED; \
libreoffice --calc",
FILE )
system(command)
答案 1 :(得分:1)
此社区Wiki答案取自先前存在于问题中的自我回答:
基于@CharlesDuffy的答案并进行了一些修订的代码,因为我无法使
/bin/sh
与export
一起工作。view <- function(data) { FILE = "/home/spreadSheetView/temp.csv" write.csv(data, file = FILE, row.names = F) system2(command = "export", args = c("$(dbus-launch) NSS_USE_SHARED_DB=ENABLED; ", "libreoffice --calc \"$1\" ", FILE)) }