1

I know that this question has been asked previously, but none the answers given have solved my problem.

I keep getting the error message

"Error in unique.default(x, nmax = nmax) : unique() applies only to vectors" in RStudio when I'm trying to compute an ANOSIM.

I'm performing the ANOSIM on a datasheet that contains an Event ID tag, species % coverage data, UTM coordinates, and several data on heavy metal concentrations, salinity and pH. I've attached a sample shot of my data --> Data example

Here are some of the data (sorry for the code block, but it didn't align proplery any other way):

EventID P1  P2  H       N(%)    Cu(ug/g) Mn(ug/g)
T1P0S1  0   100 0       0.0098  12.8     73.1
T1P0S2  10  90  0.1412  0.0084  11.6     95
T1P0S3  5   95  0.0862  0.0042  24.8     138.5
T1P0S4  40  60  0.2923  0.007   28.3     126.8
T1P0S5  15  85  0.1836  0.0042  25.8     137.1
T1P50S1 100 0   0       0.0056  8.2      73.2
T1P50S2 0   100 0       0.0042  6        110.6
T1P50S3 40  60  0.2923  0.0056  0        99.7
T1P50S4 5   95  0.0862  0.0028  32.8     208.3
T1P50S5 55  45  0.2988  0.0042  15.5     140

This is my code:

library(vegan)
library(robustHD)

mydata <- read.csv2("C:/Users/cathr/OneDrive/Dokumenter/KU/Kandidat/Thesis/Stat/veg.csv", header = TRUE, sep= ";",dec = ".")
myData <- mydata[1:85,]
rownames(myData) <- myData$EventID
myData <- myData[,-1]
apply(myData, 1, sum)

mydata[1:47] <- lapply(mydata[1:47], as.numeric)

standardize(mydata, centerFun = mean, scaleFun = sd)

mydata.bc.dist <- vegdist(mydata, method = "bray")

anosim(mydata.bc.dist, grouping, permutations = 999, distance = "bray", strata = NULL, parallel = getOption("mc.cores"))`
NelsonGon
  • 13,015
  • 7
  • 27
  • 57
  • Please make your question [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – NelsonGon Sep 20 '19 at 11:17
  • 1
    Hi Nelson, does the above help? – Cathrine Hemmingsen Sep 20 '19 at 13:22
  • You need to specify a grouping column not just "grouping". Also this should come from a different dataset(mydata?) and not mydata.bc.dist since it should be a factor. – NelsonGon Sep 20 '19 at 13:39
  • I tried to reproduce this, but the first error message was `cannot open file 'C:/Users/cathr/OneDrive/Dokumenter/KU/Kandidat/Thesis/Stat/veg.csv': No such file or directory`. And really, I don't have anything starting with `C:` in my laptop. – Jari Oksanen Sep 20 '19 at 18:56
  • Nelson; Thank you, I didn't realize that, it solved my problem. Jari; C: is just my main drive, or the name of "My computer", it is just a working directory. – Cathrine Hemmingsen Sep 21 '19 at 10:37

0 Answers0