我有价格数据集Meerssen_prices
我希望逐年绘制。但是,年份在图中显示为十进制数。我怎么能摆脱它?
year Wheat
1826 1.27
1827 1.26
1828 2.1
1829 2.2
1830 2.5
1831 3.5
1832 3.9
1833 2.6
1834 1.15
1835 1.15
1836 1.1
1837 1.15
1838 2.5
1839 2.1
1840 2.2
1841 2.24
1842 2.15
1843 2.1
1844 1.25
1845 2.2
1846 3.1
1847 3.1
1848 2.2
1849 2.1
1850 2.75
1851 2.6
1852 2.2
1853 2.16
1854 4.16
1855 4.25
1856 3.1
1857 2.17
1858 2.17
1859 2.18
1860 3.1
1861 3.2
1862 3.15
1863 2.2
1864 2.1
1865 2.1
1866 2.1
1867 3.25
这是我的代码:
span <- input_slider(0.2, 1, value = 0.75)
Meerssen_Prices %>%
ggvis(~year, ~ Wheat) %>%
layer_points() %>%
layer_smooths(span = span)
如何帮助我摆脱这些十进制逗号?
谢谢! 本
答案 0 :(得分:0)
只需将年变量从数字更改为整数即可。
Meerssen_Prices %>%
mutate(year= as.integer(year)) %>%
ggvis(~year, ~ Wheat) %>%
layer_points() %>%
layer_smooths(span = span)
答案 1 :(得分:0)
这是我的解决方案:
library(ggvis)
span <- input_slider(0.2, 1, value = 0.75)
Meerssen_Prices %>%
ggvis(~year, ~ Wheat) %>%
layer_points() %>%
layer_smooths(span = span) %>%
add_axis("x", title="year", format="####")