-3

This dataframe code :

f <- function (l) { l } data.frame(lapply(letters[1:2] , f)) 

which renders :

enter image description here

I'm attempting to transpose the rows to cols so a,b appear as :

X.a. a X.b. b 

I tried :

f <- function (l) { l } data.frame(t(lapply(letters[1:2] , f))) 

But this renders :

enter image description here

Can I use transpose function t() to change how data frame appears ?

0

1 Answer 1

2

You want to do this instead:

t(data.frame(lapply(letters[1:2] , f))) 

Your code attempts to transpose the output of lapply, which is always a list.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.