相关疑难解决方法(0)

是否可以将str输出存储在R对象中?

我想从数据帧的str输出中提取一些信息.

试过这个......

> tmp <- str(iris)
> tmp
NULL
Run Code Online (Sandbox Code Playgroud)

是否可以将其存储在变量中?

r

35
推荐指数
2
解决办法
4576
查看次数

在ggplot2_3.0.0中检索轴标签的值

如何在下面的ggplot中提取用于标记y轴和x轴的数字(分别20, 30, 40和10 , 15 ,20 ,25, 30, 35)?

情节

来自r-statistics.co

在此输入图像描述

可重现的代码

# Scatterplot
theme_set(theme_bw())  # pre-set the bw theme.
g <- ggplot(mpg, aes(cty, hwy))
g + geom_count(col="tomato3", show.legend=F) +
  labs(subtitle="mpg: city vs highway mileage", 
       y="hwy", 
       x="cty", 
       title="Counts Plot")
Run Code Online (Sandbox Code Playgroud)

我已经尝试查看输出str(g),但是成功了.

r ggplot2

6
推荐指数
1
解决办法
405
查看次数

R:从嵌套列表中按名称获取元素

我有一个像这样的嵌套列表:

smth <- list()
smth$a <- list(a1=1, a2=2, a3=3)
smth$b <- list(b1=4, b2=5, b3=6)
smth$c <- "C"
Run Code Online (Sandbox Code Playgroud)

列表中每个元素的名称都是唯一的。

我想仅通过名称从这样的列表中获取元素,而不知道它位于哪里。

例子:

getByName(smth, "c")=“C”

getByName(smth, "b2")= 5

另外,我真的不想使用,unlist因为真正的列表中有很多重元素。

r extract list nested-lists

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

标签 统计

r ×3

extract ×1

ggplot2 ×1

list ×1

nested-lists ×1