试图用“字符”绘制R中的条形图。在X轴上和“因素”上在y轴上
学位:我,BE,EMP,NAME,EIM,MA,MA,MH,OE,RC,CFS,AS
收入:73926,97410,74179,74179,75635,78866,54000,54000,44800,45000,45000
结构(list = c(“ me”,“ be”,“ emps”,“ name”,“ eim”, “ EC”,“ MA”,“ MH”,“ OE”,“ RC”,“ CFS”,“ AS”),收入= C(73926,, 97410,74179,75635,78866,54000,44800,45000,46300,46400, 46500,47000)),class = c(“ tbl_df”,“ tbl”,“ data.frame”),row.names = c(na,, -12L))
'' barplot(数据$度,数据$收入) '''
新手在这里。我正在尝试复制下面的条形图,但是在R中,我确实在努力挣扎,因为所有尝试都以错误的“参数不是数字或逻辑”结尾。不确定下一步该做什么和任何建议将不胜感激。
Degrees: ME, BE, EMPS, NAME, EIM, EC, MA, MH, OE, RC, CFS, AS
Income: 73926, 97410, 74179, 75635, 78866, 54000, 44800, 45000, 46300, 46400, 46500, 47000
structure(list(Degree = c("ME", "BE", "EMPS", "NAME", "EIM",
"Ec", "MA", "MH", "OE", "RC", "CFS", "AS"), Income = c(73926,
97410, 74179, 75635, 78866, 54000, 44800, 45000, 46300, 46400,
46500, 47000)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-12L))
'''
barplot(data$Degrees, data$Income)
'''
Newbie to R here. I am trying to replicate the bar chart below, but in R. Really struggling with this as all attempts end with the error 'argument is not numeric or logical'. Unsure what to do next and any advice would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
寻找
ggplot2
尝试创建代码strucutre的软件包信息,以便您可以编辑某些特征,例如文本大小等:
Look for
ggplot2
package informationTryed to create the code strucutre so you can edit some characteristc like texts size and etc:
您也可以尝试:
我不确定如何执行此操作(我主要使用ggplot2,而不是基本r图),但这是我为弄清楚它所做的,以防万一它有助于任何未来的终点。
我在代码中选择了单词
barplot
,然后单击F1以获得该功能的帮助。您还可以在控制台中键入?barplot
。r帮助文件具有某种格式,可能需要一些习惯。前注的“用法”部分是它所采取的论点。底部的“示例”部分通常显示使用该函数的正常方式。它显示
barplot(gnp〜年,data = longley)
具有与其他R函数相同的语法代码> y〜x 表示,取决于功能,“回归或绘图y作为x的函数”。
You might also try:
I wasn't sure how to do this (I mostly use ggplot2, not base R plots), but here's what I did to figure it out, in case it helps for any future endevours.
I selected the word
barplot
in the code and clicked F1 to get the help for the function. You can also type?barplot
in the console.R help files have a certain format that might take some getting used to. The "Usage" section on the top notes the arguments it takes. The "Examples" section at the bottom typically shows the normal way(s) to use the function. It shows
barplot(GNP ~ Year, data = longley)
which has the same syntax as some other R functions likelm
andplot
, wherey ~ x
means, depending on the function, "regress or plot y as a function of x."