Skip to content

Data Science Tutorials

  • Home
  • R
  • Statistics
  • Course
  • Machine Learning
  • Guest Blog
  • Contact
  • About Us
  • Toggle search form
  • Random Forest Machine Learning
    Random Forest Machine Learning Introduction R
  • How to test the significance of a mediation effect
    How to test the significance of a mediation effect R
  • The Multinomial Distribution in R
    The Multinomial Distribution in R R
  • Load Multiple Packages in R
    Load Multiple Packages in R R
  • How to change the column positions in R?
    How to change the column positions in R? R
  • Control Chart in Quality Control
    Control Chart in Quality Control-Quick Guide Statistics
  • How to Get a Job as a Data Engineer
    How to Get a Job as a Data Engineer? R
  • How do augmented analytics work
    How do augmented analytics work? 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 Jim No Comments on Error in sum(List) : invalid ‘type’ (list) of argument
Tweet
Share
Share
Pin

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.

Tweet
Share
Share
Pin
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 use image function in R
    How to use the image function in R R
  • Calculate the P-Value from Chi-Square Statistic in R
    Calculate the P-Value from Chi-Square Statistic in R R
  • Convert multiple columns into a single column
    Convert multiple columns into a single column-tidyr Part4 R
  • Check whether any values of a logical vector are TRUE
    Check whether any values of a logical vector are TRUE R
  • glm function in R
    glm function in r-Generalized Linear Models R
  • Extract patterns in R
    Extract patterns in R? R

Leave a Reply Cancel reply

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

  • About Us
  • Contact
  • Disclaimer
  • Guest Blog
  • Privacy Policy
  • YouTube
  • Twitter
  • Facebook
  • Tips for Data Scientist Interview Openings
  • What is Epoch in Machine Learning?
  • Dynamic data visualizations in R
  • How Do Machine Learning Chatbots Work
  • Convex optimization role in machine learning

Check your inbox or spam folder to confirm your subscription.

  • Sampling from the population in R
  • Two of the Best Online Data Science Courses for 2023
  • Process of Machine Learning Optimisation?
  • ggplot2 scale in R (grammar for graphics)
  • ggplot aesthetics in R (Grammer of graphics)
  • How to do Pairwise Comparisons in R?
    How to do Pairwise Comparisons in R? R
  • Interactive 3d plot in R
    Interactive 3d plot in R-Quick Guide R
  • Tips for Data Scientist Interview Openings
    Tips for Data Scientist Interview Openings Course
  • How to Get a Job as a Data Engineer
    How to Get a Job as a Data Engineer? R
  • Arrange the rows in a specific sequence in R
    Arrange the rows in a specific sequence in R R
  • Credit Card Fraud detection in R
    Credit Card Fraud Detection in R R
  • Beginner's Guide to Data Science
    Beginner’s Guide to Data Science Machine Learning
  • rejection region in hypothesis testing
    Rejection Region in Hypothesis Testing Statistics

Copyright © 2023 Data Science Tutorials.

Powered by PressBook News WordPress theme