Reputation: 49
I have read a html table with
tables <- readHTMLTable(path, which=1)
and would like to process the information further. Currently my data looks like this.
Category Entry
A 1
B 2
C 3
A 4
B 5
C 6
A 7
B 8
C 9
I would like to have a data frame that looks like this.
A B C
1 2 3
4 5 6
7 8 9
Is there a simple way to do this?
Upvotes: 0
Views: 54
Reputation: 886938
We can use unstack
unstack(df1, Entry~Category)
# A B C
#1 1 2 3
#2 4 5 6
#3 7 8 9
df1 <- structure(list(Category = c("A", "B", "C", "A", "B", "C", "A",
"B", "C"), Entry = 1:9), .Names = c("Category", "Entry"),
class = "data.frame", row.names = c(NA, -9L))
Upvotes: 3