multiple-columns

Splitting text column into ragged multiple new columns in a data table in R

北战南征 提交于 2019-11-27 04:40:28
问题 I have a data table containing 20000+ rows and one column. The string in each column has different number of words. I want to split the words and put each of them in a new column. I know how I can do it word by word: Data [ , Word1 := as.character(lapply(strsplit(as.character(Data$complaint), split=" "), "[", 1))] ( Data is my data table and complaint is the name of the column) Obviously, this is not efficient because each cell in each row has different number of words. Could you please tell

Set the variable result, from query

妖精的绣舞 提交于 2019-11-27 04:24:51
问题 When I create the saved procedure, i can create some variable yes? for example: CREATE PROCEDURE `some_proc` () BEGIN DECLARE some_var INT; SET some_var = 3; .... QUESTION: but how to set variable result from the query, that is how to make some like this: DECLARE some_var INT; SET some_var = SELECT COUNT(*) FROM mytable ; ? 回答1: There are multiple ways to do this. You can use a subquery: SET some_var = (SELECT COUNT(*) FROM mytable); (like your original, just add parenthesis around the query)

Combine two or more columns in a dataframe into a new column with a new name

一曲冷凌霜 提交于 2019-11-27 03:37:04
For example if I have this: n = c(2, 3, 5) s = c("aa", "bb", "cc") b = c(TRUE, FALSE, TRUE) df = data.frame(n, s, b) n s b 1 2 aa TRUE 2 3 bb FALSE 3 5 cc TRUE Then how do I combine the two columns n and s into a new column named x such that it looks like this: n s b x 1 2 aa TRUE 2 aa 2 3 bb FALSE 3 bb 3 5 cc TRUE 5 cc mnel Use paste . df$x <- paste(df$n,df$s) df # n s b x # 1 2 aa TRUE 2 aa # 2 3 bb FALSE 3 bb # 3 5 cc TRUE 5 cc Little Bee For inserting a separator: df$x <- paste(df$n, "-", df$s) As already mentioned in comments by Uwe and UseR, a general solution in the tidyverse format

wpf grid with dynamic columns

巧了我就是萌 提交于 2019-11-27 03:33:03
问题 I have a collection that I wish to bind to a WPF grid. The problem I'm facing is that the number of columns is dynamic and is dependent on a collection. Here is a simple mock up: public interface IRows { string Message{get;} IColumns[] Columns{get;} } public interface IColumns { string Header {get;} AcknowledgementState AcknowledgementState{get;} } public interface IViewModel { ObservableCollection<IRows> Rows {get;} } I want my view to bind to the the Rows collection, which contains a

How does cellForRowAtIndexPath work?

Deadly 提交于 2019-11-27 03:00:53
I HAVE READ apple documentation and it's not understandable for such a beginner in Objective-C as me. I'm trying to implement multicolumn UITableView following this link example and it just doesn't work so i need to comprehend how cellForRowAtIndexPath work, cause for me personally this method seems pretty complicated. 1) What does it return? UITableViewCell ? But why does it look so odd? -(UITableViewCell *)tableView:(UITableView *)tableView What is that? Could you please explain? 2) How does it get called and what is more important how am i to connect it to a certain UITableView ??? What if

Remove columns of dataframe based on conditions in R

偶尔善良 提交于 2019-11-27 02:59:02
问题 I have to remove columns in my dataframe which has over 4000 columns and 180 rows.The conditions I want to set in to remove the column in the dataframe are: (i) Remove the column if there are less then two values/entries in that column (ii) Remove the column if there are no two consecutive(one after the other) values in the column. (iii) Remove the column having all values as NA. I have provided with conditions on which a column is to be deleted. The aim here is not just to find a column by

Laravel 4: Unique Validation for Multiple Columns

孤街浪徒 提交于 2019-11-27 02:52:27
问题 I know this question has been asked earlier but i did not get relevant answer. I want to know that how can i write a rule to check uniqueness of two columns. I have tried to write a rule like: public $rules = array( "event_id"=>"required", "label"=>"required|unique:tblSection,label,event_id,$this->event_id", "description"=>"required" ); In my example i need to put validation so that one label could be unique for a single event id but may be used for other event id as well. For Example i want

How to paste columns from separate files using bash?

你说的曾经没有我的故事 提交于 2019-11-27 02:02:30
问题 Using the following data: $cat date1.csv Bob,2013-06-03T17:18:07 James,2013-06-03T17:18:07 Kevin,2013-06-03T17:18:07 $cat date2.csv 2012-12-02T18:30:31 2012-12-02T18:28:37 2013-06-01T12:16:05 How can date1.csv and date2.csv files be merged? Output desired: $cat merge-date1-date2.csv Bob,2013-06-03T17:18:07,2012-12-02T18:30:31 James,2013-06-03T17:18:07,2012-12-02T18:28:37 Kevin,2013-06-03T17:18:07,2013-06-01T12:16:05 Please note: the best solution will be able to quickly manage a massive

Read CSV file column by column

空扰寡人 提交于 2019-11-27 01:01:22
I want to read specific columns from a multi column csv file and print those columns in other csv file using Java. Any help please? Following is my code to print each token line by line..But I am looking to print only few columns out of the multi column csv. import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.util.StringTokenizer; public class ParseCSV { public static void main(String[] args) { try { //csv file containing data String strFile = "C:\\Users\\rsaluja\\CMS_Evaluation\\Drupal_12_08_27.csv"; //create BufferedReader to read csv file

apply a function over groups of columns

跟風遠走 提交于 2019-11-26 22:44:51
How can I use apply or a related function to create a new data frame that contains the results of the row averages of each pair of columns in a very large data frame? I have an instrument that outputs n replicate measurements on a large number of samples, where each single measurement is a vector (all measurements are the same length vectors). I'd like to calculate the average (and other stats) on all replicate measurements of each sample. This means I need to group n consecutive columns together and do row-wise calculations. For a simple example, with three replicate measurements on two