Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R column data.frame从数字格式转换为excel格式_R_Excel_Format - Fatal编程技术网

R column data.frame从数字格式转换为excel格式

R column data.frame从数字格式转换为excel格式,r,excel,format,R,Excel,Format,如何将data.frame的数字列格式化为excel样式的货币列。使用符号“$”和“,”分隔千 从 您可以使用scales::dollar data$Sepal.Length <- scales::dollar(data$Sepal.Length) head(data[, c('Species', 'Sepal.Length')]) # Species Sepal.Length #1 setosa $510,000,000 #2 setosa $490,000,000 #3 se

如何将data.frame的数字列格式化为excel样式的货币列。使用符号“$”和“,”分隔千


您可以使用
scales::dollar

data$Sepal.Length <- scales::dollar(data$Sepal.Length)
head(data[, c('Species', 'Sepal.Length')])

#  Species Sepal.Length
#1  setosa $510,000,000
#2  setosa $490,000,000
#3  setosa $470,000,000
#4  setosa $460,000,000
#5  setosa $500,000,000
#6  setosa $540,000,000

data$Sepal.LengthBaseR:

data$Sepal.Length <- paste0("$", format(data$Sepal.Length, big.mark=",", scientific=FALSE))
data$Sepal.Length <- scales::dollar(data$Sepal.Length)
head(data[, c('Species', 'Sepal.Length')])

#  Species Sepal.Length
#1  setosa $510,000,000
#2  setosa $490,000,000
#3  setosa $470,000,000
#4  setosa $460,000,000
#5  setosa $500,000,000
#6  setosa $540,000,000
data$Sepal.Length <- paste0("$", format(data$Sepal.Length, big.mark=",", scientific=FALSE))
    head(data[, c('Species', 'Sepal.Length')])
  Species Sepal.Length
1  setosa $510,000,000
2  setosa $490,000,000
3  setosa $470,000,000
4  setosa $460,000,000
5  setosa $500,000,000
6  setosa $540,000,000