简体   繁体   中英

When Creating Data Frame Character Values Are Stripped From Alphanumeric String

When creating a dataframe one of the columns is alpanumeric and the alpha characters are stripped on

>View(df) 

Code for data frame:

df <- as.data.frame(cbind(df[,1],df[,2],df[,3],df[,4],df[,5],
                          df[,6],df[,7],df[,8],df[,9]))

Column 5 is the field. Example values:

YC1275421
YW3759841
YC1289724

When viewing the dataframe the values are:

1275421
3759841
1289724

I also exported the dataframe and confirmed that the alpha characters were stripped.

How do I create the dataframe so that it contains the alphanumeric string?

As I see this problem, try this solution.

df <- data.frame(df[,1],df[,2],df[,3],df[,4],df[,5],
                          df[,6],df[,7],df[,8],df[,9])

or give head of the data so I can come with better solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM