字符串对tibble的作用

时间:2018-02-14 17:04:39

标签: r parsing tibble

我需要定义一个函数f(x,y),以便:

x = "col1,1,2,3,4"
y = "col2,a,b,c,d"

成为:

# A tibble: 4 x 2
   col1  col2
  <int> <chr>
1     1     a
2     2     b
3     3     c
4     4     d

有什么想法?谢谢。

1 个答案:

答案 0 :(得分:1)

我想到的最明显的想法是用逗号分割输入,使用<HTML> <HEAD> <TITLE>Salary Sheet</TITLE> </HEAD> <BODY> <?php include "connect.php"; $mysql = "SELECT * FROM emp_ndata LIMIT 0,1"; $myquery = mysqli_query($con, $mysql); if(! $myquery ) { die('Could not get data: ' . mysql_error()); } $row = mysqli_fetch_array($myquery, MYSQLI_ASSOC); ?> <div id="pdata"> <table class="table_for_showdata table_for_showdata_small"> <tr> <th colspan="2"> Salary Sheet of <b class="table_for_showdata_lg"> <?php echo $row['Emp_Name']; ?></b> :&nbsp; <?php echo $row ['Emp_psmonth']; ?>&nbsp; , &nbsp;<?php echo $row ['Emp_psyear']; ?> </th> </tr> <tr> <td>Emp-Code</td> <td><?php echo $row['Emp_ID']; ?></td> </tr> <tr> <td>Designation</td> <td><?php echo $row['Emp_Designation']; ?></td> </tr> <tr> <th colspan="2">EARNINGS</th> </tr> <tr> <td >Basic</td> <td><?php echo round($row ['Emp_Basic']).".00"; ?></td> </tr> <tr> <td >House Rent Allowance</td> <td><?php echo round($row ['Emp_HRA']).".00"; ?></td> </tr> <tr> <th >DEDUCTIONS</th> <th>&nbsp;</th> </tr> <tr> <td >Professional Tax</td> <td><?php echo $row ['Emp_Proffessional_Tax'].".00"; ?></td> </tr> <tr> <td >Provident Fund</td> <td><?php echo $row ['Emp_Provident_Fund'].".00"; ?></td> </tr> <tr> <th >&nbsp;</th> <th>&nbsp;</th> </tr> <tr> <td class="tab_head_blue"><b>TOTAL PAY : </td> <td style="font-size:18px"><b>Rs.<?php echo $row ['Emp_Total_Pay'].".00"; ?></b></td> </tr> </table> </div> <script type="text/javascript"> function printDiv() { var divToPrint = document.getElementById('pdata'); var popupWin = window.open('', '_blank', 'width=1100,height=400'); popupWin.document.open(); document.title = "<?php echo $row['Emp_Name']; ?>"; popupWin.document.write('<html><head><title>' + document.title + '</title>'); popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>'); popupWin.document.close(); } </script> <script> printDiv(); </script> </BODY></HTML> 将输出合并为一个字符串,并使用paste读取。

示例:

read_csv

从那里,我希望你能够将方法转换为函数。