Username
Username

Reputation: 3663

How do I make a column showing the length of a string from another column?

A sample of my dataframe where the first line is the column title:

col1
some string
some other string

How do I make another column showing how long each of col1's strings are?

Upvotes: 1

Views: 6093

Answers (1)

Username
Username

Reputation: 3663

Got it thanks to akrun's help:

df$col2 <- nchar(as.character(df$col1))

Upvotes: 5

Related Questions