If I have the example list Names
Names <- list(A = c("one", "two", "three"),
B = c("three", "four", "five"))
Is it then possible to create a column heading using one of the strings contained in the list? For example, the code below is trying to create a column named One
by indexing Names[[1]][1]
but clearly does not work.
data.frame(Names[[1]][1] = rep(5, 5))
Any suggestions would be appreciated. I tried to wrap with as.character()
but am still searching for solutions. The real data is being implemented within a loop and requires on the Names
index. The desired out come is shown below.
data.frame(One = rep(5, 5))