I have a nested named list which looks like the following:
> data <- list("1"=list(rating=-1,points=190,name="Fernando"),"2"=list(rating=3,points=532,name="Carlos"))
> data
$'1'
$'1'$rating
[1] -1
$'1'$points
[1] 190
$'1'$name
[1] "Fernando"
$'2'
$'2'$rating
[1] 3
$'2'$points
[1] 532
$'2'$name
[1] "Carlos"
Now when I use the melt function on "data" then it converts the value for name to numeric instead of character. And I can understand why because the data type for value is set to be numeric. Is there a way to convert the data type for value to be character overall.
Here's what I get when I use melt function:
> melt(data)
value L2 L1
1 -1 rating 1
2 190 points 1
3 1 name 1
4 3 rating 2
5 532 points 2
6 1 name 2
But what I want is the following:
value L2 L1
1 -1 rating 1
2 190 points 1
3 Fernando name 1
4 3 rating 2
5 532 points 2
6 Carlos name 2
where the data type of values is characters.