Can any body help me with these questions using R studios? Thank u very very much

  1. Use the read_csv function to read each of the files that the following code saves in the files object:
path <- system.file("extdata", package = "dslabs")
files <- list.files(path)
  1. Note that the last one, the olive file, gives us a warning. This is because the first line of the file is missing the header for the first column.

Read the help file for read_csv to figure out how to read in the file without reading this header. If you skip the header, you should not get this warning. Save the result to an object called dat .

  1. A problem with the previous approach is that we don’t know what the columns represent. Type:

to see that the names are not informative.

Use the readLines function to read in just the first line (we later learn how to extract values from the output).

This seems like homework, more so, it seems like part of a lesson. It instruct you.
Please see the homework policy.
You are welcome to ask us specific questions of your own, but don't point to a list of questions others have you and ask us to explain them to you. That appears to be just lazy. At least say what part of the material you don't understand and need more help with, but actually take the effort to identify these points. Thanks

FAQ: Homework Policy

1 Like

It's "Importing data" to R, I tried my best but I was not able to understand this, pls help me.

step 1 assumes that you have installed a package called dslabs
Have you followed previous instructions to do that ?

1 Like

i have already installed it, and the tidyverse package for this session

can u instruct me how to use the read_csv function to perform that in question 1 and 2

so... what happens when you do step 1 ?

1 Like

the dslabs was installed into my Documents folder.

what does the content of files show you ?

1 Like

@nirgrahamuk please help me with these code :((

please, if I ask you a question, try to answer it.
what does the content of files show you ?
or you didnt run the code of step 1 ?

1 Like

It shows these:
[1] "2010_bigfive_regents.xls"
[2] "carbon_emissions.csv"
[3] "fertility-two-countries-example.csv"
[4] "HRlist2.txt"
[5] "life-expectancy-and-fertility-two-countries-example.csv"
[6] "murders.csv"
[7] "olive.csv"
[8] "RD-Mortality-Report_2015-18-180531.pdf"
[9] "ssa-death-probability.csv"

ok, so what did you do after that step ?
did you read each of the csv's listed by using the read_csv() function ?

1 Like

It just appear Error in read_csv() : could not find function "read_csv" when I use read_csv function :((

Oh, you are to use read_csv over read.csv, then this would require that you at one time install the readr package, and then when you want to use read_csv in your work, you would attach the readr library. or prefix the function call with the readr name like readr::read_csv.

Have you installed readr ?

1 Like

@nirgrahamuk I've already installed readr and when I use library(readr) to load it and I typed read_csv() like u said, it just appeared

Error in read_delimited(file, tokenizer, col_names = col_names, col_types = col_types, :
argument "file" is missing, with no default
BTW, it is my homework :((

You didn't pass a file argument to read_csv. Were you taught about functions and their arguments? read_csv() needs to know the file to load for you

1 Like

I use read_csv function to read the files like this, Is it right?


A tibble: 8 x 1


1 carbon_emissions.csv
2 fertility-two-countries-example.csv
3 HRlist2.txt
4 life-expectancy-and-fertility-two-countries-example.csv
5 murders.csv
6 olive.csv
7 RD-Mortality-Report_2015-18-180531.pdf
8 ssa-death-probability.csv