Hi see in line
> -----Original Message----- > From: R-help <r-help-boun...@r-project.org> On Behalf Of N Meriam > Sent: Tuesday, January 8, 2019 3:08 PM > To: r-help@r-project.org > Subject: [R] Warning message: NAs introduced by coercion > > Dear all, > > I have a .csv file called df4. (15752 obs. of 264 variables). > I apply this code but couldn't continue further other analyses, a warning > message keeps coming up. Then, I want to determine max and min > similarity values, > heat map plot, cluster...etc > > > require(SNPRelate) > > library(gdsfmt) > > myd <- read.csv(file = "df4.csv", header = TRUE) > > names(myd)[-1] > myd[,1] > > myd[1:10, 1:10] > # the data must be 0,1,2 with 3 as missing so you have r > > sample.id <- names(myd)[-1] > > snp.id <- myd[,1] > > snp.position <- 1:length(snp.id) # not needed for ibs > > snp.chromosome <- rep(1, each=length(snp.id)) # not needed for ibs > > snp.allele <- rep("A/G", length(snp.id)) # not needed for ibs > # genotype data must have - in 3 > > genod <- myd[,-1] > > genod[is.na(genod)] <- 3 > > genod[genod=="0"] <- 0 > > genod[genod=="1"] <- 2 > > genod[1:10,1:10] > > genod <- as.matrix(genod) matrix can have only one type of data so you probaly changed it to character by such construction. > > class(genod) <- "numeric" This tries to change all "numeric" values to numbers but if it cannot it sets it to NA. something like > head(iris) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1 1.5 0.2 setosa 5 5.0 3.6 1.4 0.2 setosa 6 5.4 3.9 1.7 0.4 setosa > ir <-head(iris) > irm <- as.matrix(ir) > head(irm) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 "5.1" "3.5" "1.4" "0.2" "setosa" 2 "4.9" "3.0" "1.4" "0.2" "setosa" 3 "4.7" "3.2" "1.3" "0.2" "setosa" 4 "4.6" "3.1" "1.5" "0.2" "setosa" 5 "5.0" "3.6" "1.4" "0.2" "setosa" 6 "5.4" "3.9" "1.7" "0.4" "setosa" > class(irm) <- "numeric" Warning message: In class(irm) <- "numeric" : NAs introduced by coercion > head(irm) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 NA 2 4.9 3.0 1.4 0.2 NA 3 4.7 3.2 1.3 0.2 NA 4 4.6 3.1 1.5 0.2 NA 5 5.0 3.6 1.4 0.2 NA 6 5.4 3.9 1.7 0.4 NA > Cheers Petr > > > *Warning message:In class(genod) <- "numeric" : NAs introduced by coercion* > > Maybe I could illustrate more with details so I can be more specific? > Please, let me know. > > I would appreciate your help. > Thanks, > Meriam > > [[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. Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about processing and protection of business partner’s personal data are available on website: https://www.precheza.cz/en/personal-data-protection-principles/ Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/ ______________________________________________ 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.