如何将原始向量从sqlQuery转换为数据帧中的单个字符串?

时间:2019-08-07 10:48:43

标签: r rodbc dremio

在我的工作场所,R与Dremio集成在一起,我可以使用RODBC :: sqlQuery()函数访问Dremio中的表。表中有大约十万个条目。我正在使用此函数创建SQL表的数据框架,但某些行以不同的格式存储数据。我已经读过sqlQuery函数将二进制SQL类型转换为原始向量列表,因此我正在获得像这样的单元格值:

ArrayList<Integer> subArrayList;

for(int i=0;i<4;i++) {

    subArrayList = new ArrayList<Integer>();
    subArrayList.add(1); // I'm adding a random value to subArrayList
    mainArrayList.add(subArrayList);

}
extension UITextField  {
func addInputViewDatePicker(target: Any, selector: Selector) {

    let screenWidth = UIScreen.main.bounds.width

    //Add DatePicker as inputView
    let datePicker = UIDatePicker(frame: CGRect(x: 0, y: 0, width: screenWidth, height: 216))
    datePicker.datePickerMode = .date
    self.inputView = datePicker

    //Add Tool Bar as input AccessoryView
    let toolBar = UIToolbar(frame: CGRect(x: 0, y: 0, width: screenWidth, height: 44))
    let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
    let cancelBarButton = UIBarButtonItem(title: "Cancel", style: .plain, target: self, action: #selector(cancelPressed))
    let doneBarButton = UIBarButtonItem(title: "Done", style: .plain, target: target, action: selector)
    toolBar.setItems([cancelBarButton, flexibleSpace, doneBarButton], animated: false)

    self.inputAccessoryView = toolBar
}

@objc func cancelPressed() {
    self.resignFirstResponder()
} }


class helperFileViewController: UIViewController 
{


@IBOutlet weak var DOBTextField: UITextField!

override func viewDidLoad() {
    super.viewDidLoad()
    DOBTextField.addInputViewDatePicker(target: self, selector: #selector(doneButtonPressed))

}

@objc func doneButtonPressed() {
    if let  datePicker = self.DOBTextField.inputView as? UIDatePicker {
        let dateFormatter = DateFormatter()
        dateFormatter.dateStyle = .medium
        self.DOBTextField.text = dateFormatter.string(from: datePicker.date)
    }
    self.DOBTextField.resignFirstResponder()
    self.DOBTextField.inputView = nil
    self.DOBTextField.reloadInputViews()
    self.DOBTextField.becomeFirstResponder()
}
}

我希望像元值是单个字符串id as.raw(c(0x56, 0xfd, 0x36, 0xaf, 0x63, 0x18, 0x77, 0x2a, 0x09, 0x35, 0x9f, 0xe3)) ,以便可以将其用作与其他表的匹配条件。有什么办法吗?

1 个答案:

答案 0 :(得分:0)

您可以使用dplyr


library(dplyr)

df$`_Id` %>% 
  sapply(., function(x) { paste0(x, collapse = "") }) %>% 
  as.data.frame(string_id=as.character(.), stringsAsFactors=FALSE) 

# 1 56fd36af6318772a09359fe3
# 2 56fd37076318772a09359feb
# 3 56fd387a6318772a0935a007
# 4 56fd388b6318772a0935a00e
# 5 56fd389d6318772a0935a012