[R-sig-eco] NMDS vegan

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Oct 26 20:44:59 CEST 2010


On Tue, 2010-10-26 at 14:30 -0400, Soumi Ray wrote:
> Hi all,
> It worked when I replaced the blanks (missing) in my spreadsheet as NA and
> saved it as csv.

I really, really doubt that. A blank is the same as an NA as far as
read.csv() and read.table are concerned. With this in a csv file named
"foo.csv":

"Site","Var1","Var2","Var3"
"A",1,2,1
"B",2,3,2
"C",3,"NA",3
"D",4,3,4
"E",5,4,5
"F",,4,6
"G",6,5,7
"H",7,67,
"I",8,7,"NA"
"J",9,8,3
"K",10,1,4
"L",11,9,5

When read into R, the two blanks *and* the two "NA" strings are all
converted to NA (missing) within R:

> read.csv("foo.csv")
   Site Var1 Var2 Var3
1     A    1    2    1
2     B    2    3    2
3     C    3   NA    3
4     D    4    3    4
5     E    5    4    5
6     F   NA    4    6
7     G    6    5    7
8     H    7   67   NA
9     I    8    7   NA
10    J    9    8    3
11    K   10    1    4
12    L   11    9    5
> str(read.csv("foo.csv"))
'data.frame':	12 obs. of  4 variables:
 $ Site: Factor w/ 12 levels "A","B","C","D",..: 1 2 3 4 5 6 7 8 9
10 ...
 $ Var1: int  1 2 3 4 5 NA 6 7 8 9 ...
 $ Var2: int  2 3 NA 3 4 4 5 67 7 8 ...
 $ Var3: int  1 2 3 4 5 6 7 NA NA 3 ...

> Stephen, my data is in excel spreadsheet, I have no clue how to replace all
> the blank cells in the huge dataset as NA.

You don't need to. Blank is fine. As Jari pointed out, your problems
were due to other things. That these sorted themselves out whilst you
fiddled with your data, does not mean the fiddling worked ;-)

HTH

G

> Thank for the help.
> 
> Soumi
> 
> On Mon, Oct 25, 2010 at 2:10 PM, Soumi Ray <soumiray74 at gmail.com> wrote:
> 
> > Hi listers,
> >
> > I am trying to run NMDS in vegan package. I have a species dataset - with
> > columns as species and rows as variables. All my data are 0/1
> > (presence/absence). My data has missing values. I saved my data in txt file
> > and the missing values are blank spaces. I am using the syntax:
> > <nmds <-read.table ('nmds.txt', header=T, rows.names=1, sep="\t")
> > <nmds.mds.alt <- metaMDS (nmds, distance="bray", k=2, autotransform=FALSE)
> >
> > But it is showing me the error:
> > Error in distfun(comm, method = distance, ...) :
> >   NA/NaN/Inf in foreign function call (arg 1)
> > In addition: Warning message:
> > In distfun(comm, method = distance, ...) :
> >   you have empty rows: their dissimilarities may be meaningless in method
> > bray
> >
> > Could anyone kindly let me know where am I going wrong? I admit i am new to
> > R, trying to self tutor myself.
> >
> > Thank you,
> >
> > Regards,
> >
> > Soumi
> >
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-sig-ecology mailing list