Search Results

Search found 6257 results on 251 pages for 'columns'.

Page 14/251 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Reshape data frame to convert factors into columns in R

    - by Alexander L. Belikoff
    I have a data frame where one particular column has a set of specific values (let's say, 1, 2, ..., 23). What I would like to do is to convert from this layout to the one, where the frame would have extra 23 (in this case) columns, each one representing one of the factor values. The data in these columns would be booleans indicating whether a particular row had a given factor value... To show a specific example: Source frame: ID DATE SECTOR 123 2008-01-01 1 456 2008-01-01 3 789 2008-01-02 5 ... <more records with SECTOR values from 1 to 5> Desired format: ID DATE SECTOR.1 SECTOR.2 SECTOR.3 SECTOR.4 SECTOR.5 123 2008-01-01 T F F F F 456 2008-01-01 F F T F F 789 2008-01-02 F F F F T I have no problem doing it in a loop but I hoped there would be a better way. So far reshape() didn't yield the desired result. Help would be much appreciated.

    Read the article

  • Comparing 2 columns in the same table with the "Like" function

    - by Vic
    I'm trying to come up with a way to query the values in two different columns in the same table where the result set will indicate instances where the value of columnB doesn't contain the value of columnA. For example, my "Nodes" table contains columns "NodeName" and "DNS". The values should look similar to the following: NodeName DNS Router1 Router1.mydomain.com I want to run a query to show which rows have a DNS value that does not contain (or begin with) the value of the NodeName field. I think the query should function something similar to the following, but obviously I'm missing something with regard to the use of "Like" in this situation. SELECT NodeName, DNS WHERE DNS NOT LIKE 'NodeName%' I'm using SQL Server 2005, and any suggestions would be greatly appreciated... :)

    Read the article

  • Mathematica - Import CSV and process columns?

    - by Casey
    I have a CSV file that is formatted like: 0.0023709,8.5752e-007,4.847e-008 and I would like to import it into Mathematica and then have each column separated into a list so I can do some math on the selected column. I know I can import the data with: Import["data.csv"] then I can separate the columns with this: StringSplit[data[[1, 1]], ","] which gives: {"0.0023709", "8.5752e-007", "4.847e-008"} The problem now is that I don't know how to get the data into individual lists and also Mathematica does not accept scientific notation in the form 8.5e-007. Any help in how to break the data into columns and format the scientific notation would be great. Thanks in advance.

    Read the article

  • SQL Count Query with Grouping by multiple Columns

    - by Christian
    I have a table with three filled columns named "Name", "City" and "Occupation". I want to create a new column in the same table that contains the number of people who have the same occupation. "Name" | "City" | "Occupation" ------------------------------ Amy | Berlin | Plumber Bob | Berlin | Plumber Carol | Berlin | Lawyer David | London | Plumber I want to have a table that contains: "Name" | "City" | "Occupation" | "Number" --------------------------------------- Amy | Berlin | Plumber | 2 Bob | Berlin | Plumber | 2 Carol | Berlin | Lawyer | 1 David | London | Plumber | 1 How does the SQL Query that creates the new columns have to look like? I want to actually create a new column in the database that I can access later.

    Read the article

  • Rails Joins and include columns from joins table

    - by seth.vargo
    I don't understand how to get the columns I want from rails. I have two models - A User and a Profile. A User :has_many Profile (because users can revert back to an earlier version of their profile): > DESCRIBE users; +----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | username | varchar(255) | NO | UNI | NULL | | | password | varchar(255) | NO | | NULL | | | last_login | datetime | YES | | NULL | | +----------------+--------------+------+-----+---------+----------------+   > DESCRIBE profiles; +----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | user_id | int(11) | NO | MUL | NULL | | | first_name | varchar(255) | NO | | NULL | | | last_name | varchar(255) | NO | | NULL | | | . . . . . . | | . . . . . . | | . . . . . . | +----------------+--------------+------+-----+---------+----------------+ In SQL, I can run the query: > SELECT * FROM profiles JOIN users ON profiles.user_id = users.id LIMIT 1; +----+-----------+----------+---------------------+---------+---------------+-----+ | id | username | password | last_login | user_id | first_name | ... | +----+-----------+----------+---------------------+---------+---------------+-----+ | 1 | john | ****** | 2010-12-30 18:04:28 | 1 | John | ... | +----+-----------+----------+---------------------+---------+---------------+-----+ See how I get all the columns for BOTH tables JOINED together? However, when I run this same query in Rails, I don't get all the columns I want - I only get those from Profile: # in rails console >> p = Profile.joins(:user).limit(1) >> [#<Profile ...>] >> p.first_name >> NoMethodError: undefined method `first_name' for #<ActiveRecord::Relation:0x102b521d0> from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.1/lib/active_record/relation.rb:373:in `method_missing' from (irb):8 # I do NOT want to do this (AKA I do NOT want to use "includes") >> p.user >> NoMethodError: undefined method `user' for #<ActiveRecord::Relation:0x102b521d0> from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.1/lib/active_record/relation.rb:373:in method_missing' from (irb):9 I want to (efficiently) return an object that has all the properties of Profile and User together. I don't want to :include the user because it doesn't make sense. The user should always be part of the most recent profile as if they were fields within the Profile model. How do I accomplish this?

    Read the article

  • Search 2 Columns with 1 Input Field

    - by Norbert
    I have a db with two columns: first name and last name. The first name can have multiple words. Last name can contain hyphenated words. Is there a way to search both columns with only one input box? Database ID `First Name` `Last Name` 1 John Peter Doe 2 John Fubar 3 Michael Doe Search john peter returns id 1 john returns id 1,2 doe returns id 1,3 john doe returns id 1 peter john returns id 1 peter doe returns id 1 doe john returns id 1 I previously tried the following. Searching for John Doe: SELECT * FROM names WHERE ( `first` LIKE '%john%' OR `first` LIKE '%doe%' OR `last` LIKE '%john%' OR `last` LIKE '%doe%' ) which returns both 1 and 3

    Read the article

  • How to read values from Gridview columns controls in WPF

    - by Sarat
    hi frnds, I am using a WPF application, in which i placed a listview control which has 3 gridview columns. First Gridview column has a label Control and the remaining 2 gridview columns has textbox control. Now my problem is if the user enters a value in the first Gridview textbox column, the second gridview textbox column should be updated with some value. Is there any way to do that. I am filling the list view with a datatable from code behind file. And also is there any way to get the value of the label control in the 1st gridview column. Thanks in advance urs Frnd :)

    Read the article

  • Are Sphinx & thinking_sphinx really stable? Not indexing Columns

    - by seb
    I'm encountering strange behaviour from thinking_sphinx/sphinx. My define_index block is about 100 lines, so quite a lot of columns i'm indexing. For full-text searching I only need about 10 attributes, for sorting and filtering I have another approximately 50 columns, mostly floats and integers. By filtering I mean using the "with" or "without" options. Searching does not really work consistently. All of a sudden, one attribute fails to filter. Or if I add a new one, it does not work. Only after a lot of tinkering it suddenly starts working. I cannot really reproduce it. Steps I that sometimes lead me to success where: rm -rf db/sphinx change the attribute definition e.g. has some_attribute = has some_attribute, :sortable = true or = has some_attribute, :sortable = true, :as = "some_attribute" restarting the server assigning a new :as name = has some_attribute, :as = "some_attribute_new" (yes, I did rake ts:rebuild or rake ts:in after every step) Does anybody else encounter similar problems?

    Read the article

  • Return order of MySQL SHOW COLUMNS

    - by rich
    Hey guys. Simple one this, but one I can't seem to find any information on so here goes. I need to find the columns in a specific table, which is no problem.... SHOW COLUMNS FROM tablename LIKE '%ColumnPrefix%'; But I need to know what order they will be returned, preferable by choosing to order the results ascending alphabetically. I have had no luck with using ORDER BY Field. Any ideas? Cheers!

    Read the article

  • SQl rows to columns conversion

    - by Thihara
    Hi, I have a table ClassAttendance and I'm using MSSQL 2005 studentID--attendanceDate---------------------------------------status 1004--------2010-03-17--------------------------------------------------0 1005--------2010-03-17--------------------------------------------------1 1006--------2010-03-17--------------------------------------------------0 1007--------2010-03-17--------------------------------------------------0 1004--------2010-03-19--------------------------------------------------0 1005--------2010-03-19--------------------------------------------------1 1006--------2010-03-19--------------------------------------------------0 1007--------2010-03-19--------------------------------------------------0 1004--------2010-03-20--------------------------------------------------1 as you can see studentID is a foreign Key for a table called StudentData and attendedDate has an unknown number of rows. Can i get the output like below by using a query? I need the dates in one month to be columns and the value of the date columns will be values in the status column. The number of date records per studentID is the same its the number of dates in the attendanceDate filed that is unknown. studentID---------2010-03-17--------2010-03-19------2010-03-20 1004-----------------------------0----------------------0--------------------1 etc. This is for a creating a report so I need to do it in a query. Please help if you can.

    Read the article

  • Align table columns HTML

    - by Luigi Tiburzi
    I finally was able to align the columns in the tables of a page of my website. Though I found the solution I don't understand it. This is a fiddle I prepared. If you delete display: block from the CSS the columns are centered perfectly. The fact is that I don't understand what that instruction is causing problems, doesn't it means that elements are displayed as block elements? Shouldn't it cause the elements (the raw in particular) to fill an entire line? Thanks for your explanation

    Read the article

  • Code/Approach Golf: Find row in text file with too many columns

    - by awshepard
    Given a text file that is supposed to contain 10 tab-delimited columns (i.e. 9 tabs), I'd like to find all rows that have more than 10 columns (more than 9 tabs). Each row ends with CR-LF. Assume nothing about the data, field widths, etc, other than the above. Comments regarding approach, and/or working code would be extremely appreciated. Bonus for printing line numbers of offending lines as well. Thanks in advance!

    Read the article

  • Add opening and closing balance columns

    - by user1862899
    i have a table like this: StockNumber|InventoryName|Year|Month|Adj|iss|piss|Tsfr|return|rdj|rpo|xefr alb001 clinic1 2010 1 4 5 5 5 6 5 4 10 alb001 Clinic1 2010 2 10 2 2 3 3 4 4 4 alb001 Clinic1 2010 4 11 3 5 77 90 78 9 6 alb001 Clinic1 2010 5 10 2 2 3 3 4 4 4 i want to add a closing balance column which will be sum(return+rdj+rpo+xefr) - sum(adj+iss+piss+tsfr) i also want to add the opening balance column which will be the be the closing balance of the previous month. i will then calculate the current months balance as OpeningBalance + sum(return+rdj+rpo+xefr) - sum(adj+iss+piss+tsfr) = ClosingBalance NB.The Year and Month columns are floats and also want to change them to date format. i am newbie to sql and crystal reports....i want a query to help me achieve the tasks of developing a report that has the opening and closing balance columns,the opening balance being the previous closing balance.....thank you for your help....

    Read the article

  • Using VirtualMode on a DataGridView when the number of rows/columns isn't known

    - by Nathan Baulch
    I need to display an unknown length sequence of dictionaries with unknown keys efficiently in a data grid. This sequence is the result of a potentially slow LINQ query that could contain any number of results. At first I thought that VirtualMode on DataGridView was what I was looking for but it appears that the number of rows and columns must be known upfront. I tried adding a single row and column then adding more as needed from the CellValueNeeded event but this doesn't work. Is this even possible with VirtualMode? Or do I need to estimate how many rows are visible on the screen and manually build up the rows/columns? And if so, how do I ensure that a vertical scrollbar is present and react appropriately when a user uses it?

    Read the article

  • C#: Changing the order of columns when binding DataTable to a GridView

    - by Nir
    How is it possible to change the displayed order of columns from a DataTable? For example, dataTable "dt" contains two columns "a" and "b". I bind it to a GridView like this: gridView.DataSource = dt; gridView.DataBind(); But I'd like the GridView to display "b" first (leftmost). Important point: I'm using this to export to Excel and there's no actual output to screen, using: HtmlTextWriter htw = new HtmlTextWriter(sw); gridView.RenderControl(htw); Thanks!

    Read the article

  • concatenating results from SQL query and NULL columns

    - by Curtis
    I need to concatenate several columns of a table into a single value, then show that value in an asp dropdownlist. The SQL code I'm issuing is as follows: SELECT UserID, CustomerNum, UserName + ' - ' + UserAddress + ',' + UserCity + ' ' + UserState AS UserInfo FROM Users WHERE (CustomerNum = @CustomerNum) ORDER BY UserName I then set 'UserInfo' as the text field in the dropdownlist. This generally works, except occasionally one of the columns in the database is null (for example, UserState). When that happens, the entire concatenation is null, and I get an empty entry in the dropdownlist. Is there something in SQLServer that will allow me to ignore those NULL results, or will I have to code something up in the DataBind event? Thanks

    Read the article

  • Implications of Fulltext Search over many columns

    - by Alex
    Hello, I have a really wide table which includes separate columns for billing address, shipping address, primary address, names, aliases etc. (I can't normalize this table further, and that's not the question here anyways). I'm implementing SQL Server fulltext search, and I'm wondering whether I should limit the search ability to just the primary fields (primary address and names for example), or if I can extend the search ability across all columns without occurring too much of a performance or memory penalty. I've done some basic testing with 10,000 sample rows and it's quite fast but I don't have much experience with fulltext indexing, especially its dictionary internals, so I don't know if the index is going to grow over time, or if there is anything else to consider. Thoughts?

    Read the article

  • DDEX Firebird editing queries duplicates columns in Visual Studio 2008

    - by A Bothe
    Hello everybody! I don't know if some of you also has experienced it but when I edit a query in Visual Studio (it uses DDEX 2.0.5 for accessing the Firebird 2.5 database), it duplicates some of the columns. What's really interesting is the fact that only System.Boolean columns are duplicated: Originally, there was only ,for instance, a 'PRO_DELETED' field... Now I wanted to sort my results by this field - I had to change the select statement in the so-called QueryBuilder by adding "ORDER BY PRO_DELETED" ...After clicking OK it somehow created a new column (!?) called 'PRO_DELETED1' My question is: Why does DDEX add such a new row to the column view and why can't I access the original PRO_DELETED field anymore? Thanks in advance!

    Read the article

  • Maintaining the position of columns in Grails/GORM

    - by firnnauriel
    Is there a way to fix the position of the columns in a domain? I have this domain: class SnbrActVector { int nid String term double weight static mapping = { version false id(generator: 'assigned') } static constraints = { nid(blank:false) term(blank:false) weight(blank:false) } } This is the schema of the table generated: CREATE TABLE `fractor_grailsDEV`.`snbr_act_vector` ( `id` bigint(20) NOT NULL, `weight` double NOT NULL, `term` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `nid` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci It seems that the order of the columns were reversed. Is there a way to make it like this? (order is nid, term, weight) CREATE TABLE `fractor_grailsDEV`.`snbr_act_vector` ( `id` bigint(20) NOT NULL, `nid` int(11) NOT NULL, `term` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `weight` double NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

    Read the article

  • Using reshape + cast to aggregate over multiple columns

    - by DamonJW
    In R, I have a data frame with columns for Seat (factor), Party (factor) and Votes (numeric). I want to create a summary data frame with columns for Seat, Winning party, and Vote share. For example, from the data frame df <- data.frame(party=rep(c('Lab','C','LD'),times=4), votes=c(1,12,2,11,3,10,4,9,5,8,6,15), seat=rep(c('A','B','C','D'),each=3)) I want to get the output seat winner voteshare 1 A C 0.8000000 2 B Lab 0.4583333 3 C C 0.5000000 4 D LD 0.5172414 I can figure out how to achieve this. But I'm sure there must be a better way, probably a cunning one-liner using Hadley Wickham's reshape package. Any suggestions? For what it's worth, my solution uses a function from my package djwutils_2.10.zip and is invoked as follows. But there are all sorts of special cases it doesn't deal with, so I'd rather rely on someone else's code. aggregateList(df, by=list(seat=seat), FUN=list(winner=function(x) x$party[which.max(x$votes)], voteshare=function(x) max(x$votes)/sum(x$votes)))

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >