Read and Write Rdata to and from csv
setwd('/Users/drwhite/Documents/3sls/0Bin/') load("vaux.Rdata",.GlobalEnv) write.csv(vaux,"vaux2.csv") vaux2<-read.csv("vaux2.csv", header=TRUE) save(vaux2,file='vaux2.Rdata')
- The first piece of advice is to avoid doing so if possible! If you have access to Excel, export the data you want from Excel in tab-delimited or comma-separated form, and use read.delim or read.csv to import it into R.
read.csv and read.delim provide arguments to read.table appropriate for CSV and tab-delimited files exported from spreadsheets in English-speaking locales.
http://www.cyclismo.org/tutorial/R/input.html gave the hint to do forag <- read.csv(" ")
setwd("C:/My Documents/Binford") forag <- read.csv("Binford47vars.csv") save(forag,file="Binfordvars47.RData")
- loading data into R
- Rpad An environment for building R projects
- Rpad cheat sheet for R
- extract a table
- R FAQ The very basics of R
Q: How can I save my work?
- You can save all the objects and functions that you have created in an .RData file,
by using the save or the save.image functions. It is very important that you remember to include the .RData extension when indicating the file path because R will not supply it for you!
Q: How can I retrieve the work that I have saved using a save.image function?
The load function will load an .RData file.
load("d:/file_name.RData") load("C:/Program Files/R/R-2.6.2/SCCS/sccs.RData")
R remove file unlink("bad_file")
Editing the functions is extremely simple. To see a function (command) you type it's name without adding parentheses. To edit a function you type edit(function name). This opens up the local command line text editor. In my Linux version of R this defaults to vi. However it can be changed with the variable EDITOR. You can get the documentation on edit with help("edit"). Since functions are objects, as are data frames, you create a new version of a function by copying the result like this.
new_function <- edit(old_function)
The following command must be used to change a function, because edit does not alter its object.
function <- edit (function)
however there is a 'fix' command which is the equivalent of the above line
In reply to
On Wednesday 27 February 2008, you wrote: > I am going to try now to add some new commands to sccs.RData and also > update the .sav file. > > Could you give me a few commands that would > > extract the programs contained there.... get the > source(...) for each so I can see them, add to them, etc. > > thanks -- Doug