我有一个嵌套的tibbles列表(其中包括列表本身等,有点像开始)。
library(tidyverse)
# example function I want to apply
fun1 <- function(data) {
minimum <- min(data$Sepal.Length)
return(minimum)
}
# example of nested list
list_nested_tibbles <- list(
list1 = iris %>% group_by(Species) %>% nest(),
list2
我在读一个yaml文件
- person_id: 111
person_name: Russell
time:
- 1
- 2
- 3
value:
- a
- b
- c
- person_id: 222
person_name: Steven
time:
- 1
- 2
value:
- d
- e
我想将其去造化为:
person_id person_name time value
1 111 Russell 1 a
2 111 Russell 2 b
我的问题和这个非常相似:
我正在尝试解套嵌入在一个名为"Obs“的变量中的数据帧,但是我不明白为什么解套命令不起作用。
library(IMFData)
# Pull data from the CDIS database in the IMF Data
cdis <- imf_data(database_id = 'CDIS', indicator = 'IIWDA_DV_BP6_USD',
country = c('CN', 'GB'),
我构建了一个闪亮的应用程序,我用hist()和density()对象创建了一些情节,它们都保存在一个列表中,从另一个脚本文件中保存到一个.RDS文件中。所以,在闪亮的我只读了.RDS和制作的情节。
现在一切都在工作,除了我找不到如何用hchart()函数改变高图集的高度之外。在我的代码中,按照它的构建方式,我不能使用管道"%>%",因为我在purrr::map()函数中使用了hchart。
为了更好地解释,我创建了一个小示例,如下所示。
# Example of how the objects are structured
list <-
在本例中,我希望对dataset中的每个字符变量应用count()函数。
library(dplyr)
library(purrr)
nycflights13::flights %>%
select_if(is.character) %>%
map(., count)
但我收到了错误消息:
Error in UseMethod("groups") : no applicable method for
'groups' applied to an object of class "character"
我不知道如
我有一个字符串列表(在dataframe中)。我还拥有一个列表(与dataframe中的列表相同的大小),其中包含与索引对应的数字。我想从第一个列表中提取与第二个列表中的整数对应的元素。
这是我综合生成的数据
columnSentence<-list(c(",", ",Biopsies taken from top of stricture-metal marking clips in situ.",
",Diaphragmatic pinch:40cm .,She has a small hiatus hernia .",
"
我有以下简单的用例,其中我定义了两个包含名称和位置的示例:
if(!require(tidyverse)) install.packages("tidyverse", repos = "http://cran.us.r-project.org")
if(!require(ggmap)) devtools::install_github("dkahle/ggmap")
# you may also need to
#register_google(key="<register your own key>")
x &
如何访问dplyr::mutate_at正在处理的列名 比方说,我们想要将数据框中的一列转换为具有存储在单独列表中的级别的因子。 df <- data.frame("C1"=c("A","B","C"), "C2"=c("D","E","F"))
df
C1 C2
1 A D
2 B E
3 C F
lst <- list("C2"=c("F","E","D"), "
library(tidyverse)
library(broom)
library(dplyr)
# create a tibble with an id column for each simulation and x wrapped in list()
sim <- tibble(id = 1:1000,
x = list(rbinom(1000,1,0.5))) %>%
# to generate z, pr, y, k use map and map2 from the purrr package to loop over the list