0

I´m trying to do redundancy analysis (RDA) on my data in R. The data frame I´m using was uploaded as a Microsoft Excel csv file. The data frame looks something like this:

site biomass index

1     0.001 1.5

2    0.122  2.3

3    0.255  4.9

When trying to create a formula for the RDA, I constantly get the following message: "Error in formula.data.frame(object, env = baseenv()) : cannot create a formula from a zero-column data frame"

Does anyone know how I can change my data frame so that I no longer get this error message?

Thanks in advance!

SabDeM
  • 6,858
  • 2
  • 24
  • 38

2 Answers2

0

You load all your data to row.names instead of columns

  1. you used default separator ',' while your data is separated by ';'
  2. you specified row.names = 1 so that first column (and the only one as the separator is wrong) goes to row.names.

that's why your data.frame has no columns. To fix this, use

read.csv('data.csv', sep = ';', row.names=NULL)
RInatM
  • 1,178
  • 1
  • 15
  • 39
0

Problem solved :) Thanks for the your answers. I tried the suggestions but what ended up working was to import the data with the <- read.csv2("data.csv", row.names=1), so basically to use read.csv2 instead of read.csv, as it seems to be used in many European locales.

There is more info on the difference between csv and csv2 here: Difference between read.csv() and read.csv2() in R

Community
  • 1
  • 1