【问题标题】:Unzipping with ldply produces Error Results do not have equal lengths使用 ldply 解压缩会产生错误 结果长度不相等
【发布时间】:2021-02-23 11:27:03
【问题描述】:

使用 ldply 解压缩文件列表时出现此错误

list_to_dataframe(res, attr(.data, "split_labels"), .id, id_as_factor) 中的错误: 结果长度不相等

library(curl)
# Create a temporarly file and Temporaly directory
temp_direct <- tempdir()
temp <- tempfile()

#Download ZIP file from web
curl_fetch_disk(url = "https://api.esios.ree.es/archives/9/download?date_type=datos&start_date=01-01-2020&end_date=31-08-2020",
                path = temp)
# Unzip downloaded file in temporaly directory, this creates several ZIP files in it.
unzip(temp, exdir =temp_direct )

# Create a list of files that contain C3 in filename.
zip_c3_pattern <- list.files(path = temp_direct, pattern = '*C3*', full.names = TRUE)
library(plyr)

# unzip all your files with previous pattern
ldply(.data = zip_c3_pattern, .fun = unzip, exdir = temp_direct)

【问题讨论】:

    标签: r plyr


    【解决方案1】:

    解决了自己将 ldply 替换为 llply 的问题

    llply(.data = zip_c3_pattern, .fun = unzip, exdir = temp_direct)
    

    【讨论】:

      猜你喜欢
      • 2016-02-20
      • 1970-01-01
      • 2016-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多