What is the procedure for loading a data set from a textbook in R?

  • Thread starter Eclair_de_XII
  • Start date
  • Tags
    Data Set
In summary: After installing the package and trying to run the commands, I get this error:Error in eval(m$data, eframe) : object 'juul' not foundI also tried typing in >data("juul") and it returned this message:"Warning message:In data("juul") : data set ‘juul’ not found"I'm sure I have already installed the data package that the book tells me to install. Is it possible that those data sets no longer exist on the internet? I'm led to believe this because of some things... First, I installed the package as indicated in the book in the opening post once more
  • #1
Eclair_de_XII
1,083
91

Homework Statement


I'm using a textbook called "Introductory Statistics with R" by Dalgaard, and I am having trouble doing one of the problems. It asks me to isolate names from a data set called "juul". But the problem is that I am unable to locate said data set.

Homework Equations


Functions used:
data()
install.packages()

The Attempt at a Solution


The problem is that I am unable to bring it up using the data() function. I have already installed the package that complements the book by typing in "install.packages("ISwR")", but I am still unable to find the data set in question. Do I need to specify where to look for the data set in R, or something?
 
Last edited:
Physics news on Phys.org
  • #3
I don't think it's a function. In the textbook I'm using, it specifically states that it is a data set, one that I am unable to retrieve.
 
  • #4
Ok, I see now. now.
I think I got confused by the usage. If I come across something else, I will post it.
 
  • #5
I don't suppose there's any chance that the name is a typo? It wouldn't be much of a stretch to see "jul" become "juul".
 
  • #6
Have you tried the command that is in the link that @scottdave provided?

plot(igf1~age, data=juul)

If so, did it give an error message?

What specific data command did you try and what error messages did you get?
 
Last edited:
  • #7
gneill said:
It wouldn't be much of a stretch to see "jul" become "juul".

The book specifically asks: "Write the logical expression to use to extract girls between 7 and 14 years of age in the juul data set".

FactChecker said:
If so, did it give an error message?

I tried the command and it returned this message:

"Error in eval(m$data, eframe) : object 'juul' not found"

I also tried typing in >data("juul") and it returned this message:

"Warning message:
In data("juul") : data set ‘juul’ not found"I'm sure I have already installed the data package that the book tells me to install. Is it possible that those data sets no longer exist on the internet? I'm led to believe this because of some things... First, I installed the package as indicated in the book in the opening post once more. Then I tried searching my entire computer for any instances of "juul".

ZUVpMf3.png


Then I clicked on the first result, and it takes me to this page:

AVW9O1l.png


It shows only a single hyperlink. I click on it, and I am taken to this website. I start scrolling around for "juul".

e0731yo.png


So I scroll down to find my database "juul". The databases in purple are likely links I've already visited and was unable to find the corresponding data set for.

jLjMu83.png


So I click on that link, and this is the error message that shows up, which leads me to believe that the database in question no longer exists.

khdcKJU.png


Thoughts? Sorry for all the picture-spam. Please let me know if it's disruptive, and I'll try to replace them with just links, or downsize them a bit.
 

Attachments

  • ZUVpMf3.png
    ZUVpMf3.png
    64.3 KB · Views: 535
  • AVW9O1l.png
    AVW9O1l.png
    64.1 KB · Views: 545
  • e0731yo.png
    e0731yo.png
    49.7 KB · Views: 490
  • jLjMu83.png
    jLjMu83.png
    50.7 KB · Views: 492
  • khdcKJU.png
    khdcKJU.png
    39.3 KB · Views: 510
  • #8
In the first screen-shot, it looks like you tried to access the data before you installed the package. That is certain to fail. I'm not sure that I understand what happened after that. Did you try those plot and data commands after installing the package? If so, what happened?

PS. You might try juul2. That may be the replacement of juul, which may have been deleted.
 
  • #9
Hm, it still doesn't work...

MrMrdTQ.png
 

Attachments

  • MrMrdTQ.png
    MrMrdTQ.png
    69.7 KB · Views: 516
  • #11
Thanks. But to be honest, it seems like too much work to copy all those text files, save them, and guess which directory I put them into for R to access.

I think I want to look for a different book, one whose exercises I can do without all this hassle.
 
  • #12
I think that the package has not been completely installed and loaded for use. That will be a problem no matter what book you use. See http://mazamascience.com/WorkingWithData/?p=728 and make sure that the data has been loaded for use. If you are not running as administrator, you may want to set up a personal library.
 
  • #13
From a quick glance at R Studio, the dataset "juul" is not currently loaded into the system. You've completed part of the step by typing

install.packages("ISwR")

All you've done here is install the R package. What you then need to do is to load the package into RStudio.

To do this, you need to run the following command:

library("ISwR")

This would actually load the library package. Once that's done, then the dataset should be there, and you could then go ahead and use the plot function.
 
  • Like
Likes scottdave and FactChecker

Related to What is the procedure for loading a data set from a textbook in R?

1. How do I load a data set from R?

In order to load a data set from R, you can use the read.csv() function. This function allows you to read in a data set from a CSV file and store it as a data frame in R.

2. What formats can I load data sets from in R?

R can load data sets from a variety of formats, including CSV, Excel, text files, and databases. You can use the appropriate function, such as read.csv(), read_excel(), read.table(), or read.db() to load data from these different formats.

3. How can I check if a data set has been successfully loaded in R?

You can use the head() function in R to view the first few rows of the data set and check if the data has been loaded correctly. Alternatively, you can also use the str() function to view the structure of the data set, which will show you the variable names and types.

4. Can I load multiple data sets into R at once?

Yes, you can use the list.files() function to load multiple data sets from a specified folder into R. This function will return a list of all the files in the specified folder, which you can then loop through and load each data set using the appropriate function.

5. How can I save a data set in R for future use?

You can use the write.csv() function to save a data set as a CSV file in a specified location. This will allow you to access and use the data set in the future without needing to load it again from its original source.

Similar threads

  • Programming and Computer Science
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
14
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
Replies
4
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Introductory Physics Homework Help
Replies
11
Views
2K
  • Precalculus Mathematics Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
1K
Back
Top