我正在使用plotly绘制一个带ggplot的图形.如何在情节上使情节私密而不是公开?我的代码看起来像:
a <- ggplot(data, aes(var1, var2, text=var3)) + geom_point()
py$ggplotly(a)
Run Code Online (Sandbox Code Playgroud) 我的数据框包含以下数据:
Tester W1 W2 W3 A P WD(%) TS(Hrs.) AT(Hrs.) SU(%)
a 60 40 102 202 150 100 120 120 100
b 30 38 46 114 150 76 135 120 100
c 25 30 52 107 150 71 120 120 100
Run Code Online (Sandbox Code Playgroud)
通过使用该包,jsonlite我已转换为json格式:
{
"Tester": [ "a", "b", "c" ],
"W1": [ 60, 30, 25],
"W2": [ 40, 38, 30 ],
"W3": [ 102, 46, 52 ],
"A": [ 202, 114, 107 ],
"P": [ 150, 150, 150 ], …Run Code Online (Sandbox Code Playgroud) 这是我的示例数据:
table1
xaxis yaxis ae work
1 5 35736 Attending_Education Working
2 6 72286 Attending_Education Working
3 7 133316 Attending_Education Working
4 8 252520 Attending_Education Working
5 9 228964 Attending_Education Working
6 10 504676 Attending_Education Working
Run Code Online (Sandbox Code Playgroud)
这是我使用过的代码。
p<-ggplot(table1,aes(x=table1$xaxis,y=table1$yaxis))
Economic_Activity<-factor(table1$work)
Education_Status<-factor(table1$ae)
p<-p+geom_point(aes(colour=Education_Status,shape=Economic_Activity),size=4)
p+xlab("Population Ages")+ylab("Attending Education Institutions Count")+ggtitle("Attending Educational Institutions by Economic Activity Status :: INDIA 2001")
Run Code Online (Sandbox Code Playgroud)
这是我得到的输出。

我希望在此图中做两件事。
我希望手动为这些分类变量设置颜色(Attending_Education\Not_AE)。例如。深绿色表示 attend_Education,红色表示 Not_AE。
在经济活动的传说中,我不需要黑色来表示工作\不工作类别。我需要深绿色和红色。
我是 R 新手。我也尝试过调色板(),也发现了@下面的链接。但似乎没有任何作用 如何将特定颜色分配给 R 中的特定分类变量?
注:请看我的要求。
table1
xaxis yaxis ae work
1 5 35736 Attending_Education Working
2 6 …Run Code Online (Sandbox Code Playgroud)我在prometheus中有不同的指标counter_metrics a,couneter_metrices b并且我想要一个singlestat来统计所有不同的请求指标。
我该如何获取?
(sum(couneter_metrics{instance="a,job="b"}))+
Run Code Online (Sandbox Code Playgroud) 我在使用多个 if 语句时遇到问题。输出总是取自第一个条件,即使条件不正确.. 谁能指出我做错了什么?
代码:
for(i in 1:length(data_model3$Gewicht)){
if (data_model3$Gewicht[i] < 1){
data_model3$LIXshipping <- 3.26
}
else if (data_model3$Gewicht[i] > 1 & data_model3$Gewicht[i] < 2){
data_model3$LIXshipping <- 3.26
}
else if (data_model3$Gewicht[i] > 2 & data_model3$Gewicht[i] < 3){
data_model3$LIXshipping <- 3.86
}
else if (data_model3$Gewicht[i] > 3 & data_model3$Gewicht[i] < 4){
data_model3$LIXshipping <- 3.86
}
else if (data_model3$Gewicht[i] > 4 & data_model3$Gewicht[i] < 5){
data_model3$LIXshipping <- 3.86
}
else if (data_model3$Gewicht[i] > 5 & data_model3$Gewicht[i] < 10){
data_model3$LIXshipping <- 4.39 …Run Code Online (Sandbox Code Playgroud) 我可以使用以下代码块创建与数据库的连接:
library("RJDBC", "DBI")
library("dplyr.snowflakedb")
library("dplyr")
options(dplyr.jdbc.classpath = "/jar_files/snowflake-jdbc-3.10.0.jar")
conn <- src_snowflakedb(
user = "username",
password = "password",
account = "account",
host = "account.eu-west-1.snowflakecomputing.com",
opts = list(
warehouse = "PUBLIC",
db = "PROD",
schema = "SCHEMA")
)
Run Code Online (Sandbox Code Playgroud)
当我跑步时:
class(conn)
Run Code Online (Sandbox Code Playgroud)
我得到:
类(conn)[1]“src_snowflakedb”“src_sql”“src”
如果我跑
db_list_tables(conn$con)
Run Code Online (Sandbox Code Playgroud)
结果是:
db_list_tables(conn$con) [1] "GA_CUSTOMER_CDP_TP" "APPLICABLE_ROLES" "COLUMNS" "DATABASES"
[5] "ENABLED_ROLES" "EXTERNAL_TABLES" "FILE_FORMATS" "FUNCTIONS"
[9] "INFORMATION_SCHEMA_CATALOG_NAME" "LOAD_HISTORY" "OBJECT_PRIVILEGES" "PIPES "
[13] "PROCEDURES" "REFERENTIAL_CONSTRAINTS" "REPLICATION_DATABASES" "SCHEMATA"
[17] "SEQUENCES" "STAGES" "TABLES" "TABLE_CONSTRAINTS"
[21] "TABLE_PRIVILEGES" "TABLE_STORAGE_METRICS" "USAGE_PRIVILEGES" "VIEWS"
[25] " APPLICABLE_ROLES" "COLUMNS" "DATABASES" …
我在我的代码中有这个来获取数组的频率.
$arr = array(10, 9, 23, 7, 40, 43, 7, 5, 10, 7);
$frq = array_count_values($arr);
foreach($frq as $key => $values){ print $key . " = " . $values . "<br>";}
Run Code Online (Sandbox Code Playgroud)
输出:
5 = 1
7 = 3
9 = 1
10 = 2
23 = 1
40 = 1
43 = 1
Run Code Online (Sandbox Code Playgroud)
现在有没有办法for只使用循环来解决这个问题- 即不使用array_count_values()函数?谢谢.
int fp, page;
char *data;
if(argc > 1){
printf("Read the docs");
exit(1);
}
fp = open("log.txt", O_RDONLY); //Opening file to read
page = getpagesize();
data = mmap(0, page, PROT_READ, 0,fp, 0);
initscr(); // Creating the ncurse screen
clear();
move(0, 0);
printw("%s", data);
endwin(); //Ends window
fclose(fp); //Closing file
return 0;
Run Code Online (Sandbox Code Playgroud)
这是我的代码,由于某种原因,我不断收到分段错误。我所有的头文件都已包含在内,所以这不是问题(显然,因为它与内存有关)。提前致谢。
编辑:明白了 - 它没有被格式化为字符串。并且还必须使用 stat() 来获取文件信息而不是 getpagesize()
r ×5
ggplot2 ×2
c ×1
dplyr ×1
grafana ×1
if-statement ×1
jsonlite ×1
loops ×1
mmap ×1
php ×1
plotly ×1
private ×1
prometheus ×1
snowflake-cloud-data-platform ×1
unix ×1