在由DT1
指定的每个i
组中的给定键列中,将data.table
(如DT2
中的DT2
)加入Date
DT2[DT1, on = 'key']
列。
我无法运行key
,因为那是不正确的,因为Date
列中的DT3
列是重复的,但是在一个日期内是唯一的。
split
是我的预期输出。如果没有data.table
-y的library(data.table)
set.seed(1)
DT1 <- data.table(
Segment = sample(paste0('S', 1:10), 100, TRUE),
Activity = sample(paste0('A', 1:5), 100, TRUE),
Value = runif(100)
)
dates <- seq(as.Date('2018-01-01'), as.Date('2018-11-30'), by = '1 day')
DT2 <- data.table(
Date = rep(dates, each = 5),
Segment = sample(paste0('S', 1:10), 3340, TRUE),
Total = runif(3340, 1, 2)
)
rm(dates)
# To ensure that each Date Segment combination is unique
DT2 <- unique(DT2, by = c('Date', 'Segment'))
iDT2 <- split(DT2, by = 'Date')
iDT2 <- lapply(
iDT2,
function(x) {
x[DT1, on = 'Segment', nomatch = 0]
}
)
DT3 <- rbindlist(iDT2, use.names = TRUE)
动作,有什么方法可以实现?
ListView lViewSMS = (ListView) findViewById(R.id.listViewSMS);
if(fetchInbox()!=null)
{
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, fetchInbox());
lViewSMS.setAdapter(adapter);
}
//put the above part in oncreateview()
public ArrayList fetchInbox()
{
ArrayList sms = new ArrayList();
Uri uriSms = Uri.parse("content://sms/inbox");
Cursor cursor = getContentResolver().query(uriSms, new String[]{"_id", "address", "date", "body","" + "person"},null,null,null);
cursor.moveToFirst();
while (cursor.moveToNext())
{
String match="is created";
String address = cursor.getString(1);
String body = cursor.getString(3);
// String title = cursor.getString(3);
String tdata=body;
sms.add(""+""+body);
}
return sms;
}
答案 0 :(得分:1)
使用笛卡尔-1
可以达到相同的结果:
answers = ["orange", "apple", "pear"]
if (answers.indexOf(userGuess) != -1) {
console.log(userGuess + "is correct");
}
以下是证明:
merge