我想为R中的双向网络图中的顶点标签使用不同的字体。第一列是一个人的名字,第二列是该人所隶属的组织(可能有双重隶属关系)。
这是数据示例
mBillingClient = BillingClient.newBuilder(this).enablePendingPurchases().setListener(this).build();
mBillingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(BillingResult billingResult) {
if (billingResult.getResponseCode() == OK) {
final Purchase.PurchasesResult purchasesResult = mBillingClient.queryPurchases(BillingClient.SkuType.INAPP);
if (purchasesResult.getResponseCode() == OK) {
final List<Purchase> purchases = purchasesResult.getPurchasesList();
for (final Purchase purchase : purchases) {
}
}
}
}
@Override
public void onBillingServiceDisconnected() {
CommonUtils.showToast(mActivity, "disconnected");
}
});
mUnlockPremiumButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final List<String> skuList = new ArrayList<> ();
skuList.add(getString(R.string.inapp_premium_product_id));
final SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder()
.setSkusList(skuList)
.setType(BillingClient.SkuType.INAPP);
mBillingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) {
for (SkuDetails skuDetails : skuDetailsList) {
if (getString(R.string.inapp_premium_product_id).equals(skuDetails.getSku())) {
final BillingFlowParams flowParams = BillingFlowParams.newBuilder()
.setSkuDetails(skuDetails)
.build();
final BillingResult result = mBillingClient.launchBillingFlow(mActivity, flowParams);
if (result.getResponseCode() == ITEM_ALREADY_OWNED)
{
CommonUtils.showToast(mActivity, getString(R.string.alert_purchased));
}
else if (result.getResponseCode() != OK)
{
//always returns a getResponseCode of -1 (service disconnected)
}
}
}
}
});
}
});
我为绘图中识别出的数据分配了两种字体样式(无特殊样式)。但是,发生以下错误,我不知道该如何解决:
# R version 3.5.1 (2018-07-02) -- "Feather Spray"
# igraph 1.2.4
set.seed(7)
# bipartite network data
nodes <- read.csv("example.csv", header = TRUE, sep =";")
> nodes
Person Organisation
1 John SPD
2 Maria SPD
3 John CDU
4 Karl CDU
5 Maik Greens
6 Lisa Left
7 Holger SPD
8 Nico CDU
9 Peter Greens
10 Astrid SPD
11 Theo Left
12 Rita Greens
13 Eric FDP
14 Walter CDU
15 Hilda FDP
16 Boris CDU
17 Olga FDP
18 Nina Left
19 Doris CDU
20 Udo SPD
summary(nodes)
library(igraph)
# different fonts and node shapes
shape <- c("circle", "square")
let <- c("Times", "Helvetica")
# creating graph (g)
g <- graph.data.frame(nodes, directed = FALSE)
# creating bipartite network
V(g)$type <- FALSE
V(g)$type[V(g)$name %in% nodes[, 1]] <- TRUE
plot(g, layout= layout_with_kk,
vertex.shape= shape[as.numeric(V(g)$type) + 1],
vertex.label.family= let[as.numeric(V(g)$type)+1]
)
我在这里找不到任何相关问题。
谢谢您的帮助和建议!