Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

Add column to R dataframe that is length of string in another column

$
0
0

This should be EASY but I can't figure it out and search didn't help. I'd like to add a column to a dataframe that is just the length of the strings in another column.

So say I have a data frame of names like such:

   Name    Last
1  John     Doe
2 Edgar     Poe
3  Walt Whitman
4  Jane  Austen

I'd like to append a new column with the string length of, say, the last name, so it would look like:

   Name    Last  Length
1  John     Doe  3
2 Edgar     Poe  3
3  Walt Whitman  7
4  Jane  Austen  6

Thanks


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>