Tech Diary
November 21, 2018
R melt data frame - convert to long format
melted_data <- melt(somedata[somedata$col1 %in% c('A', 'B'),], id="col1") # convert to long format
Before
col1
col2
col3
A
x
1
B
y
2
C z 3
After melt
col1
variable
value
A
col2
x
A
col3
1
B
col2
y
B
col3
2
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment