What does L mean?

Hello everyone!

I am new to R and am trying to understand some codes that other people have written. The code I am focusing on right now was written by @andresrcs in this thread:

df %>%
pivot_longer(c("PA", "PUA"), names_to = "type") %>%
ggplot(aes(y = Country, x = value, fill = type)) +
geom_col() +
scale_x_continuous(labels = scales::percent_format(scale = 1))
#> Error in df %>% pivot_longer(c("PA", "PUA"), names_to = "type") %>% ggplot(aes(y = Country, : could not find function "%>%"

Created on 2021-12-10 by the reprex package (v2.0.1)

As you can see, andresrcs writes "10L" in the c() function following row.names. What does "-10L" mean? From what I understand, including "-10L" will produce a data frame with 10 rows. But I cannot find any instruction document to confirm that. Furthermore, why is the integer negative (-10 instead of 10)? Does it have something to do with the "L" element?

the "L" after a number denotes that is of class "integer" and not "numeric"

class(10L)
#> [1] "integer"
class(10)
#> [1] "numeric"

Created on 2021-12-10 by the reprex package (v2.0.1)

Also, I haven't manually written the "L"s, that part of the code comes from the sample data (in a copy/paste friendly format). That format is usually produced by the use of the dput() or datapasta::df_paste() functions.

Read this reprex guide to better understand the concept

Thank you, @andresrcs !

P.S. Is it okay to thank people on RStudio? The guidelines on StackOverflow (another coding forum, which I'm sure you've heard of) recommend that we do not thank each other lest we clog up our threads. Does the same policy apply in RStudio?

Yes, it's OK but it is more usual to simply give "likes" to the person you want to thanks.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.