我会使用diplyr加入一些表,但这会提醒我一些错误。
我有两个变量,我想加入它们,但它提醒我一些错误。怎么了?如何使用dplyr创建在行之间正确匹配的表?谢谢
Mouth_tissues= counts_sample_mouth0$counts
Glands= counts_sample_gland0$counts
head(Mouth_tissues)
Mouth_tissues
gene0 547
gene1 78
gene2 5
gene3 13
gene4 16
gene5 49
> head(Glands)
Glands
gene0 332
gene1 60
gene2 583
gene3 6964
gene4 2162
gene5 6
> full_join(Mouth_tissues, Glands)
Error in UseMethod("full_join") :
no applicable method for 'full_join' applied to an object of class "c('matrix', 'integer', 'numeric')"
然后我做了:
mouth<-as.data.frame.matrix(Mouth_tissues)
glands<-as.data.frame.matrix(Glands)
library(dplyr)
full_join(mouth, glands)
Error: `by` required, because the data sources have no common variables
Call `rlang::last_error()` to see a backtrace
dput(head(counts_sample_gland0))
dput(head(counts_sample_mouth0))
答案 0 :(得分:0)
我认为这是您想要做的?
使用“ Num”列上的完整联接将两个表联接在一起。
public partial class Window3 : Window
{
string dbConnectionString = @"Data Source = tensiondata.db;Version=3;"; // String connection
private object con;
public Window3()
{
InitializeComponent();
}
private void Open_Click(object sender, RoutedEventArgs e) // Opening Excel file into data grid
{
OpenFileDialog openfile = new OpenFileDialog();
openfile.DefaultExt = ".xlsx";
openfile.Filter = "(.xlsx)|*.xlsx";
//openfile.ShowDialog();
var browsefile = openfile.ShowDialog();
if (browsefile == true)
{
txtFilePath.Text = openfile.FileName;
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook excelBook = excelApp.Workbooks.Open(txtFilePath.Text.ToString(), 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
Microsoft.Office.Interop.Excel.Worksheet excelSheet = (Microsoft.Office.Interop.Excel.Worksheet)excelBook.Worksheets.get_Item(1); ;
Microsoft.Office.Interop.Excel.Range excelRange = excelSheet.UsedRange;
string strCellData = "";
double douCellData;
int rowCnt = 0;
int colCnt = 0;
DataTable dt = new DataTable();
for (colCnt = 1; colCnt <= excelRange.Columns.Count; colCnt++)
{
string strColumn = "";
strColumn = (string)(excelRange.Cells[1, colCnt] as Microsoft.Office.Interop.Excel.Range).Value2;
dt.Columns.Add(strColumn, typeof(string));
}
for (rowCnt = 1; rowCnt <= excelRange.Rows.Count; rowCnt++)
{
string strData = "";
for (colCnt = 1; colCnt <= excelRange.Columns.Count; colCnt++)
{
try
{
strCellData = (string)(excelRange.Cells[rowCnt, colCnt] as Microsoft.Office.Interop.Excel.Range).Value2;
strData += strCellData + "|";
}
catch (Exception ex)
{
douCellData = (excelRange.Cells[rowCnt, colCnt] as Microsoft.Office.Interop.Excel.Range).Value2;
strData += douCellData.ToString() + "|";
}
}
strData = strData.Remove(strData.Length - 1, 1);
dt.Rows.Add(strData.Split('|'));
}
dtGrid.ItemsSource = dt.DefaultView;
excelBook.Close(true, null, null);
excelApp.Quit();
}
}
private void Button_Click(object sender, RoutedEventArgs e) // Next Window Button
{
Window2 sec = new Window2();
sec.ShowDialog();
}
private void Button_Click_1(object sender, RoutedEventArgs e) // Save and update button
{
//Open connection to database
SQLiteConnection SQLiteCon = new SQLiteConnection(dbConnectionString);
SQLiteCon.Open();
try
{
}
//SQLiteCon.Close();
//}
// while (dr.Read())
// {
// }
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}