Create a *read-only* CSV - r

I hope this is a straightforward question -- I create a lot of output files using write_csv, and for auditing purposes, I need to be sure that those csv files can't be modified by someone else. Is there a way to write a CSV file that's read-only? write.csv and write_csv don't have any obvious parameters for this when creating the file; am I missing anything, or is there another way to do this?

You could try to use this:
system("attrib +R file.csv")

Related

Download a text file of items in the global environment

What to do when you have a lot of individual objects in the global environment and you want to save them as a table of values?
I could not find any similar questions here, but found and an answer in the R help files eventually. It's posted below.
The dump function in base R did the trick. I used dump(ls(), "my_file_name.txt")
It produces a text file that you can edit pretty easily. I used a macro in notepad++ to replace the <- items and delete the line break, resulting in a file I could easily copy and paste into a table.
There's probably a better way. Other answers are more than welcome.

Execute R files through an R script

I'm not sure how to properly ask this but basically I have a very populated single 400 line file on a kaggle competition I was working on and I want to split it up into multiple files (say one file is for data cleaning, another file is for feature engineering etc) in such a way that I can have one main file that will go from reading the csv files all the way to making the model predictions, how can I do that in R? Do I have to encapsulate the entire files into one function each and then use that? If so how does that work? Thanks in advance
You can use the source command and pass it the filename. try ?source

Create directory and write insite files

I have a script, written in R, that generate a lot of output. I would like to put these outputs into their own directories. Then I would like to create, in R, a directory and then move into it, writing file inside it. Is there a way to approach this?
Use dir.create() function. Link:
https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/files2

Using a Value in write.csv

Maybe a simple question, but I am trying to automate a bit of code, including the write.csv process.
I want to use a character (Stationname, e.g. STN76) to name the csv, I have this:
write.csv(AbunData, file = Stationname)
Where the station name is the automated bit. Which sort of works, but without the .csv file encoding. I want to .csv to be
STN76.csv
or would would be even better!
STN76_Routput.csv
Cheers!
if you include more details on exactly what you are doing you will probably get a more helpful answer :), but have you explored using paste() or paste0() to create the file names. E.g.:
file_name <- paste0("STN", SOME_NUMBER, "_Routput.csv")

"filename.rdata" file Exploring and Converting to CSV

I'm no R-programmer (because of the problem I started learning it), I'm using Python, In a forcasting task I got a dataset signalList.rdata of a pheomenen called partial discharge.
I tried some commands to load, open and view, Hardly got a glimps
my_data <- get(load('C:/Users/Zack-PC/Desktop/Study/Data Sets/pdCluster/signalList.Rdata'))
but, since i lack deep knowledge about R, I wanted to convert it into a csv file, or any type that I can deal with in python.
or, explore it and copy-paste manually.
so, i'm asking for any solution whether using R or Python or any tool to get what's in the .rdata file.
Have you managed to load the data successfully into your working environment?
If so, write.csv is the function you are looking for.
If not,
setwd("C:/Users/Zack-PC/Desktop/Study/Data Sets/pdCluster/")
signalList <- load("signalList.Rdata")
write.csv(signalList, "signalList.csv")
should do the trick.
If you would like to remove signalList from your working directory,
rm(signalList)
will accomplish this.
Note: changing your working directory isn't necessary, it just makes it easier to read in a comment I feel. You may also specify another path for saving your csv to within the second argument of write.csv.

Resources