Search code examples
excelrload-data-infile

Making .RData file from Excel sheet


How can I save data from an Excel sheet to .RData file in R? I want to use one of the packages in R and to load my dataset as data(dataset) i think i have to save the data as .RData file and then load that into the package. My data currently is in an Excel spreadsheet.

my excel sheets has column names like x, y , time.lag. I have saved it as .csv then i use: x=read.csv('filepath', header=T,) then i say data(x) and it shows dataset 'x' not found


Solution

  • save your Excel data as a .csv file and import it using read.csv() or read.table(). Help on each will explain the options.

    For example, you have a file called myFile.xls, save it as myFile.csv.

    library(BBMM)
    
    # load an example dataset from BBMM
    data(locations)
    
    
    # from the BBMM help file
    BBMM <- brownian.bridge(x=locations$x, y=locations$y, time.lag=locations$time.lag[-1], location.error=20,  cell.size=50)
    bbmm.summary(BBMM)
    
    # output of summary(BBMM)
    Brownian motion variance :  3003.392
    Size of grid :  138552 cells
    Grid cell size :  50
    
    
    # subsitute locations for myData for your dataset that you have read form a myFile.csv file
    myData <- read.csv(file='myFile.csv', header=TRUE)
    
    head(myData) # will show the first 5 entries in you imported data
    
    # use whatever you need from the BBMM package now ....