我在 R 中创建了一个数据框,其中第 2 列包含我从 YouTube 中提取的每一行的 URL。下载了 youtubecaption 包,并希望将“get_caption()”函数应用于具有 URL 的列中的每一行。这是因为我想从我收集的每个 URL 转录音频。
我尝试通过执行以下操作来创建一个函数来自动执行此操作:
# Extracts the URLs from the page with the playlist of YouTube Videos
ExtractTranscript <- function(){
# Extract the Transcripts
Transcripts <- get_caption()%>%
return(data_frame(Transcript = Transcripts))
}
然后我尝试使用 apply 函数在列中的每个 url 上使用 get caption:
apply(YouTubeUrls,2, ExtractTranscript)
但是,它没有用。你有什么建议吗?谢谢!!