What is lapply() function in R?

Question

With example

in progress 0
Xtramous 4 weeks 1 Answer 56 views Newbie 0

Answer ( 1 )

  1. If the programmers want the output to be a list, then lapply() function is used.
    Eg:
    movies <- c("SPYDERMAN","BATMAN","VERTIGO","CHINATOWN")
    movies_lower <-lapply(movies, tolower)
    str(movies_lower)
    OUTPUT:
    ## List of 4
    ## $:chr"spyderman"
    ## $:chr"batman"
    ## $:chr"vertigo"
    ## $:chr"chinatown"

Leave an answer

Browse
Browse