Problem finding missingness (wrangling data) using tidyverse. Getting Evaluation error.

Dear Rstudio Community,

I have a problem running my script in R...

I am using tidyverse and readxl.

The dataset (xl file) is a simple matrix containing expression values.
Some columns are missing some data, so i wish to determine if my data first of all do miss any data, so i can remove the columns afterwards.

For some reason it gives me a evalutaion error eventhough it loads the files fine..

Have anyone encountered a simular problem to mine?

 # Load libraries
> # ------------------------------------------------------------------------------
> library('tidyverse')
> library('readxl')
> 
> # Load data
> # ------------------------------------------------------------------------------
> f = 'C:/Users/Torsten/Desktop/Bachelor/data/_raw/data_file.xlsx'
> all_markers = read_excel(path = f, col_names = FALSE, sheet = 'all markers')
New names:
* `` -> `..1`
* `` -> `..2`
* `` -> `..3`
* `` -> `..4`
* `` -> `..5`
* ... and 83 more
> q_pcr = read_excel(path = f, col_names = FALSE, sheet = 'Q-PCR', skip = 1)
New names:
* `` -> `..1`
* `` -> `..2`
* `` -> `..3`
* `` -> `..4`
* `` -> `..5`
* ... and 28 more
> 
> # Wrangle data
> # ------------------------------------------------------------------------------
> 
> # Check missingness in variables
> all_markers %>% summarise_all(function(x){sum(is.na(x))}) %>%
+   select_if(function(x){ifelse(x>0,TRUE,FALSE)}) %>% print
Error in summarise_impl(.data, dots) : 
  Evaluation error: ..1 used in an incorrect context, no ... to look in.

If you're reading this into R using readxl::read_excel(), it will by default try to convert your object into a data frame (more specifically a tibble — you can tell what the return object will be by looking at the value in a function reference).

So, what's happening is that readxl is attempting name repair, and giving your columns names, rather than keeping it as a matrix:

You can read your sheet in from a csv and convert it to a matrix, or read it in as an Excel file and do the same. See this thread on Stack Overflow:

If you need further assistance, could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.

install.packages("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ.

Thank you for the responses.
It was very help full.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.