admin管理员组文章数量:1389754
I'm working on a script that requires me to reference a table of data stored outside of my current R working directory. My working directory and data is all stored within my anization's Sharepoint system, so in order to keep the script usable for other Sharepoint users, I set up my working directory call to refer to the path through active document context setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
. To refer to my dataset, I used the ../
notation to move up out of my working directory to the common parent folder between my script file and my dataset file (three levels up). Then I directly reference the filepath to the dataset to call it up. I've done this successfully in other scripts, but when I try it in this script, it throws an error. I don't know where I've gone wrong. I don't think I've hit on the character limit for filepath names, nor do I have unusual characters in the name. Is there a limit to how many levels you can go up or down in R filepaths?
Just to be clear, I know I could put the dataset in my working directory and that calling up the working directory in a non-direct way isn't ideal, but we have a specific file structure for a reason, and I want this to be a sustainable script that doesn't rely on me having a bunch of files in one folder that only I can access. Other people have to be able to run this script besides me.
# Sample Code (with dummy names for privacy reasons)
## Working directory
setwd(dirname(rstudioapi::getActiveDocumentContext()$path)) #sets the working directory as the folder where the script file is stored
# This sets the working directory as: C:/Users/myusername/My Organization/Group-SharePoint Site2 - Channel Name - Folder Name/Data Storage/PROD
## Data
census<-read_csv("../../../Group-Sharepoint Site1 - Documents/General/Public Datasets/State Name/State Name_ACSST5Y2023_S2101_Veteran Status.csv")
# The common parent folder is three levels up from my working directory
## Error
Error: '../../../Group-Sharepoint Dummy Folder - Documents/General/Public Datasets/State Name/State Name_ACSST5Y2023_S2101_Veteran Status.csv' does not exist in current working directory ('C:/Users/myusername/My Organization/Group-SharePoint Site2 - Channel Name - Folder Name/Data Storage/PROD').
本文标签: rReferencing a csv file outside of a working directory in SharepointStack Overflow
版权声明:本文标题:r - Referencing a .csv file outside of a working directory in Sharepoint - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744693197a2620121.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论