Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting issues with using the setwd command #156

Open
MinhasMA opened this issue May 31, 2018 · 15 comments
Open

getting issues with using the setwd command #156

MinhasMA opened this issue May 31, 2018 · 15 comments

Comments

@MinhasMA
Copy link

Can someone comment on the setwd() command in R?
Seemingly have followed the correct syntax, but keep on getting an error
setwd("Addresstoworkingdirectory")

@VarunKShetty
Copy link
Collaborator

What is the error you get?

@MinhasMA
Copy link
Author

Was able to figure it out. Thanks!

@MinhasMA
Copy link
Author

However, there is another issue

Quitting from lines 58-69 (MarketSegmentationProcessInClassParts1and2.Rmd)
Error in file(filename, "r", encoding = encoding) :
cannot open the connection

rmarkdown::render("MarketSegmentationProcessInClassParts1and2.Rmd")

processing file: MarketSegmentationProcessInClassParts1and2.Rmd
|. | 2%
ordinary text without R code

|.. | 4%
label: setuplibraries (with options)
List of 2
$ echo : logi FALSE
$ message: logi FALSE

Quitting from lines 58-69 (MarketSegmentationProcessInClassParts1and2.Rmd)
Error in file(filename, "r", encoding = encoding) :
cannot open the connection

@VarunKShetty
Copy link
Collaborator

What are the lines 58 - 69 in your RMD file?

@VarunKShetty VarunKShetty reopened this May 31, 2018
@MinhasMA
Copy link
Author

suppressWarnings(source("../../AnalyticsLibraries/library.R"))
# Package options
suppressWarnings(ggthemr('fresh'))  # ggplot theme
opts_knit$set(progress=FALSE, verbose=FALSE)
opts_chunk$set(echo=FALSE, fig.align="center", fig.width=10, fig.height=6.35, results="asis")
options(knitr.kable.NA = '')

# Run below only once, then comment out
# New versions of the networkD3 package may not work properly, so install the following version
packageurl <- "https://cran.r-project.org/src/contrib/Archive/networkD3/networkD3_0.2.13.tar.gz"
install.packages(packageurl, repos=NULL, type="source")

\clearpage

@MinhasMA
Copy link
Author

I have the correct directory as set by setwd()
But it appears that some information was lost in translation?

@VarunKShetty
Copy link
Collaborator

"../../AnalyticsLibraries/library.R" is a relative path. This basically says, go up two levels from the working directorry and look for a folder called "AnalyticsLibraries" at that location. Does that process make sense in your context?
If not, subsitute the ../../AnalyticsLibraries/library.R with the absolute path. For example: In my case: Users/Varun/Docs/InseadAnalysticsGit/AnalyticLibraries/Library.R

@MinhasMA
Copy link
Author

Tried it but it did not work.
I looked at the folder and the analyticslibraries folder is not present in my home folder (setwd)

Could I comment out the whole section? 58-69?

@VarunKShetty
Copy link
Collaborator

No. Don't comment it out. The RMD needs that piece for knitting.

Do you have the Library.R script on your disk somewhere? What is the path to that file?

@MinhasMA
Copy link
Author

Yes, file is available on my computer.

I've made the following address change (locating it to the right folder)

Still get an error

suppressWarnings(source("C:\Users\manna\Documents\COURSES\Data Science for Business\INSEADAnalytics-master\INSEADAnalytics-master\CourseSessions\Session1
/AnalyticsLibraries/library.R"))

@VarunKShetty
Copy link
Collaborator

Can you try this instead? I just replaced with appropriate slashes. C:/Users/manna/Documents/COURSES/Data Science for Business/INSEADAnalytics-master/INSEADAnalytics-master/CourseSessions/Session1/AnalyticsLibraries/library.R

@MinhasMA
Copy link
Author

Tried and it still fails :(

Quitting from lines 58-71 (MarketSegmentationProcessInClassParts1and2.Rmd)
Error in file(filename, "r", encoding = encoding) :
cannot open the connection

Lines 58-71

suppressWarnings(source("C:/Users/manna/Documents/COURSES/Data Science for Business/INSEADAnalytics-master/INSEADAnalytics-master/CourseSessions/Session1/AnalyticsLibraries/library.R"))



# Package options
suppressWarnings(ggthemr('fresh'))  # ggplot theme
opts_knit$set(progress=FALSE, verbose=FALSE)
opts_chunk$set(echo=FALSE, fig.align="center", fig.width=10, fig.height=6.35, results="asis")
options(knitr.kable.NA = '')

# Run below only once, then comment out
# New versions of the networkD3 package may not work properly, so install the following version
packageurl <- "https://cran.r-project.org/src/contrib/Archive/networkD3/networkD3_0.2.13.tar.gz"
install.packages(packageurl, repos=NULL, type="source")

@VarunKShetty
Copy link
Collaborator

Are you sure your path is correct? You should be routing to the library.R inside AnalyticsLibraries. There isn't an AnalyticsLibraries folder inside Session1 typically.

@VarunKShetty
Copy link
Collaborator

"C:/Users/manna/Documents/COURSES/Data Science for Business/INSEADAnalytics-master/INSEADAnalytics-master/AnalyticsLibraries/library.R"
"C:/Users/manna/Documents/COURSES/Data Science for Business/INSEADAnalytics-master/AnalyticsLibraries/library.R"
I think your correct path should be one of the above two.

@MinhasMA
Copy link
Author

Thanks a lot. It works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants