I think that Goran is right, I didn't take "cor(data)" literally.
Jim On Thu, Jul 6, 2017 at 3:38 AM, Göran Broström <goran.brost...@umu.se> wrote: > On 2017-07-05 11:56, Jim Lemon wrote: >> >> Hi Chin Yi, >> If you are trying to correlate "Health" with "Disease", i.e. >> >> cydf<-read.table(text="OTU ID Health Disease >> Bacterial 1 0.29 0.34 >> Bacterial 2 0.25 0.07 >> Bacterial 3 0.06 0.06 >> Bacterial 4 0.07 0.09 >> Bacterial 5 0.02 0.05", >> header=TRUE) >> print(cor(cydf$Health,cydf$Disease)) >> [1] 0.7103517 >> >> If you are getting that error, it probably means that either "Health" >> or "Disease" or perhaps both have been read in as a factor. To test >> this: >> >> is.factor(cydf$Health) >> [1] FALSE >>> >>> is.factor(cydf$Disease) >> >> [1] FALSE >> >> If either of these returns TRUE, that is almost certainly the problem. > > > Or maybe Chin Yi tried (as it seems) > >> cor(cydf) > Error in cor(cydf) : 'x' must be numeric > > (with cydf == data): 'OTU' is not numeric. > > Follow Jim's advice. > > Göran > > >> >> Jim >> >> >> On Wed, Jul 5, 2017 at 11:27 AM, SEB140004 Student >> <chi...@siswa.um.edu.my> wrote: >>> >>> Greeting. >>> >>> Dear Mr/Mrs/Miss, >>> >>> OTU ID Health Disease >>> Bacterial 1 0.29 0.34 >>> Bacterial 2 0.25 0.07 >>> Bacterial 3 0.06 0.06 >>> Bacterial 4 0.07 0.09 >>> Bacterial 5 0.02 0.05 >>> Above show the first 6 data sets, may I ask that the reason of R show the >>> error like "Error in cor(data) : 'x' must be numeric" ? And how to solve >>> it? Besides, isn't this data can conduct correlation matrix? >>> >>> Moreover, isn't this data sets can be plot into network? If can, which >>> package should I use? >>> >>> Thank you. >>> >>> Best regards, >>> Kang Chin Yi >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >> >> >> ______________________________________________ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.