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.
read.csv(cutomer_churn) View(customer_churn) > ## Extract$'internetservicecolumn' and store in new vector -> customer
I tried uploading the customer_churn data. it cannot be uploaded, as it is unauthorized.
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.
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 class(mpg.csv) #>  "numeric" class(mtcars) #>  "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!
@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 a+a
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 View(customer_churn) # 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!
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
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:
- He has created working directory as downloads,
- He has already imported all the datasets in the Rstudio
- 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.