Message-ID: <CAN2xGJZkPF1mSvFpMmRdfjHHN_5rrQTyb_-y_vyvDpCys0rGPA@mail.gmail.com>
Date: 2015-04-23T13:15:02Z
From: Dimitri Liakhovitski
Subject: reshape data frame when one column has unequal number of entries
Hello!
I have my data frame x with 2 character columns:
x <- data.frame(a = numeric(), b = I(list()))
x[1:3,"a"] = 1:3
x[[1, "b"]] <- "a, b, c"
x[[2, "b"]] <- "d, e"
x[[3, "b"]] <- "f"
x$a = as.character(x$a)
x$b = as.character(x$b)
x
str(x)
I need to produce this data frame:
1 a
1 b
1 c
2 d
2 e
3 f
Is it possible without looping?
Thank you!
--
Dimitri Liakhovitski