5
Help with unit conversion (bytes) within a column
Post Body
Hi all, I have a quick, newbie question.
I have a dataframe with app names and sizes. Here is a simplified example below:
size app
1 1.7M A
2 30.8M B
3 2.3M C
4 456k D
5 10M E
6 123k F
Both columns are strings, but I'd like to have size be numeric and stabilized to megabytes. This would involve me multiplying all k's by 0.001. But I can't multiply until I remove the letters.
I looked into the measurements packages and I don't think they have a conversion for this. I thought of a select(), gsub(), str_replace(), lapply (I'm partial to lapply, I've used it elsewhere in the code), extract(), and ifelse(). Would I have to split the columns and then remerge them? Is this just a simple for loop?
Author
Account Strength
100%
Account Age
4 years
Verified Email
Yes
Verified Flair
Yes
Total Karma
5,699
Link Karma
4,416
Comment Karma
668
Profile updated: 16 hours ago
Posts updated: 4 months ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/rprogrammin...