Cannot connect to a dataset

I want to extract some data as my assignment. When I write command, it does not connect to the data set in Rstudio. I had already imported that data into the script window.

Please show the code you are running and any error messages you are getting. This should include the data you are using to read in the data set.

> ## Extract$'internetservicecolumn' and store in new vector -> customer

I tried uploading the customer_churn data. it cannot be uploaded, as it is unauthorized.

should be

churn <- read.csv("customer_churn")

assuming that the target file is in your working directory.

Thanks FJCC and technocrat for your support. by the following code in script window, the code is copied in console, as is, no error showing and customer_churn data also appears in script window:

#extract$internetservice into new data frame
##extract$internetservice -> customer.csv

But my command of extraction of internet services column is not granted! That is my aim.

does extract have a variable internetservice? Check with


Despite the name, subset of the object won't produce either a data frame or a csv file.

mpg.csv <- mtcars$mpg
#> [1] "numeric"
#> [1] "data.frame"

Thanks technocrat, but the problem still exists!

See the FAQ: How to do a minimal reproducible example reprex for beginners to clarify the problem.

Thanks technocrat for referring the link!

1 Like

@Somaira54 you have provided snippets of code with #'s in front of them. You know a # makes the rest of the line into a comment and so nothing happens.

So if you use

a <-2

You should get the result 4. People will often show that in the code like this:

> a <- 2
> a+a
# 4

The > means at the console command prompt
The # shows the result.

So now back to your question. What are you trying to do? What do you mean "extract" some data? Do you mean import it into R (known as 'read' in R) or export it out of R (known as 'write' in R).

# load a CSV file called customer_churn.csv into
# object called customer_churn
customer_churn <- read.csv("customer_churn.csv")

# Show the resulting data

# put the internetservice column into a new object
customer_churn$internetservice -> customer

# save the new object as a new CSV file
write.csv(customer, "new.csv")

Thank you so much CALUM_POLWART for explaining it so well!

View (customer_churn)


Error in file(file, "rt") : cannot open the connection

In addition: Warning message:

In file(file, "rt") :

cannot open file 'customer_churn.csv': No such file or directory

View (customer_churn)

Error in View : object 'customer_churn' not found

I have imported the customer_churn from the import data drop-down manu of environment window. But surprisingly I write the code in script window, the output in console shows as an error, "file customer_churn not found". That is the reason I cannot do my assignments. I do copy the same code as my teacher writes. I see that his commands smoothly give successful results. I see that the results in table forms as well as text forms. I have started to wonder that there is some compatabilty issue between my Mac version and Rstudio??

This sounds like the file path is wrong.

get.wd() will tell you where it looks

I am giving reply to myself. The reasons, my trainer is able to functions smoothly in Rstudio:

  1. He has created working directory as downloads,
  2. He has already imported all the datasets in the Rstudio
  3. He uses his many of his own user defined functions--UDF
    these are some of the reasons i found so far for his smooth functioning in RStudio.
    Thanks everyone for their kind input.

Hi CALUM_POLWART, you hit the nail! Thanks for your kind input!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.