尝试使用以下示例数据创建图表:
DF:
kill -9 <pid>
我在这里遇到错误;
#include <stdio.h>
int main() {
int num,rem,te=0,to=0,e=0,o=0;
float ae,ao;
while (1) {
printf("\nEnter Number : ");
scanf("%d",&num);
if (num==0) break;
rem=num%2;
switch (rem) {
case 0 :
te+=num;
e++;
case 1 :
to+=num;
o++;
}
}
printf("\nTotal of even numbers : %d",te);
printf("\nTotal of odd numbers : %d",to);
printf("\nTotal of number of even numbers : %d",e);
printf("\nTotal of number of odd numbers : %d",o);
printf("\nAverage of even no. : %f",ae=te/e);
printf("\nAverage of odd no. : %f",ao=to/o);
getchar();
return 0;
}
ID DAY STORE PRODid QTY GBP PROD
2 8042899 1584 70470 1372 6 9.54 Yogurt
3 8042899 1586 70470 1372 2 3.18 Yogurt
4 8042899 1589 70470 1372 2 3.18 Yogurt
5 8042899 1590 70470 307 3 3.27 Yogurt
6 8042899 1590 70470 300 2 2.18 Yogurt
7 8042899 1590 70470 1372 1 1.59 Yogurt
列的问题不是 df[, .(total_sales = (sum(QTY) * (GBP))), by = DAY]
ggplot(aes(x = total_sales)) +
geom_histogram(fill = 'steelblue', bins = 50) +
labs(x = 'Day unit sales', title = 'Titlte of plot')
对象吗?
答案 0 :(得分:1)
我不确定你想要绘制的是什么,也不知道你遇到的错误是什么;我假设您要将total_sales
绘制为DAY
的函数。正如@PoGibas所建议的那样,你可以使用geom_bar
:
df <- read.table(text =
" ID DAY STORE PRODid QTY GBP PROD
2 8042899 1584 70470 1372 6 9.54 Yogurt
3 8042899 1586 70470 1372 2 3.18 Yogurt
4 8042899 1589 70470 1372 2 3.18 Yogurt
5 8042899 1590 70470 307 3 3.27 Yogurt
6 8042899 1590 70470 300 2 2.18 Yogurt
7 8042899 1590 70470 1372 1 1.59 Yogurt", header = T)
require(data.table);
require(margrittr);
require(ggplot2);
df <- as.data.table(df);
df[, .(total_sales = (sum(QTY) * (GBP))), by = DAY] %>%
ggplot(aes(x = DAY, y = total_sales)) +
geom_bar(fill = 'steelblue', stat = "identity") +
labs(x = 'Day', title = 'Title of plot')