Skip to content

Data Science Tutorials

For Data Science Learners

  • How to convert characters from upper to lower case in R
    How to convert characters from upper to lower case in R? R
  • Defensive Programming Strategies in R
    Defensive Programming Strategies in R Machine Learning
  • How to perform kruskal wallis test in r
    How to perform the Kruskal-Wallis test in R? R
  • Fisher’s exact test in R
    Fisher’s exact test in R R
  • How to Rank by Group in R?
    How to Rank by Group in R? R
  • Steps to Mastering Natural Language Processing
    Steps to Mastering Natural Language Processing Machine Learning
  • Extract columns of data frame in R R
  • How to test the significance of a mediation effect
    How to test the significance of a mediation effect R
Error in sum(List) : invalid 'type' (list) of argument

Error in sum(List) : invalid ‘type’ (list) of argument

Posted on May 21May 21 By Admin No Comments on Error in sum(List) : invalid ‘type’ (list) of argument

Error in sum(List) : invalid ‘type’ (list) of argument, You’ll learn how to fix the “Error in FUN: invalid ‘type’ (list) of argument” in this R lesson.

Example Data Creation

The following list will serve as the foundation for this R tutorial.

Checking Missing Values in R – Data Science Tutorials

List <- list(1:10,    15, 100)
List
[[1]]
 [1]  1  2  3  4  5  6  7  8  9 10
[[2]]
[1] 15
[[3]]
[1] 100

The structure of our example data is seen in the previous RStudio console output — There are three list elements in this list object. There are numeric values in each of these list components.

Example 1: Reproduce the Error in sum(List) : invalid ‘type’ (list) of argument

The ” Error in sum(List) : invalid ‘type’ (list) of argument” can be replicated using the R code below.

Assume we wish to calculate the total of all elements in our data. Then, as seen in the following R code, we may use the sum function:

sum(List)                     
Error in sum(List) : invalid 'type' (list) of argument

Example 2: Fix the Error in sum(List) : invalid ‘type’ (list) of argument

The “Error in FUN: invalid ‘type’ (list) of argument” is demonstrated in this example.

To do so, we must first use the unlist function to transform our list into a vector object.

listvec <- unlist(List)
listvec
1   2   3   4   5   6   7   8   9  10  15 100

The structure of our modified data is shown in the preceding output. We’ve built a vector that contains all of the input list’s elements.

How to draw heatmap in r: Quick and Easy way – Data Science Tutorials

We can now use the sum function for our newly modified data.

sum(listvec)
170

The sum function provides the correct result without any issues this time.

R Tags:errors

Post navigation

Previous Post: Sorting in r: sort, order & rank R Functions
Next Post: Artificial Intelligence Examples-Quick View

Related Posts

  • How to add columns to a data frame in R
    How to add columns to a data frame in R R
  • Detecting and Dealing with Outliers
    Detecting and Dealing with Outliers: First Step R
  • Convert Multiple Columns to Numeric in R
    Convert Multiple Columns to Numeric in R R
  •  Identify positions in R R
  • Calculate the p-Value from Z-Score in R
    Calculate the p-Value from Z-Score in R R
  • How to apply a transformation to multiple columns in R?
    How to apply a transformation to multiple columns in R? R

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Best Prompt Engineering Books
  • Understanding Machine Learning and Data Science
  • Best Git Books
  • Top 5 Books to Learn Data Engineering
  • Mastering R Programming for Data Science: Tips and Tricks
  • About Us
  • Contact
  • Disclaimer
  • Privacy Policy

https://www.r-bloggers.com

  • YouTube
  • Twitter
  • Facebook
  • Course
  • Excel
  • Machine Learning
  • Opensesame
  • R
  • Statistics

Check your inbox or spam folder to confirm your subscription.

  • How to Compare Two Lists in Excel Using VLOOKUP
    How to Compare Two Lists in Excel Using VLOOKUP Excel
  • Crosstab calculation in R
    Crosstab calculation in R R
  • Get the first value in each group in R
    Get the first value in each group in R? R
  • Defensive Programming Strategies in R
    Defensive Programming Strategies in R Machine Learning
  • Difference between R and Python
    Difference between R and Python R
  • Error in rbind(deparse.level ...) numbers of columns of arguments do not match
    Error in rbind(deparse.level …) numbers of columns of arguments do not match R
  • Select variables of data frame in R R
  • How to Find Quartiles in R
    How to Find Quartiles in R? R

Privacy Policy

Copyright © 2025 Data Science Tutorials.

Powered by PressBook News WordPress theme