[R-meta] Dataframe is character
P. Roberto Bakker
robertobakker at gmail.com
Sat Nov 18 09:17:59 CET 2017
Thank you for you advice.
'readxl' is a nice package which reads the excel correctly. The problem was
that I should not use class("dat") but class(dat); and not class("yi") nor
class(yi) but class(dat$yi).
2017-11-17 12:37 GMT+01:00 Ken Beath <ken at kjbeath.com.au>:
> More correctly you believe that your Excel file is all numeric and it
> obviously isn’t. Reading Excell files can be a bit nasty because it is easy
> in the process of editing to have cells that are formatted as text. This
> can even be rows after teh data.
>
> You have 2 choices. Either fix the Excel file by deleting any extra rows
> and making sure everything is formatted as numeric or save it as a csv and
> then use read.csv. I’ve found the second option much more reliable.
>
> Ken
>
> > On 17 Nov 2017, at 9:14 pm, P. Roberto Bakker <robertobakker at gmail.com>
> wrote:
> >
> > I resend my mail as I was not member of this list - now I am.
> > Roberto
> >
> > ---------- Forwarded message ----------
> > From: P. Roberto Bakker <robertobakker at gmail.com>
> > Date: 2017-11-17 10:41 GMT+01:00
> > Subject: Dataframe is character
> > To: r-help at r-project.org
> >
> >
> >
> > 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-sig-meta-analysis mailing list
> > R-sig-meta-analysis at r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
> >
>
>
[[alternative HTML version deleted]]
More information about the R-sig-meta-analysis
mailing list