根据列名称对直方图进行标题

时间:2020-06-14 01:42:20

标签: r histogram

我想在此data.frame的列上调用多个命令。也就是说,我想要geoMean(X)hist(X)basicstats = function(x){ a = summary(x); b = geoMean(x, na.rm = TRUE); hist(x, main = x); print(a); print(b) } ,以便可以使用50列以上的适当数据快速填充表。我的功能如下:

basicstats()

当我致电main = x时,摘要和geoMean效果很好。但是直方图标题看起来像这样!

enter image description here

显然,我的问题是我需要更改colnames(),以使标题是x的列名,而不是x的数据。我无法让[ERROR] 2020-06-14 01:17:31.633 [[main]-pipeline-manager] javapipeline - Pipeline aborted due to error {:pipeline_id=>"main", :exception=>#<ArgumentError: pathname contains null byte>, :backtrace=>["org/jruby/ext/pathname/RubyPathname.java:197:in `initialize'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-file-4.1.16/lib/logstash/inputs/file.rb:274:in `block in register'", "org/jruby/RubyArray.java:1809:in `each'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-file-4.1.16/lib/logstash/inputs/file.rb:273:in `register'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:216:in `block in register_plugins'", "org/jruby/RubyArray.java:1809:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:215:in `register_plugins'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:327:in `start_inputs'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:287:in `start_workers'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:170:in `run'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:125:in `block in start'"], "pipeline.sources"=>["/usr/share/logstash/bin/logstash.conf"], :thread=>"#<Thread:0x79aee194 run>"} [ERROR] 2020-06-14 01:17:31.667 [Converge PipelineAction::Create<main>] agent - Failed to execute action {:id=>:main, :action_type=>LogStash::ConvergeResult::FailedAction, :message=>"Could not execute action: PipelineAction::Create<main>, action_result: false", :backtrace=>nil} 处理向量x。有任何想法吗?

提前谢谢!

1 个答案:

答案 0 :(得分:0)

由@alistaire提供-我需要使用deparse(substitute(x))输入向量的名称。完美运行。