我想保存包含带双引号的空格或空格的字符串列。
export class Task extends React.Component {
constructor(props){
super(props);
this.dataChanged = this.dataChanged.bind(this);
this.removeCurrentTask = this.removeCurrentTask.bind(this);
this.saveCurrentTask = this.saveCurrentTask.bind(this);
this.openCurrentTask = this.openCurrentTask.bind(this);
this.state = {
message: this.props.message
}
}
saveCurrentTask () {
this.props.saveTask(this.props.entryNum);
}
customValidateText (text) {
return (text.length > 0 && text.length < 31);
}
dataChanged(data) {
console.log(data.message);
this.props.renameTask(data.message,this.props.entryNum);
this.setState({ message: data.message });
}
removeCurrentTask () {
this.props.deleteTask(this.props.entryNum);
}
openCurrentTask () {
this.props.openTask(this.props.entryNum);
}
render () {
const centerRow = classNames('textCenter', 'row'),
iconSetup = this.props.iconClasses,
domIcons = [];
for (let icon in iconSetup) {
if (iconSetup.hasOwnProperty(icon)) {
let element = iconSetup[icon];
domIcons.push(<Icon className={classNames('large', element['inClass'])} onClick={element['clickFun']}/>)
}
}
return (
<div className={centerRow}>
{domIcons}
</div>
);
}
}
答案 0 :(得分:1)
如果你有这个:
df$label
#> [1] "" "Change working directory..."
#> [3] "" "Open script file..."
#> [5] "Save script..." "Save script as..."
你想用双引号包装内容,你可以这样做:
df$label <- paste0('"', df$label, '"')
df$label
#> [1] "\"\"" "\"Change working directory...\""
#> [3] "\"\"" "\"Open script file...\""
#> [5] "\"Save script...\"" "\"Save script as...\""
一次更新所有列
使用基础R(改编自@ r2evans的评论)
df[] <- lapply(df, function(x) paste0('"', x, '"'))
或者如果你喜欢使用类似dplyr
的东西,你可以这样做:
library(dplyr)
df <- mutate_all(df, ~ paste0('"', ., '"'))
答案 1 :(得分:-1)
您可以将""
替换为'""'
。