問題タブ [geom-vline]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
r - ggplot でそれ以外の場合 + geom_vline の文字と数値の間で値を切り替える
ブロックをggplotに統合する必要がありif else
ます。値に応じて、次のvariable_to_switch
ようになります。
- 値が数値の場合 -> プロット ライン
- 値はテキスト -> 線をプロットしない
提供されたソリューションとの競合の可能性を考慮して、コードを最も完全なバージョンで提供します。
variable_to_switch == "Text"
このエラーが発生する
場合: Error: Discrete value supplied to continuous scale
.
任意variable_to_switch
の数値プロットに等しい場合は機能します。
の文字と数値を切り替えたいvariable_to_switch
。次の場合の
望ましい出力variable_to_switch == "Text"
: