Need some assistance with Data Wrangling in R

r

#1

I have two columns in a CSV file, “Device” and “IP” (both are headers). For each row in the “Device” column, there are multiple IPs in the “IP” column but they are embedded in the same cell separated by the new line character. My objective is to get the IPs in separate rows in the “IP” column for and the corresponding device repeating in the “Device” column. How do I do this in R. Please assist.


#2

You should use a combination of gsub and reshape to get what you need. Check the below link to get basic understanding of reshaping data.

Idea is to first get the IP’s in multiple columns and then reshaping the data the way you want. No direct answers, here but thats the best way to learn. Try it out.

https://www.r-statistics.com/tag/transpose/


#3

Thanks for your guidance, let me try that out.