Quantcast
Channel: R - merge two dataframes - Error in sort.list(bx[m$xi]) : 'x' must be atomic for 'sort.list' - Stack Overflow
Viewing all articles
Browse latest Browse all 3

R - merge two dataframes - Error in sort.list(bx[m$xi]) : 'x' must be atomic for 'sort.list'

$
0
0

I am trying to merge to dataframe by key_date that set in each of them:

> merge <- merge(x = df1, y = df2, by = "key_date", all.x = TRUE)

Error:

Error in sort.list(bx[m$xi]) : 'x' must be atomic for 'sort.list'Have you called 'sort' on a list?

The structure of df1:

'data.frame':   192 obs. of  8 variables: $ date    : POSIXct, format: "2017-02-03 00:00:00" ... $ NO2     : num  7.4 6.7 7 6.1 5.8 8.8 9 8.5 8.1 7.6 ... $ key_date: POSIXlt, format: "2017-02-03" ... $ site    : chr  "anon1""anon1""anon1""anon1" ... $ code    : chr  "anon1""anon1""anon1""anon1" ...

The structure of df2:

'data.frame':   2 obs. of  6 variables: $ airport : chr  "LCY""LCY" $ key_date: chr  "2017-02-04""2017-02-03" $ ws      : num  4 13 $ wd      : num  161 185 $ tempi   : num  7 8 $ humidity: num  85 78> dput(df2)structure(list(airport = c("LCY", "LCY"), key_date = c("2017-02-04", "2017-02-03"), ws = c(4, 13), wd = c(161, 185), tempi = c(7, 8), humidity = c(85, 78)), .Names = c("airport", "key_date", "ws", "wd", "tempi", "humidity"), row.names = c(NA, -2L), class = "data.frame")

What has gone wrong? Any ideas?


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>