Re: [R-sig-eco] NA error in envfit
Kendra, Are you sure that it was a factor? I am unable to trigger an error with a one-level factor in vegan 2.0-9. Moreover, the error message you sent was from vectorfit and factors (also one-level factors) are not handled in that function but they go to factorfit, and error should come from factorfit. Character strings variable go to vectorfit (instead of factorfit) and gives exactly that error and from vectorfit. I don't ask these things out of my meanness, but I want to fix these functions for the next release. I have now found one problem and I have fixed that in R-Forge. If there are some other problems, I want to fix them, too. Therefore I really want to know what happened with your application. I try to reproduce your problems, but this is kind of blind watchmaker's works as I don't have a reproducible test case. Therefore I have to ask stubbornly. Cheers, Jari Oksanen On 06/12/2013, at 21:35 PM, Mitchell, Kendra wrote: > My offending variable was correctly imported as a factor, but since I was > subsetting the data to look only at one zone at a time it was a factor with > only one level > > > -- > Kendra Maas Mitchell, Ph.D. > Post Doctoral Research Fellow > University of British Columbia > 604-822-5646 > > > From: Gavin Simpson [ucfa...@gmail.com] > Sent: Friday, December 06, 2013 11:09 AM > To: Dixon, Philip M [STAT] > Cc: Mitchell, Kendra; r-sig-ecology@r-project.org > Subject: Re: [R-sig-eco] NA error in envfit > > Phillip, > > You approach to using factors misses an important consideration; the > class that was observed in the full dataset should not disappear just > because you subsetted the data in some manner. Also, `droplevels()` is > a useful function to call on a factor or data frame if subsetting > produces levels with zero observations and if that information is not > made use on in whatever computations follow next. > > G > > On 5 December 2013 10:42, Dixon, Philip M [STAT] wrote: >> Kendra, >> >> I wonder if the problem is a factor level with no observations. One of the >> frustrating things about factors (class variables) in R is that the list of >> levels is stored separately from the data. This can cause all sorts of >> problems if you create the factor, then subset the data, and the subset is >> missing one or more levels of the factor. You are subsetting your data, so >> this may be the source of the problem. >> >> My working philosophy is to keep variables as character strings or numbers >> until just before I need the factors. That avoids any issues with >> extraneous levels. That means reading data sets (.txt or .csv files) with >> as.is=TRUE to avoid default creation of factors. relevel() may recreate the >> list of levels. I usually use factor(as.character(variable)) to flip a >> factor to a vector of character strings then back to a factor with the >> correct set of levels. >> >> Best wishes, >> Philip Dixon >> >> >>[[alternative HTML version deleted]] >> >> ___ >> R-sig-ecology mailing list >> R-sig-ecology@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology > > > > -- > Gavin Simpson, PhD > > ___ > R-sig-ecology mailing list > R-sig-ecology@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
My offending variable was correctly imported as a factor, but since I was subsetting the data to look only at one zone at a time it was a factor with only one level -- Kendra Maas Mitchell, Ph.D. Post Doctoral Research Fellow University of British Columbia 604-822-5646 From: Gavin Simpson [ucfa...@gmail.com] Sent: Friday, December 06, 2013 11:09 AM To: Dixon, Philip M [STAT] Cc: Mitchell, Kendra; r-sig-ecology@r-project.org Subject: Re: [R-sig-eco] NA error in envfit Phillip, You approach to using factors misses an important consideration; the class that was observed in the full dataset should not disappear just because you subsetted the data in some manner. Also, `droplevels()` is a useful function to call on a factor or data frame if subsetting produces levels with zero observations and if that information is not made use on in whatever computations follow next. G On 5 December 2013 10:42, Dixon, Philip M [STAT] wrote: > Kendra, > > I wonder if the problem is a factor level with no observations. One of the > frustrating things about factors (class variables) in R is that the list of > levels is stored separately from the data. This can cause all sorts of > problems if you create the factor, then subset the data, and the subset is > missing one or more levels of the factor. You are subsetting your data, so > this may be the source of the problem. > > My working philosophy is to keep variables as character strings or numbers > until just before I need the factors. That avoids any issues with extraneous > levels. That means reading data sets (.txt or .csv files) with as.is=TRUE to > avoid default creation of factors. relevel() may recreate the list of > levels. I usually use factor(as.character(variable)) to flip a factor to a > vector of character strings then back to a factor with the correct set of > levels. > > Best wishes, > Philip Dixon > > > [[alternative HTML version deleted]] > > ___ > R-sig-ecology mailing list > R-sig-ecology@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology -- Gavin Simpson, PhD ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
Phillip, You approach to using factors misses an important consideration; the class that was observed in the full dataset should not disappear just because you subsetted the data in some manner. Also, `droplevels()` is a useful function to call on a factor or data frame if subsetting produces levels with zero observations and if that information is not made use on in whatever computations follow next. G On 5 December 2013 10:42, Dixon, Philip M [STAT] wrote: > Kendra, > > I wonder if the problem is a factor level with no observations. One of the > frustrating things about factors (class variables) in R is that the list of > levels is stored separately from the data. This can cause all sorts of > problems if you create the factor, then subset the data, and the subset is > missing one or more levels of the factor. You are subsetting your data, so > this may be the source of the problem. > > My working philosophy is to keep variables as character strings or numbers > until just before I need the factors. That avoids any issues with extraneous > levels. That means reading data sets (.txt or .csv files) with as.is=TRUE to > avoid default creation of factors. relevel() may recreate the list of > levels. I usually use factor(as.character(variable)) to flip a factor to a > vector of character strings then back to a factor with the correct set of > levels. > > Best wishes, > Philip Dixon > > > [[alternative HTML version deleted]] > > ___ > R-sig-ecology mailing list > R-sig-ecology@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology -- Gavin Simpson, PhD ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
On 05/12/2013, at 18:42 PM, Dixon, Philip M [STAT] wrote: > > I wonder if the problem is a factor level with no observations. One of the > frustrating things about factors (class variables) in R is that the list of > levels is stored separately from the data. This can cause all sorts of > problems if you create the factor, then subset the data, and the subset is > missing one or more levels of the factor. You are subsetting your data, so > this may be the source of the problem. > > My working philosophy is to keep variables as character strings or numbers > until just before I need the factors. That avoids any issues with extraneous > levels. That means reading data sets (.txt or .csv files) with as.is=TRUE to > avoid default creation of factors. relevel() may recreate the list of > levels. I usually use factor(as.character(variable)) to flip a factor to a > vector of character strings then back to a factor with the correct set of > levels. Philip, It very much look that this kind of approach is the source of all evil. We *assume* in envfit() that if a variable is not a factor, then it is numeric. If it is a character string instead being numeric, you get those strange error messages. We do take care of the extraneous factor levels in envfit, but we expected that variables are either factors or numeric -- we did not expect character strings. I guess we have to add some ugly code to handle these cases and either cast character strings to factors or ignore variables that are neither numeric nor factors. Cheers, Jari Oksanen ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
It's not that hard: * windows: just go to http://cran.r-project.org/bin/windows/Rtools/, then download and run the installer. * mac: download xcode from the app store and gfortran from http://cran.r-project.org/bin/macosx/tools/ * linux: you're on linux, you can figure it out yourself ;) Hadley On Thu, Dec 5, 2013 at 9:04 AM, Jari Oksanen wrote: > It is easy if you have C and Fortran compilers plus unix tools. I assume most > people do not have those. Then 'easy' is quite different a concept. > > Cheers, Jari Oksanen > alkuperäinen viesti > Lähettäjä: Hadley Wickham > Lähetetty: 05.12.2013, 16:19 > Vastaanottaja: Eduard Szöcs > Kopio: r-sig-ecology@r-project.org > Aihe: Re: [R-sig-eco] NA error in envfit > >> # install vegan from github >> install_github('vegan', 'jarioksa') > > BTW I recommend using this form: > > install_github('jarioksa/vegan') > > Hadley > > -- > http://had.co.nz/ > > ___ > R-sig-ecology mailing list > R-sig-ecology@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology -- http://had.co.nz/ ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
Thanks, makes sense to remove a variable that has no variation and it fixed the issue. And that is much easier than building and installing from source. -- Kendra Maas Mitchell, Ph.D. Post Doctoral Research Fellow University of British Columbia 604-822-5646 From: r-sig-ecology-boun...@r-project.org [r-sig-ecology-boun...@r-project.org] on behalf of Jari Oksanen [jari.oksa...@oulu.fi] Sent: Thursday, December 05, 2013 7:04 AM To: Eduard Szöcs; Hadley Wickham Cc: r-sig-ecology@r-project.org Subject: Re: [R-sig-eco] NA error in envfit It is easy if you have C and Fortran compilers plus unix tools. I assume most people do not have those. Then 'easy' is quite different a concept. Cheers, Jari Oksanen alkuperäinen viesti Lähettäjä: Hadley Wickham Lähetetty: 05.12.2013, 16:19 Vastaanottaja: Eduard Szöcs Kopio: r-sig-ecology@r-project.org Aihe: Re: [R-sig-eco] NA error in envfit > # install vegan from github > install_github('vegan', 'jarioksa') BTW I recommend using this form: install_github('jarioksa/vegan') Hadley -- http://had.co.nz/ ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
Thanks, I think it was the odd variable that was named "f.env$zone" I removed that column and suddenly things started working -- Kendra Maas Mitchell, Ph.D. Post Doctoral Research Fellow University of British Columbia 604-822-5646 From: Dixon, Philip M [STAT] [pdi...@iastate.edu] Sent: Thursday, December 05, 2013 8:42 AM To: Mitchell, Kendra Cc: r-sig-ecology@r-project.org Subject: NA error in envfit Kendra, I wonder if the problem is a factor level with no observations. One of the frustrating things about factors (class variables) in R is that the list of levels is stored separately from the data. This can cause all sorts of problems if you create the factor, then subset the data, and the subset is missing one or more levels of the factor. You are subsetting your data, so this may be the source of the problem. My working philosophy is to keep variables as character strings or numbers until just before I need the factors. That avoids any issues with extraneous levels. That means reading data sets (.txt or .csv files) with as.is=TRUE to avoid default creation of factors. relevel() may recreate the list of levels. I usually use factor(as.character(variable)) to flip a factor to a vector of character strings then back to a factor with the correct set of levels. Best wishes, Philip Dixon [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
[R-sig-eco] NA error in envfit
Kendra, I wonder if the problem is a factor level with no observations. One of the frustrating things about factors (class variables) in R is that the list of levels is stored separately from the data. This can cause all sorts of problems if you create the factor, then subset the data, and the subset is missing one or more levels of the factor. You are subsetting your data, so this may be the source of the problem. My working philosophy is to keep variables as character strings or numbers until just before I need the factors. That avoids any issues with extraneous levels. That means reading data sets (.txt or .csv files) with as.is=TRUE to avoid default creation of factors. relevel() may recreate the list of levels. I usually use factor(as.character(variable)) to flip a factor to a vector of character strings then back to a factor with the correct set of levels. Best wishes, Philip Dixon [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
It is easy if you have C and Fortran compilers plus unix tools. I assume most people do not have those. Then 'easy' is quite different a concept. Cheers, Jari Oksanen alkuperäinen viesti Lähettäjä: Hadley Wickham Lähetetty: 05.12.2013, 16:19 Vastaanottaja: Eduard Szöcs Kopio: r-sig-ecology@r-project.org Aihe: Re: [R-sig-eco] NA error in envfit > # install vegan from github > install_github('vegan', 'jarioksa') BTW I recommend using this form: install_github('jarioksa/vegan') Hadley -- http://had.co.nz/ ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
> # install vegan from github > install_github('vegan', 'jarioksa') BTW I recommend using this form: install_github('jarioksa/vegan') Hadley -- http://had.co.nz/ ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
Hai, building and installing from github is quite easy with the devtools package (thanks to Hadley!): # install devtools install.packages('devtools') require(devtools) # install vegan from github install_github('vegan', 'jarioksa') Cheers, Eduard Szöcs On 12/05/2013 02:07 PM, Jari Oksanen wrote: > Hello, > > I think I saw something like this in autumn (northern hemisphere) when a > variable had constant values with no variation, and envfit did not know how > to scale the arrow. > > We fixed this in the development version of vegan in R-Forge on September 29. > Unfortunately R-Forge is again dysfunctional and cannot build the package, > but if you are able to do that yourself you can try to see if the problem is > fixed there. The same files are also in github, but you need to build the > package yourself there too. I'm working with a minor release of vegan > (2.0-10) which may be published on Monday 9 Dec, but there are no guarantees > that it will have this envfit fix or be released like planned (you know, the > best laid plans of mice and men...) > > It may be easiest to see if a constant "variable" is the culprit, and remove > that if needed. If this is not the case, we need more info and a > *reproducible* example. We haven't got any now, and I cannot reproduce your > problem. > > Cheers, Jari Oksanen > > From: r-sig-ecology-boun...@r-project.org > [r-sig-ecology-boun...@r-project.org] on behalf of Stephen Sefick > [sas0...@auburn.edu] > Sent: 04 December 2013 22:01 > To: Mitchell, Kendra > Cc: r-sig-ecology@r-project.org > Subject: Re: [R-sig-eco] NA error in envfit > > Kendra, > > Something is wrong in X or P; find out what the foreign function call is > and then you may be able to track down the offending data problem. > Maybe a logarithm somewhere? This is probably not much help; I don't > have much experience with envfit. > > Stephen > > On 12/03/2013 07:06 PM, Mitchell, Kendra wrote: >> I'm running a bunch of NMS with vectors fitted (slicing and dicing a large >> dataset in different ways). I'm suddenly getting an error from envfit >> >> f.bSBS.org.fit<-envfit(f.bSBS.org.nms, f.bSBS.org.env, permutations=999, >> na.rm=TRUE) >> >> Error in vectorfit(X, P, permutations, strata, choices, w = w, ...) : >>NA/NaN/Inf in foreign function call (arg 1) >> In addition: Warning message: >> In vectorfit(X, P, permutations, strata, choices, w = w, ...) : >>NAs introduced by coercion >> >> I can plot the NMS and even run ordifit on individual env variables, so >> can't figure out what the problem is. There aren't any NA/NaN/Inf in >> either of those data that I can find. I've tried running it without >> na.rm=TRUE and still get the error. Guidance on how to fix this would be >> appreciated. >> >> Here's the whole slicing process and str for the data >> >> >> f.bSBS.org<-f.env$zone.hor=="bSBS.1" >> f.bSBS.org.tyc<-f.tyc[f.bSBS.org,f.bSBS.org] >> f.bSBS.org.env<-subset(f.env, f.env$zone.hor=="bSBS.1") >> f.bSBS.org.nms<-metaMDS(as.dist(f.bSBS.org.tyc), k=3, trymin=50, trymax=250, >> wascores=FALSE) >> f.bSBS.org.fit<-envfit(f.bSBS.org.nms, f.bSBS.org.env, permutations=999, >> na.rm=TRUE) >> >> >> str(f.bSBS.org.env) >> 'data.frame':63 obs. of 14 variables: >> $ zone : Factor w/ 6 levels "bIDF","bSBS",..: 2 2 2 2 2 2 2 2 2 2 >> ... >> $ site : Factor w/ 18 levels "A7","A8","A9",..: 12 12 12 12 12 12 >> 12 12 12 12 ... >> $ om : Factor w/ 4 levels "0","1","2","3": 2 2 2 3 3 3 2 2 2 3 >> ... >> $ compaction : num 1 1 1 1 1 1 1 1 1 1 ... >> $ herbicide: num 0 0 0 0 0 0 0 0 0 0 ... >> $ horizon : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ... >> $ Water_content: num 50.3 50.3 50.3 50.1 50.1 ... >> $ DNA_ug_g : num 71.2 71.2 71.2 68.6 68.6 ... >> $ C: num 30.5 30.5 30.5 28.4 28.4 ... >> $ N: num 0.863 0.863 0.863 0.81 0.81 ... >> $ pH_H2O : num 4.63 4.63 4.63 4.49 4.49 ... >> $ CN : num 35.3 35.3 35.3 35.1 35.1 ... >> $ f.env$zone : Factor w/ 6 levels "bIDF","bSBS",..: 2 2 2 2 2 2 2 2 2 2 >> ... >> $ zone.hor : chr "bSBS.1" "bSBS.1" "bSBS.1" "bSBS.1" ... >> >&
Re: [R-sig-eco] NA error in envfit
Hello, I think I saw something like this in autumn (northern hemisphere) when a variable had constant values with no variation, and envfit did not know how to scale the arrow. We fixed this in the development version of vegan in R-Forge on September 29. Unfortunately R-Forge is again dysfunctional and cannot build the package, but if you are able to do that yourself you can try to see if the problem is fixed there. The same files are also in github, but you need to build the package yourself there too. I'm working with a minor release of vegan (2.0-10) which may be published on Monday 9 Dec, but there are no guarantees that it will have this envfit fix or be released like planned (you know, the best laid plans of mice and men...) It may be easiest to see if a constant "variable" is the culprit, and remove that if needed. If this is not the case, we need more info and a *reproducible* example. We haven't got any now, and I cannot reproduce your problem. Cheers, Jari Oksanen From: r-sig-ecology-boun...@r-project.org [r-sig-ecology-boun...@r-project.org] on behalf of Stephen Sefick [sas0...@auburn.edu] Sent: 04 December 2013 22:01 To: Mitchell, Kendra Cc: r-sig-ecology@r-project.org Subject: Re: [R-sig-eco] NA error in envfit Kendra, Something is wrong in X or P; find out what the foreign function call is and then you may be able to track down the offending data problem. Maybe a logarithm somewhere? This is probably not much help; I don't have much experience with envfit. Stephen On 12/03/2013 07:06 PM, Mitchell, Kendra wrote: > I'm running a bunch of NMS with vectors fitted (slicing and dicing a large > dataset in different ways). I'm suddenly getting an error from envfit > > f.bSBS.org.fit<-envfit(f.bSBS.org.nms, f.bSBS.org.env, permutations=999, > na.rm=TRUE) > > Error in vectorfit(X, P, permutations, strata, choices, w = w, ...) : >NA/NaN/Inf in foreign function call (arg 1) > In addition: Warning message: > In vectorfit(X, P, permutations, strata, choices, w = w, ...) : >NAs introduced by coercion > > I can plot the NMS and even run ordifit on individual env variables, so can't > figure out what the problem is. There aren't any NA/NaN/Inf in either of > those data that I can find. I've tried running it without na.rm=TRUE and > still get the error. Guidance on how to fix this would be appreciated. > > Here's the whole slicing process and str for the data > > > f.bSBS.org<-f.env$zone.hor=="bSBS.1" > f.bSBS.org.tyc<-f.tyc[f.bSBS.org,f.bSBS.org] > f.bSBS.org.env<-subset(f.env, f.env$zone.hor=="bSBS.1") > f.bSBS.org.nms<-metaMDS(as.dist(f.bSBS.org.tyc), k=3, trymin=50, trymax=250, > wascores=FALSE) > f.bSBS.org.fit<-envfit(f.bSBS.org.nms, f.bSBS.org.env, permutations=999, > na.rm=TRUE) > > > str(f.bSBS.org.env) > 'data.frame':63 obs. of 14 variables: > $ zone : Factor w/ 6 levels "bIDF","bSBS",..: 2 2 2 2 2 2 2 2 2 2 > ... > $ site : Factor w/ 18 levels "A7","A8","A9",..: 12 12 12 12 12 12 > 12 12 12 12 ... > $ om : Factor w/ 4 levels "0","1","2","3": 2 2 2 3 3 3 2 2 2 3 ... > $ compaction : num 1 1 1 1 1 1 1 1 1 1 ... > $ herbicide: num 0 0 0 0 0 0 0 0 0 0 ... > $ horizon : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ... > $ Water_content: num 50.3 50.3 50.3 50.1 50.1 ... > $ DNA_ug_g : num 71.2 71.2 71.2 68.6 68.6 ... > $ C: num 30.5 30.5 30.5 28.4 28.4 ... > $ N: num 0.863 0.863 0.863 0.81 0.81 ... > $ pH_H2O : num 4.63 4.63 4.63 4.49 4.49 ... > $ CN : num 35.3 35.3 35.3 35.1 35.1 ... > $ f.env$zone : Factor w/ 6 levels "bIDF","bSBS",..: 2 2 2 2 2 2 2 2 2 2 > ... > $ zone.hor : chr "bSBS.1" "bSBS.1" "bSBS.1" "bSBS.1" ... > > str(f.bSBS.org.nms) > List of 35 > $ nobj : int 63 > $ nfix : int 0 > $ ndim : num 3 > $ ndis : int 1953 > $ ngrp : int 1 > $ diss : num [1:1953] 0.00424 0.00437 0.05169 0.07522 0.11039 ... > $ iidx : int [1:1953] 12 8 55 56 52 7 56 12 59 52 ... > $ jidx : int [1:1953] 7 6 18 55 8 3 18 3 12 49 ... > $ xinit : num [1:189] 0.654 0.837 0.438 0.105 -0.313 ... > $ istart: int 1 > $ isform: int 1 > $ ities : int 1 > $ iregn : int 1 > $ iscal : int 1 > $ maxits: int 200 > $ sratmx: num 1 > $ strmin: num 1e-04 > $ sfgrmn: num 1e-07 > $ dist : num [1:1953] 0.0679 0.0231 0
Re: [R-sig-eco] NA error in envfit
Kendra, Something is wrong in X or P; find out what the foreign function call is and then you may be able to track down the offending data problem. Maybe a logarithm somewhere? This is probably not much help; I don't have much experience with envfit. Stephen On 12/03/2013 07:06 PM, Mitchell, Kendra wrote: I'm running a bunch of NMS with vectors fitted (slicing and dicing a large dataset in different ways). I'm suddenly getting an error from envfit f.bSBS.org.fit<-envfit(f.bSBS.org.nms, f.bSBS.org.env, permutations=999, na.rm=TRUE) Error in vectorfit(X, P, permutations, strata, choices, w = w, ...) : NA/NaN/Inf in foreign function call (arg 1) In addition: Warning message: In vectorfit(X, P, permutations, strata, choices, w = w, ...) : NAs introduced by coercion I can plot the NMS and even run ordifit on individual env variables, so can't figure out what the problem is. There aren't any NA/NaN/Inf in either of those data that I can find. I've tried running it without na.rm=TRUE and still get the error. Guidance on how to fix this would be appreciated. Here's the whole slicing process and str for the data f.bSBS.org<-f.env$zone.hor=="bSBS.1" f.bSBS.org.tyc<-f.tyc[f.bSBS.org,f.bSBS.org] f.bSBS.org.env<-subset(f.env, f.env$zone.hor=="bSBS.1") f.bSBS.org.nms<-metaMDS(as.dist(f.bSBS.org.tyc), k=3, trymin=50, trymax=250, wascores=FALSE) f.bSBS.org.fit<-envfit(f.bSBS.org.nms, f.bSBS.org.env, permutations=999, na.rm=TRUE) str(f.bSBS.org.env) 'data.frame':63 obs. of 14 variables: $ zone : Factor w/ 6 levels "bIDF","bSBS",..: 2 2 2 2 2 2 2 2 2 2 ... $ site : Factor w/ 18 levels "A7","A8","A9",..: 12 12 12 12 12 12 12 12 12 12 ... $ om : Factor w/ 4 levels "0","1","2","3": 2 2 2 3 3 3 2 2 2 3 ... $ compaction : num 1 1 1 1 1 1 1 1 1 1 ... $ herbicide: num 0 0 0 0 0 0 0 0 0 0 ... $ horizon : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ... $ Water_content: num 50.3 50.3 50.3 50.1 50.1 ... $ DNA_ug_g : num 71.2 71.2 71.2 68.6 68.6 ... $ C: num 30.5 30.5 30.5 28.4 28.4 ... $ N: num 0.863 0.863 0.863 0.81 0.81 ... $ pH_H2O : num 4.63 4.63 4.63 4.49 4.49 ... $ CN : num 35.3 35.3 35.3 35.1 35.1 ... $ f.env$zone : Factor w/ 6 levels "bIDF","bSBS",..: 2 2 2 2 2 2 2 2 2 2 ... $ zone.hor : chr "bSBS.1" "bSBS.1" "bSBS.1" "bSBS.1" ... str(f.bSBS.org.nms) List of 35 $ nobj : int 63 $ nfix : int 0 $ ndim : num 3 $ ndis : int 1953 $ ngrp : int 1 $ diss : num [1:1953] 0.00424 0.00437 0.05169 0.07522 0.11039 ... $ iidx : int [1:1953] 12 8 55 56 52 7 56 12 59 52 ... $ jidx : int [1:1953] 7 6 18 55 8 3 18 3 12 49 ... $ xinit : num [1:189] 0.654 0.837 0.438 0.105 -0.313 ... $ istart: int 1 $ isform: int 1 $ ities : int 1 $ iregn : int 1 $ iscal : int 1 $ maxits: int 200 $ sratmx: num 1 $ strmin: num 1e-04 $ sfgrmn: num 1e-07 $ dist : num [1:1953] 0.0679 0.0231 0.3598 0.1248 0.1422 ... $ dhat : num [1:1953] 0.0455 0.0455 0.2076 0.2076 0.2076 ... $ points: num [1:63, 1:3] -0.1256 0.1224 0.267 0.2374 -0.0427 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : chr [1:63] "LL001" "LL002" "LL003" "LL007" ... .. ..$ : chr [1:3] "MDS1" "MDS2" "MDS3" ..- attr(*, "centre")= logi TRUE ..- attr(*, "pc")= logi TRUE ..- attr(*, "halfchange")= logi FALSE $ stress: num 0.157 $ grstress : num 0.157 $ iters : int 180 $ icause: int 3 $ call : language metaMDS(comm = as.dist(f.bSBS.org.tyc), k = 3, trymax = 250, wascores = FALSE, trymin = 50) $ model : chr "global" $ distmethod: chr "user supplied" $ distcall : chr "as.dist.default(m = f.bSBS.org.tyc)" $ distance : chr "user supplied" $ converged : logi TRUE $ tries : num 23 $ engine: chr "monoMDS" $ species : logi NA $ data : chr "as.dist(f.bSBS.org.tyc)" - attr(*, "class")= chr [1:2] "metaMDS" "monoMDS" -- Kendra Maas Mitchell, Ph.D. Post Doctoral Research Fellow University of British Columbia 604-822-5646 [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology -- Stephen Sefick ** Auburn University Biological Sciences 331 Funchess Hall Auburn, Alabama 36849 ** sas0...@auburn.edu http://www.auburn.edu/~sas0025 ** Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis "A big computer, a compl
[R-sig-eco] NA error in envfit
I'm running a bunch of NMS with vectors fitted (slicing and dicing a large dataset in different ways). I'm suddenly getting an error from envfit f.bSBS.org.fit<-envfit(f.bSBS.org.nms, f.bSBS.org.env, permutations=999, na.rm=TRUE) Error in vectorfit(X, P, permutations, strata, choices, w = w, ...) : NA/NaN/Inf in foreign function call (arg 1) In addition: Warning message: In vectorfit(X, P, permutations, strata, choices, w = w, ...) : NAs introduced by coercion I can plot the NMS and even run ordifit on individual env variables, so can't figure out what the problem is. There aren't any NA/NaN/Inf in either of those data that I can find. I've tried running it without na.rm=TRUE and still get the error. Guidance on how to fix this would be appreciated. Here's the whole slicing process and str for the data f.bSBS.org<-f.env$zone.hor=="bSBS.1" f.bSBS.org.tyc<-f.tyc[f.bSBS.org,f.bSBS.org] f.bSBS.org.env<-subset(f.env, f.env$zone.hor=="bSBS.1") f.bSBS.org.nms<-metaMDS(as.dist(f.bSBS.org.tyc), k=3, trymin=50, trymax=250, wascores=FALSE) f.bSBS.org.fit<-envfit(f.bSBS.org.nms, f.bSBS.org.env, permutations=999, na.rm=TRUE) str(f.bSBS.org.env) 'data.frame':63 obs. of 14 variables: $ zone : Factor w/ 6 levels "bIDF","bSBS",..: 2 2 2 2 2 2 2 2 2 2 ... $ site : Factor w/ 18 levels "A7","A8","A9",..: 12 12 12 12 12 12 12 12 12 12 ... $ om : Factor w/ 4 levels "0","1","2","3": 2 2 2 3 3 3 2 2 2 3 ... $ compaction : num 1 1 1 1 1 1 1 1 1 1 ... $ herbicide: num 0 0 0 0 0 0 0 0 0 0 ... $ horizon : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ... $ Water_content: num 50.3 50.3 50.3 50.1 50.1 ... $ DNA_ug_g : num 71.2 71.2 71.2 68.6 68.6 ... $ C: num 30.5 30.5 30.5 28.4 28.4 ... $ N: num 0.863 0.863 0.863 0.81 0.81 ... $ pH_H2O : num 4.63 4.63 4.63 4.49 4.49 ... $ CN : num 35.3 35.3 35.3 35.1 35.1 ... $ f.env$zone : Factor w/ 6 levels "bIDF","bSBS",..: 2 2 2 2 2 2 2 2 2 2 ... $ zone.hor : chr "bSBS.1" "bSBS.1" "bSBS.1" "bSBS.1" ... str(f.bSBS.org.nms) List of 35 $ nobj : int 63 $ nfix : int 0 $ ndim : num 3 $ ndis : int 1953 $ ngrp : int 1 $ diss : num [1:1953] 0.00424 0.00437 0.05169 0.07522 0.11039 ... $ iidx : int [1:1953] 12 8 55 56 52 7 56 12 59 52 ... $ jidx : int [1:1953] 7 6 18 55 8 3 18 3 12 49 ... $ xinit : num [1:189] 0.654 0.837 0.438 0.105 -0.313 ... $ istart: int 1 $ isform: int 1 $ ities : int 1 $ iregn : int 1 $ iscal : int 1 $ maxits: int 200 $ sratmx: num 1 $ strmin: num 1e-04 $ sfgrmn: num 1e-07 $ dist : num [1:1953] 0.0679 0.0231 0.3598 0.1248 0.1422 ... $ dhat : num [1:1953] 0.0455 0.0455 0.2076 0.2076 0.2076 ... $ points: num [1:63, 1:3] -0.1256 0.1224 0.267 0.2374 -0.0427 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : chr [1:63] "LL001" "LL002" "LL003" "LL007" ... .. ..$ : chr [1:3] "MDS1" "MDS2" "MDS3" ..- attr(*, "centre")= logi TRUE ..- attr(*, "pc")= logi TRUE ..- attr(*, "halfchange")= logi FALSE $ stress: num 0.157 $ grstress : num 0.157 $ iters : int 180 $ icause: int 3 $ call : language metaMDS(comm = as.dist(f.bSBS.org.tyc), k = 3, trymax = 250, wascores = FALSE, trymin = 50) $ model : chr "global" $ distmethod: chr "user supplied" $ distcall : chr "as.dist.default(m = f.bSBS.org.tyc)" $ distance : chr "user supplied" $ converged : logi TRUE $ tries : num 23 $ engine: chr "monoMDS" $ species : logi NA $ data : chr "as.dist(f.bSBS.org.tyc)" - attr(*, "class")= chr [1:2] "metaMDS" "monoMDS" -- Kendra Maas Mitchell, Ph.D. Post Doctoral Research Fellow University of British Columbia 604-822-5646 [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology