Error: could not find function "read_excel" using R on Mac

45,115

Solution 1

While you called the library, try and see if adding readxl::read_excel(path = "yourPath",sheet=1), or even remove the sheet reference. It will automatically take the first sheet.

Solution 2

Perhaps, when you moved the excel and R file to another folder, the pathway should be change either. Try change the pathway, or replace the pathay by file.choose() and search the excel file manually. You called the package "xlsx", which can do the thing what you need. Maybe you're typing it wrong.

Dataset <- read.xlsx("Example.xlsx",sheetName="testing")

or

Dataset <- read.xlsx("Example.xlsx",sheetIndex="number of the excel sheet")

I hope it helps.

Solution 3

Try activating library(tidyverse) and library(readr) then use the read_excel().This should work.

Share:
45,115
user8760612
Author by

user8760612

Updated on July 09, 2022

Comments

  • user8760612
    user8760612 almost 2 years

    I am trying to link up my excel data set to R for statistical analysis. I am running on OSX Sierra (10.12.6) with R studio (1.0.153) and Java 8 (update 144).

    The function "read_excel" was able to open my excel document a week ago. When I moved the excel and the R document together to another folder, it no longer worked. Reloading the libraries has had no effect. After multiple attempts (and restarting R studio and computer), something finally worked but function "lmer" was no longer found. After reloading library "lme4", "read_excel" no longer worked!

    I have also tried using "read.xlsx" and "readWorksheet(loadWorkbook(...))", which didn't work. "read.csv" also did not work properly since the commas were creating disorganized columns and I am dealing with a larger excel workbook with ongoing changes.

    Reading on Stack, question Importing .xlsx file into R has not resolved my issue! Please help!

    Libraries loaded:

    library(multcomp)
    library(nlme)
    library(XLConnect)
    library(XLConnectJars)
    library(lme4)
    library(car)
    library(rJava)
    library(xlsx)
    library(readxl)
    

    R data file:

    Dataset <- read_excel("Example.xlsx",sheet="testing")
    #alternative line: Dataset <- read.xlsx("~/Desktop/My Stuff/Sample/Example.xlsx", sheet=7)
    
    Dataset$AAA <- as.factor(Dataset$AAA)
    Dataset$BBB <- as.factor(Dataset$BBB)
    Dataset$CCC <- as.numeric(Dataset$CCC)
    Dataset$DDD <- as.numeric(Dataset$DDD)
    
    Dataset_lme = lmer(CCC ~ AAA + BBB + (1|DDD), data=Dataset)
    
  • user8760612
    user8760612 over 6 years
    Thanks Carl! This allowed the script to run past the first line! What you've added, is this just a way to specify what library to look for the function? It still doesn't run past the "lmer" function in the script (error = not finding the function).
  • sɐunıɔןɐqɐp
    sɐunıɔןɐqɐp about 4 years
    From Review: Hi, this post does not seem to provide a quality answer to the question. Please either edit your answer and improve it, or just post it as a comment to the question/other answer.