Hi everybody, Question: why are my dataframe and numeric variables a character? I read an excel file via readxl but my dataframe is a character, and numeric variables, eg "yi", are also a character. My excelfile is in English numeric Sometimes the dataframe was indeed a dataframe, but I do not know why it did sometimes. Thank you in advance, Roberto PS I used "guess". The problem is not solve by using "text", "numeric" etc My syntax (I think I cannot send the excel file as binary?)> library(readxl) > library(readxl) > library(metafor) > setwd("C:/docs/Work2/Statistic_Analyses/MetaQTcAD") > getwd()[1] "C:/docs/Work2/Statistic_Analyses/MetaQTcAD">> dat <- read_excel("Hedges-g_QTc MA_R05.xlsx", sheet = 2, col_names=TRUE,col_types = c("guess"))> class("dat")[1] "character"> class("yi")[1] "character">[[alternative HTML version deleted]]
class("dat") is different from class(dat), which is what you actually want. On 17-11-17, P. Roberto Bakker wrote:> Hi everybody, > > Question: why are my dataframe and numeric variables a character? > > I read an excel file via readxl but my dataframe is a character, and > numeric variables, eg "yi", are also a character. > My excelfile is in English numeric > Sometimes the dataframe was indeed a dataframe, but I do not know why it > did sometimes. > Thank you in advance, Roberto > PS I used "guess". The problem is not solve by using "text", "numeric" etc > > My syntax (I think I cannot send the excel file as binary?) > > > library(readxl) > > library(readxl) > > library(metafor) > > setwd("C:/docs/Work2/Statistic_Analyses/MetaQTcAD") > > getwd() > [1] "C:/docs/Work2/Statistic_Analyses/MetaQTcAD" > > > > > dat <- read_excel("Hedges-g_QTc MA_R05.xlsx", sheet = 2, col_names=TRUE, > col_types = c("guess")) > > class("dat") > [1] "character" > > class("yi") > [1] "character" > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.
Hi Roberto, This often happens when there are some non-numeric characters. You would have to check it. Without more information, e.g. dput(dat), you will have to find by yourself. HTH, Ivan -- Dr. Ivan Calandra TraCEr, laboratory for Traceology and Controlled Experiments MONREPOS Archaeological Research Centre and Museum for Human Behavioural Evolution Schloss Monrepos 56567 Neuwied, Germany +49 (0) 2631 9772-243 https://www.researchgate.net/profile/Ivan_Calandra On 17/11/2017 10:41, P. Roberto Bakker wrote:> Hi everybody, > > Question: why are my dataframe and numeric variables a character? > > I read an excel file via readxl but my dataframe is a character, and > numeric variables, eg "yi", are also a character. > My excelfile is in English numeric > Sometimes the dataframe was indeed a dataframe, but I do not know why it > did sometimes. > Thank you in advance, Roberto > PS I used "guess". The problem is not solve by using "text", "numeric" etc > > My syntax (I think I cannot send the excel file as binary?) > >> library(readxl) >> library(readxl) >> library(metafor) >> setwd("C:/docs/Work2/Statistic_Analyses/MetaQTcAD") >> getwd() > [1] "C:/docs/Work2/Statistic_Analyses/MetaQTcAD" >> dat <- read_excel("Hedges-g_QTc MA_R05.xlsx", sheet = 2, col_names=TRUE, > col_types = c("guess")) >> class("dat") > [1] "character" >> class("yi") > [1] "character" > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >
Good one, did not even notice that...! -- Dr. Ivan Calandra TraCEr, laboratory for Traceology and Controlled Experiments MONREPOS Archaeological Research Centre and Museum for Human Behavioural Evolution Schloss Monrepos 56567 Neuwied, Germany +49 (0) 2631 9772-243 https://www.researchgate.net/profile/Ivan_Calandra On 17/11/2017 11:02, Petra Oleum wrote:> class("dat") is different from class(dat), which is what you actually want. > > On 17-11-17, P. Roberto Bakker wrote: >> Hi everybody, >> >> Question: why are my dataframe and numeric variables a character? >> >> I read an excel file via readxl but my dataframe is a character, and >> numeric variables, eg "yi", are also a character. >> My excelfile is in English numeric >> Sometimes the dataframe was indeed a dataframe, but I do not know why it >> did sometimes. >> Thank you in advance, Roberto >> PS I used "guess". The problem is not solve by using "text", "numeric" etc >> >> My syntax (I think I cannot send the excel file as binary?) >> >>> library(readxl) >>> library(readxl) >>> library(metafor) >>> setwd("C:/docs/Work2/Statistic_Analyses/MetaQTcAD") >>> getwd() >> [1] "C:/docs/Work2/Statistic_Analyses/MetaQTcAD" >>> dat <- read_excel("Hedges-g_QTc MA_R05.xlsx", sheet = 2, col_names=TRUE, >> col_types = c("guess")) >>> class("dat") >> [1] "character" >>> class("yi") >> [1] "character" >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at 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 at 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. >