小编Fis*_*ane的帖子

Jupyter 笔记本在新选项卡中打开链接

我想在我的 Jupyter Notebook 中创建超链接以在新选项卡中打开。但是,我不知道该怎么做。建议?

I want this [link](url) to open in a new tab.
Run Code Online (Sandbox Code Playgroud)

jupyter

3
推荐指数
1
解决办法
4755
查看次数

R中的传单图例基于颜色和形状

我在传单图上有图标,根据我的数据框中的一些变量,它们具有不同的颜色和形状.我想在绘图中包含一个图例,显示每个形状和颜色组合代表什么.我该怎么办?

用虚拟数据演示:

 library(leaflet)

 lat1= 36+runif(n=5,min=-1,max=1)

 lon1 =-115+runif(n=5,min=-1,max=1)

lat2= 35+runif(n=5,min=-0.5,max=0.5)
lon2 =-110+runif(n=5,min=-0.5,max=0.5)

lat3= 34+runif(n=5,min=-0.5,max=0.5)
lon3 =-112+runif(n=5,min=-0.5,max=0.5)
data_all=rbind(data.frame(Longitude=lon1,Latitude=lat1,Group=sample(c(16,17,18),5,replace = TRUE),condition=sample(c("red","blue","green"),5,replace = TRUE),stringsAsFactors = FALSE),
           data.frame(Longitude=lon2,Latitude=lat1,Group=sample(c(16,17,18),5,replace = TRUE),condition=sample(c("red","blue","green"),5,replace = TRUE),stringsAsFactors = FALSE),
           data.frame(Longitude=lon3,Latitude=lat1,Group=sample(c(16,17,18),5,replace = TRUE),condition=sample(c("red","blue","green"),5,replace = TRUE),stringsAsFactors = FALSE))

# A function to create png images for each shape and color 
pchIcons = function(pch = 1, width = 30, height = 30, bg = "transparent", col = NULL, ...) {
  n = length(pch)
  files = character(n)
  # create a sequence of png images …
Run Code Online (Sandbox Code Playgroud)

r leaflet

3
推荐指数
1
解决办法
1302
查看次数

R jsonlite:以特定格式创建 JSON 数据

我想使用 R 的 jsonlite 包创建 JSON 数据以使用Python加载到DynamoDB。我希望数据位于如下所示的结构中。如何在 R 中创建它?我尝试创建一个数据框,其中一列是列表,并将数据框更改为 json,但结果不是所需的格式。我还尝试转换包含列表的列表,但输出 json 的结构不是我想要的。

[
{
    "ID": 100,
    "title": "aa",
    "more": {
      "interesting":"yes",
      "new":"no",
      "original":"yes"
    }
},

{
    "ID": 110,
    "title": "bb",
    "more": {
      "interesting":"no",
      "new":"yes",
      "original":"yes"
    }
},

{
    "ID": 200,
    "title": "cc",
    "more": {
      "interesting":"yes",
      "new":"yes",
      "original":"no"
    }
  }
]
Run Code Online (Sandbox Code Playgroud)

这是我的示例数据和我尝试过的:

library(jsonlite)

ID=c(100,110,200)
Title=c("aa","bb","cc")
more=I(list(Interesting=c("yes","no","yes"),new=c("no","yes","yes"),original=c("yes","yes","no")))

 a=list(ID=ID,Title=Title,more=more)
 a=toJSON(a)
 write(a,"temp.json")  # this does not give the structure I want
Run Code Online (Sandbox Code Playgroud)

json r jsonlite

0
推荐指数
1
解决办法
3133
查看次数

带有 ggplot2 的条形图中的条形图

是否可以使用 ggplot2 在 R 中的条形图中绘制条形图,如下图所示。我想比较预期值和实际值,我想生成一个类似于下图的图。我提供了一些虚拟代码:

 library(tidyverse)

df = data_frame(name = letters[1:10],profit = rnorm(mean = 100, sd = 20, n = 10),
            target = profit + rnorm(mean = 10, sd = 10, n = 10))

   df %>% ggplot(aes(x = name, y = profit)) + geom_bar(stat = "identity") 
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

r ggplot2

0
推荐指数
1
解决办法
535
查看次数

标签 统计

r ×3

ggplot2 ×1

json ×1

jsonlite ×1

jupyter ×1

leaflet ×1