Skip to content

Data Science Tutorials

  • Home
  • R
  • Statistics
  • Course
  • Machine Learning
  • Guest Blog
  • Contact
  • About Us
  • Toggle search form
  • How to perform kruskal wallis test in r
    How to perform the Kruskal-Wallis test in R? R
  • How to Implement the Sklearn Predict Approach
    How to Implement the Sklearn Predict Approach? R
  • How to Add Superscripts and Subscripts to Plots in R?, The basic syntax for adding superscripts or subscripts to charts in R is as follows:
    How to Add Superscripts and Subscripts to Plots in R? R
  • Radar plot in R
    How to create Radar Plot in R-ggradar R
  • How to Join Data Frames for different column names in R
    How to Join Data Frames for different column names in R R
  • Checking Missing Values in R
    Checking Missing Values in R R
  • Error: Can't rename columns that don't exist
    Can’t rename columns that don’t exist R
  • best books about data analytics
    Best Books to Learn Statistics for Data Science Course
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 create a hexbins chart in R
    How to create a hexbin chart in R R
  • Algorithm Classifications in Machine Learning
    Algorithm Classifications in Machine Learning Machine Learning
  • How to change the column positions in R?
    How to change the column positions in R? R
  • What Is the Best Way to Filter by Date in R
    What Is the Best Way to Filter by Date in R? R
  • How to handle Imbalanced Data
    How to handle Imbalanced Data? R
  • How to create a heatmap in R
    How to create a heatmap 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
  • Top 7 Skills Required to Become a Data Scientist
  • Learn Hadoop for Data Science
  • How Do Online Criminals Acquire Sensitive Data
  • Top Reasons To Learn R in 2023
  • Linear Interpolation in R-approx

Check your inbox or spam folder to confirm your subscription.

 https://www.r-bloggers.com
  • Comparing group means in R
    One way ANOVA Example in R-Quick Guide R
  • How to create a heatmap in R
    How to create a heatmap in R R
  • Convert multiple columns into a single column
    Convert multiple columns into a single column-tidyr Part4 R
  • display the last value of each line in ggplot
    How to add labels at the end of each line in ggplot2? R
  • How to Replace String in Column in R
    How to Replace String in Column using R R
  • How to Group and Summarize Data in R
    How to Group and Summarize Data in R R
  • 5 Free Books to Learn Statistics For Data Science
    5 Free Books to Learn Statistics For Data Science Course
  • How to Add a title to ggplot2 Plots in R
    How to Add a caption to ggplot2 Plots in R? R

Copyright © 2023 Data Science Tutorials.

Powered by PressBook News WordPress theme