Can?t get past first step of Chapter 7 page 164. Opened a new RStudio window. Loaded tidyverse and keyed in library(tidyverse) which of course includes dplyr. The working directory is: C:/Users/Owner/Documents. Then keyed in: db <- src_sqlite(?data/pitchrx.sqlite?,create=TRUE) And got the following error: Error: Could not connect to database: unable to open database file Googled everything I could think of to find the sqlite function and the pitchrx.sqlite empty data base. Can someone give me some direction? I wondering if I have configured RStudio incorrectly. Why doesn?t my by RStudio point to the correct data file? [[alternative HTML version deleted]]
This is R-help, not RStudio-help, nor is it "Analyzing Baseball Data"-help, which means you cannot assume we know anything about what you are don't unless you tell us. However, it turns out that neither R nor RStudio are likely to be at fault here... it is up to you to keep track of which directory is the current directory (?getwd) and to insure that the files you want to access are in the directories where you are looking for them (a sub-directory called data within your current directory). Note that if you double-click on a file from most file manager windows, and that opens R or RStudio, the file manager will set the current directory conveniently to where the file is for you. For RGui (on-topic here), that file could be an empty start.RData file. For RStudio (not really on-topic here) that is usually a YourProject.Rproj file. But we don't know what files or sub-directories you have to work with, or how you are starting RStudio. Do read the Posting Guide and try to clarify your questions with R code and responses from R for best results on this mailing list. On March 16, 2020 3:35:36 PM PDT, Phillip Heinrich <herd_dog at cox.net> wrote:>Can?t get past first step of Chapter 7 page 164. > >Opened a new RStudio window. Loaded tidyverse and keyed in >library(tidyverse) which of course includes dplyr. The working >directory is: C:/Users/Owner/Documents. > >Then keyed in: db <- src_sqlite(?data/pitchrx.sqlite?,create=TRUE) > >And got the following error: Error: Could not connect to database: > unable to open database file > >Googled everything I could think of to find the sqlite function and the >pitchrx.sqlite empty data base. Can someone give me some direction? > >I wondering if I have configured RStudio incorrectly. Why doesn?t my >by RStudio point to the correct data file? > > > > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.-- Sent from my phone. Please excuse my brevity.
... and in addition see ?file.choose for an interactive way to choose files that may be easier and/or help you to diagnose your problems. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Mar 16, 2020 at 4:13 PM Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:> This is R-help, not RStudio-help, nor is it "Analyzing Baseball > Data"-help, which means you cannot assume we know anything about what you > are don't unless you tell us. However, it turns out that neither R nor > RStudio are likely to be at fault here... it is up to you to keep track of > which directory is the current directory (?getwd) and to insure that the > files you want to access are in the directories where you are looking for > them (a sub-directory called data within your current directory). > > Note that if you double-click on a file from most file manager windows, > and that opens R or RStudio, the file manager will set the current > directory conveniently to where the file is for you. For RGui (on-topic > here), that file could be an empty start.RData file. For RStudio (not > really on-topic here) that is usually a YourProject.Rproj file. But we > don't know what files or sub-directories you have to work with, or how you > are starting RStudio. > > Do read the Posting Guide and try to clarify your questions with R code > and responses from R for best results on this mailing list. > > On March 16, 2020 3:35:36 PM PDT, Phillip Heinrich <herd_dog at cox.net> > wrote: > >Can?t get past first step of Chapter 7 page 164. > > > >Opened a new RStudio window. Loaded tidyverse and keyed in > >library(tidyverse) which of course includes dplyr. The working > >directory is: C:/Users/Owner/Documents. > > > >Then keyed in: db <- src_sqlite(?data/pitchrx.sqlite?,create=TRUE) > > > >And got the following error: Error: Could not connect to database: > > unable to open database file > > > >Googled everything I could think of to find the sqlite function and the > >pitchrx.sqlite empty data base. Can someone give me some direction? > > > >I wondering if I have configured RStudio incorrectly. Why doesn?t my > >by RStudio point to the correct data file? > > > > > > > > > > [[alternative HTML version deleted]] > > > >______________________________________________ > >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > >https://stat.ethz.ch/mailman/listinfo/r-help > >PLEASE do read the posting guide > >http://www.R-project.org/posting-guide.html > >and provide commented, minimal, self-contained, reproducible code. > > -- > Sent from my phone. Please excuse my brevity. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Hi Phillip, Generally these problems come down to knowing/setting your working directory. The first question is whether you have a directory named "data" inside your "C:/Users/Owner/Documents" directory? You may need to create this directory first, outside of R and/or RStudio (using your Windows OS). Below is some example code (on a Mac). You might want to try 1) creating the "data" directory in Windows as mentioned earlier, 2) setting your working directory to "C:/Users/Owner/Documents/data", then 3) re-running your src_sqlite() command giving "pitchrx.sqlite? as the database file name.> getwd()[1] "/Users/homedir/R_Dir"> setwd("/Users/homedir/R_Dir/data")Error in setwd("/Users/homedir/R_Dir/data") : cannot change working directory>HTH, Bill. W. Michels, Ph.D. On Mon, Mar 16, 2020 at 3:35 PM Phillip Heinrich <herd_dog at cox.net> wrote:> > Can?t get past first step of Chapter 7 page 164. > > Opened a new RStudio window. Loaded tidyverse and keyed in library(tidyverse) which of course includes dplyr. The working directory is: C:/Users/Owner/Documents. > > Then keyed in: db <- src_sqlite(?data/pitchrx.sqlite?,create=TRUE) > > And got the following error: Error: Could not connect to database: > unable to open database file > > Googled everything I could think of to find the sqlite function and the pitchrx.sqlite empty data base. Can someone give me some direction? > > I wondering if I have configured RStudio incorrectly. Why doesn?t my by RStudio point to the correct data file? > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
On Mon, 16 Mar 2020 15:35:36 -0700 "Phillip Heinrich" <herd_dog at cox.net> wrote:> Can?t get past first step of Chapter 7 page 164. > > Opened a new RStudio window. Loaded tidyverse and keyed in > library(tidyverse) which of course includes dplyr. The working > directory is: C:/Users/Owner/Documents. > > Then keyed in: db <- src_sqlite(?data/pitchrx.sqlite?,create=TRUE) > > And got the following error: Error: Could not connect to database: > unable to open database > file > > Googled everything I could think of to find the sqlite function and > the pitchrx.sqlite empty data base. Can someone give me some > direction? > > I wondering if I have configured RStudio incorrectly. Why doesn?t my > by RStudio point to the correct data file? >I get the idea that this might be homework. There's a good deal of information missing if you want help, and probably you've neglected a few steps that need to be taken before you can proceed. You also need to understand the difference between R and RStudio. What you could do is type in "??src_sqlite() and see what it tells you. For instance, have you installed the package RSQlite? If you haven't you need to install it. It also appears that you might be running Windows. Have you installed sqlite? And so on ... JWD