Cannot export data to a file in R (write.csv)
First part is to check the working directory and ensure that you have write access to that directory. You can check this with getwd()
. I can reproduce your error by trying to write to a directory which is read only.
To set the working directory to something else with read access you can type setwd("H:/foo")
.
Once you have write access the write.csv(x,file='whatever.csv')
should work.
Using write.csv() function in R but it doesn't actually save it to my C:
In my opinion, the simplest way would be to save the file to the same folder that rstudio is running in, and use the rstudio gui. It should be write.csv(daily_steps, "./daily_steps.csv") (no quotes around the function), and then on the tab in the bottom right of rstudio, you can select files, and it should be there. Then you can use the graphic user interface to move it to your desktop in a way analogous to what you would do in MS word.
Exporting Data to CSV in R
You did not assign the results of do.call function to anything. Fairly common R noob error. Failure to understand the functional programming paradigm. Results need to be assigned to R names or they just get garbage-collected.
The error is actually from the code that you didn't put in a code block:
write.csv(read.csv, file ='Lineups.csv')
The 'read.csv' was presumably your intended name for the result of the do.call
-operation, except it is by default a function name rather than your expectation. You could assign the do.call
-results to the name 'read.csv' but doing so is very poor practice. Choose a more descriptive name like 'TEMP_files_appended'.
TEMP_files_appended <- do.call("rbind",lapply(filenames, read.csv, header = TRUE))
write.csv(TEMP_files_appended, file ='Lineups.csv')
(I will observe that using header=TRUE
for read.csv
is not needed since that is the default for that function.)
Related Topics
Using R - Delete Rows When a Value Repeated Less Than 3 Times
Extracting Common Character Strings from Multiple Vectors of Different Lengths
Use Csl-File for PDF-Output in Bookdown
In Shiny Apps for R, How to Delay the Firing of a Reactive
Get the Vector of Values from Different Columns of a Matrix
Plot Negative Values in Logarithmic Scale with Ggplot 2
Cbind Two Lists of Data.Frames to a New List
How to Build a Crossword-Like Plot for a Boolean Matrix
User Defined Colour Palette in R and Ggpairs
Group Data in R for Consecutive Rows
Add Titles to Ggplots Created with Map()
R: Faceted Bar Chart with Percentages Labels Independent for Each Plot
R Remove Multiple Text Strings in Data Frame
Send a Text String Containing Double Quotes to Function