search for: rows

Displaying 20 results from an estimated 16661 matches for "rows".

Did you mean: roms
2011 Sep 09
3
Read a list of files into named R data.frames
...h reads all the files, but doesn't create the R objects in the global environment. What is missing here? for (i in 1:length(files)) { inp <- read.csv(file=files[i], header=TRUE) name <- sub(".csv", "", files[i]) cat("Read ", files[i], "\trows: ", nrow(inp), " cols: ", ncol(inp), "\n") eval(paste(name, "<- inp")) } Read Allstar.csv rows: 4475 cols: 3 Read AllstarFull.csv rows: 4676 cols: 8 Read Appearances.csv rows: 94157 cols: 20 Read AwardsManagers.csv rows: 57...
2009 May 09
2
a general way to select a subset of matrix rows?
Dear fellow R users, I can't figure out how to do a simple thing properly: apply an operation to matrix columns on a selected subset of rows. Things go wrong when only one row is being selected. I am sure there's a way to do this properly. Here's an example: # define a 3-by-4 matrix x > x <- matrix(runif(12),ncol=4) > str(x) num [1:3, 1:4] 0.568 0.217 0.309 0.859 0.651 ... # calculate column means for selected...
2008 Jul 01
1
[.data.frame speedup
Below is a version of [.data.frame that is faster for subscripting rows of large data frames; it avoids calling duplicated(rows) if there is no need to check for duplicate row names, when: i is logical attr(x, "dup.row.names") is not NULL (S+ compatibility) i is numeric and negative i is strictly increasing "[.data.frame" <-...
2011 May 25
1
rake task: uninitialized constant
I have this rake taks: CUSTOM_MONTHS = [nil, "GEN", "FEB", "MAR", "APR", "MAG", "GIU", "LUG", "AGO", "SET", "OTT", "NOV", "DIC"] def parse_date_string(date_string) begin day, month, year = date_string.split("-") Time.mktime(year, CUSTOM_MONTHS.index(month),
2013 Jan 22
2
Creating a Data Frame from an XML
...top <- xmlRoot (doc) xmlName (top) names (top) art <- top [["row"]] art ** *Output:* > art<row BRAND="GMC" NUM="1" YEAR="1999" VALUE="10000"/> This is where I am having difficulties. I am unable to "access" additional rows; ( i.e. <row BRAND="GMC" NUM="1" YEAR="1967" VALUE="PRICLESS" /> ) and I am unable to access the individual entries to actually create the data frame. The data frame I would like is as follows: BRAND NUM YEAR VALUE GMC 1 199...
2018 Apr 21
2
Check if row of dataframe is superset of any row in another dataframe.
Hi, I am looking for a way in which I can check if rows in 1 dataframe are present in another data frame in a unique way. A row in dataframe should be super set of any row in another dataframe. I can write a for loop for it, however, that will be inefficient. So, I am looking for an efficient way to do this in R. I have explained it with an example be...
2007 May 01
5
duplicate key violates unique constraint
I''ve run into an interesting issue. When setting up a table with data from a file (I''m doing this in a block). I find that I can''t create separate entries manually after the import. It complains about a duplicate primary key. I''ve tried Schedule.id += 1 but id= either isn''t defined or accessible in the class Here is my code:
2008 Jan 11
3
Date range queries return zero results
Hello, I am having trouble getting data ranges to work correctly. I am using the following command to load the db: index << {:title => row[7].to_i, :date => Date.strptime(row[3], ''%Y-%m-%d''), :page_id => row[5].to_i, :page => row[6].to_i, :content_type => row[1].to_i,
2008 Oct 30
1
row.names(data.frame(matrixWithDimnames)) depends on first rowname being "" or not. (PR#13230)
...then the row names of the input were carried into the output. I haven't had the time yet to make a fix for this, but the distinction between row.names[1] != or == "" comes from code in data.frame() itself (not as.data.frame.matrix): 81 if (missing(row.names) && nrows[i] > 0L) { 82 rowsi <- attr(xi, "row.names") 83 if (!(rowsi[[1L]] %in% "")) 84 row.names <- data.row.names(row.names, rowsi, 85 i) 86 } Why is that check there? Bill Dunlap TIBC...
2005 Oct 07
2
Some Ruby code help?
Hi, This isn''t related to Rails itself, but rather to Ruby. I''m trying to import a file into a database. The fields are separated by a ''|''. Everything seems to work fine, but after 64 rows are inserted, it starts mangling the field values. Would you take a look at the following code? require ''mysql'' def capitalize(str) str.downcase.gsub(/\b\w/) {|first| first.upcase } end def state(name, h) id = -1 h.query("SELECT id FROM states WHERE name = ...
2015 Mar 13
2
[PATCH] part-list: add support for show partition type
...as_m_opt) { - /* New-style parsing using the "machine-readable" format from - * 'parted -m'. - * - * lines[0] is "BYT;", lines[1] is the device line which we ignore, - * lines[2..] are the partitions themselves. Count how many. - */ - size_t nr_rows = 0, row; - for (row = 2; lines[row] != NULL; ++row) - ++nr_rows; - - r = malloc (sizeof *r); - if (r == NULL) { - reply_with_perror ("malloc"); - return NULL; + /* Old-style. Start at the line following "^Number", up to the + * next blank line. + *...
2008 Feb 16
2
NoMethodError... but its not a method!
Hi everyone, I am putting together an application in which each part of it was tested individually. Now that it is put together, I''m having problems... The one giving me problems is my "ImportController" which parses a CSV during post and puts it into my database. I have two separate CSV upload actions (one is for a bill called "bes" and the other from the provider
2009 Mar 30
2
which rows are duplicates?
I would like to know which rows are duplicates of each other, not simply that a row is duplicate of another row. In the following example rows 1 and 3 are duplicates. > x <- c(1,3,1) > y <- c(2,4,2) > z <- c(3,4,3) > data <- data.frame(x,y,z) x y z 1 1 2 3 2 3 4 4 3 1 2 3 I can't figure...
2009 Mar 30
2
which rows are duplicates?
I would like to know which rows are duplicates of each other, not simply that a row is duplicate of another row. In the following example rows 1 and 3 are duplicates. > x <- c(1,3,1) > y <- c(2,4,2) > z <- c(3,4,3) > data <- data.frame(x,y,z) x y z 1 1 2 3 2 3 4 4 3 1 2 3 I can't figure...
2007 Apr 06
2
Reading a csv file row by row
...a file, which is convenient, and when the same 'read' command is executed the next time, the next row of the same file will be read. I tried to replicate such row-by-row reading in R.I use scan( ) to do so with the "skip= xxx " option. It takes only seconds when the number of the rows is within 1000. However, it takes hours to read 10000 rows. I think it is because every time R reads, it needs to start from the first row of the file and count xxx rows to find the row it needs to read. Therefore, it takes more time for R to locate the row it needs to read. Is there a solution to...
2009 Jun 11
3
Matrix manipulation
Hello everyone, I have a couple of fairly simple questions (I hope) the answers to which I cannot find through the documentation at the moment. 1. I would like to delete the a row from a matrix if a certain elimination criterion is met. I am familiar with x <- x[-7,] (to remove row 7, for example). Are there any other means of removing an entire row? 2. Is there a single command that
2007 Mar 02
5
extracting rows from a data frame by looping over the row names: performance issues
...on row... } which could probably considered a very natural (and R'ish) way of doing it (but maybe I'm wrong and the real idiom for doing this is something different). The problem with this "idiomatic form" is that it is _very_ slow. The loop itself + the simple extraction of the rows (no computation on the rows) takes 10 hours on a powerful server (quad core Linux with 8G of RAM)! Looping over the first 100 rows takes 12 seconds: > system.time(for (key in row.names(dat)[1:100]) { row <- dat[key, ] }) user system elapsed 12.637 0.120 12.756 But if, instead...
2006 Apr 14
1
row.names in data.frame
We know from the White Book p.57 that the row names of a data frame `are never NULL and must be unique'. R documents that row.names() returns a character vector, and in R (much more so than on S) a long character vector of short unique strings is expensive to store (I saw 72 bytes/row on a 64-bit machine for 1:1e6). [Incidentally, in the White Book the index page nos are all off by one
2006 Mar 01
3
Optimization problem: selecting independent rows to maximize the mean
Dear R community, I have a dataframe with 500,000 rows and 102 columns. The rows represent spatial polygons, some of which overlap others (i.e., not all rows are independent of each other). Given a particular row, the first column contains a unique "RowID". The second column contains the "Variable" of interest. The remaining 100 co...
2008 Dec 22
3
row sum question
...aning that if the value is shown in the above row(s) already, the same value in the following row shouldn't be added into the sum. The result should be like this: row.sum [1] 2 1 0 1 And if a and c were swapped, the row.sum is 3 0 0 1 Second, I'd like to randomly reorder the rows, and repeat calculating row.sum again, for many times less than all combinations possible (4! In this case), kind of simulation, and store the results into a matrix. Thanks. Keun-Hyung [[alternative HTML version deleted]]