How can I differentiate between lapply and sapply ?

0 votes
Jun 11, 2018 in Data Analytics by shams
• 3,580 points
75 views

1 answer to this question.

0 votes
  • If the programmers want the output to be a data frame or a vector, then sapply function is used whereas if a programmer wants the output to be a list then lapply is used. 
  • There is one more function known as vapply which is preferred over sapply, as vapply allows the programmer to specify the output type. 
  • The disadvantage of using vapply is that it is difficult to be implemented and more verbose.
answered Jun 11, 2018 by zombie
• 3,690 points

Related Questions In Data Analytics

0 votes
1 answer

How can I change font size and direction of axes text in ggplot2 ?

You can try theme(): Library(ggplot2) a <- data.frame(x=gl(10, 1, ...READ MORE

answered May 30, 2018 in Data Analytics by zombie
• 3,690 points
187 views
0 votes
1 answer
0 votes
1 answer

How can I use parallel so that it preserves the list of data frames

You can use pmap as follows: nc <- ...READ MORE

answered Apr 4, 2018 in Data Analytics by kappa3010
• 2,010 points
24 views
0 votes
1 answer

How can I drop columns by name in a data frame ?

We can Drop Columns by name in ...READ MORE

answered Apr 13, 2018 in Data Analytics by zombie
• 3,690 points
29 views
0 votes
1 answer

Which function can I use to clear the console in R and RStudio ?

Description                   Windows & Linux           Mac Clear console                      Ctrl+L ...READ MORE

answered Apr 17, 2018 in Data Analytics by anonymous
933 views
0 votes
1 answer

How can I measuring running time of R Code ?

5 ways to measure running time of ...READ MORE

answered Apr 17, 2018 in Data Analytics by anonymous
94 views
0 votes
1 answer

How can we trim leading and trailing whitespaces in R?

trimws {base} //Remove Leading/Trailing Whitespace Removes leading and/or ...READ MORE

answered Apr 18, 2018 in Data Analytics by zombie
• 3,690 points
359 views
0 votes
1 answer

How can I import multiple .csv files into R ?

## import_multiple_csv_files_to_R # Purpose: Import multiple csv files ...READ MORE

answered Apr 19, 2018 in Data Analytics by zombie
• 3,690 points
367 views
0 votes
1 answer

How can I print string and variable contents on the same line using R?

There are two options for doing so.  You ...READ MORE

answered May 9, 2018 in Data Analytics by zombie
• 3,690 points
23 views
0 votes
1 answer

How can I add x and y axis labels in ggplot2 ?

# Load a dataset(to work with) # We’ll ...READ MORE

answered May 16, 2018 in Data Analytics by zombie
• 3,690 points
88 views