I'm taking the columns from a data frame and using them to create another data frame, but the names keep getting jumbled instead of keeping the original name. How do I avoid this?
> newDigit1 <- data.frame((security_id = rsPred1$security_id))
> head(newDigit1)
X.security_id...rsPred1.security_id.
1 1
2 6
3 5
4 3
5 3
6 2
It should be like this:
> newDigit1 <- data.frame((security_id = rsPred1$security_id))
> head(newDigit1)
security_id
1 1
2 6
3 5
4 3
5 3
6 2
It's because you've doubled up the brackets
((
. CompareIn case 1,
x = dfr$x
is a name-value pair being passed into thedata.frame
function.In case 2,
(x = dfr$x)
returns a vector with no name, so R invents a temporary one and then passes that vector into thedata.frame
function.