similar to: Substitute NAs in a data frame

Displaying 20 results from an estimated 4000 matches similar to: "Substitute NAs in a data frame"

2018 Jan 27
0
Newbie wants to compare 2 huge RDSs row by row.
Hi Marsh, An RDS is not a data structure such as a data.frame. It can be anything. For example if I want to save my objects a, b, c I could do: > saveRDS( list(a,b,c,), file="tmp.RDS") Then read them back later with > myList <- readRDS( "tmp.RDS" ) Do you have additional information about your "RDSs" ? Eric On Sat, Jan 27, 2018 at 6:54 AM, Marsh Hardy
2018 Jan 27
0
Newbie wants to compare 2 huge RDSs row by row.
Hi Guys, I apologize for my rank & utter newness at R. I used summary() and found about 95 variables, both character and numeric, all with "Length:368842" I assume is the # of records. I'd like to know the record number (row #?) of any record where the data doesn't match in the 2 files of what should be the same output. Thanks in advance, M. //
2018 Jan 27
3
Newbie wants to compare 2 huge RDSs row by row.
Also, it will be easier to provide helpful information if you'd describe what in your data you want to compare and what you hope to get out of the comparison. Best wishes, Ulrik Eric Berger <ericjberger at gmail.com> schrieb am Sa., 27. Jan. 2018, 08:18: > Hi Marsh, > An RDS is not a data structure such as a data.frame. It can be anything. > For example if I want to save my
2018 Jan 27
2
Newbie wants to compare 2 huge RDSs row by row.
If your two objects have class "data.frame" (look at class(objectName)) and they both have the same number of columns and the same order of columns and the column types match closely enough (use all.equal(x1, x2) for that), then you can try which( rowSums( x1 != x2 ) > 0) E.g., > x1 <- data.frame(X=1:5, Y=rep(c("A","B"),c(3,2))) > x2 <-
2018 Jan 28
0
Newbie wants to compare 2 huge RDSs row by row.
Cool, looks like that'd do it, almost as if converting an entire record to a character string and comparing strings. -- M. B. Hardy, statistician work: Applied Research Associates, S. E. Div. 8537 Six Forks Rd., # 6000 / Raleigh, NC 27615-2963 (919) 582-3329, fax: 582-3301 home: 1020 W. South St. / Raleigh, NC 27603-2162 (919) 834-1245
2018 Jan 28
2
Newbie wants to compare 2 huge RDSs row by row.
The anti_join from the package dplyr might also be handy. install.package("dplyr") library(dplyr) anti_join (x1, x2) You can get help on the different functions by ?function.name(), so ?anti_join() will bring you help - and examples - on the anti_join function. It might be worth testing your approach on a small subset of the data. That makes it easier for you to follow what happens
2018 Jan 28
1
Newbie wants to compare 2 huge RDSs row by row.
Thanks, I think I've found the most succinct expression of differences in two data.frames... length(which( rowSums( x1 != x2 ) > 0)) gives a count of the # of records in two data.frames that do not match. // ________________________________________ From: Henrik Bengtsson [henrik.bengtsson at gmail.com] Sent: Sunday, January 28, 2018 11:12 AM To: Ulrik Stervbo Cc: Marsh Hardy ARA/RISK;
2018 Jan 28
0
Newbie wants to compare 2 huge RDSs row by row.
The diffobj package (https://cran.r-project.org/package=diffobj) is really helpful here. It provides "diff" functions diffPrint(), diffStr(), and diffChr() to compare two object 'x' and 'y' and provide neat colorized summary output. Example: > iris2 <- iris > iris2[122:125,4] <- iris2[122:125,4] + 0.1 > diffobj::diffPrint(iris2, iris) < iris2 >
2010 Mar 28
0
Preserving both yearmon and numeric data in an xls object
Hi R gourmets, I am trying to convert an HTML table into an xts object. The table has six columns, with the data of interest in a single row with each cell containing a long, \n-delimited character string. Initially, I work with these strings as elements in a list. This is necessary because the strings in each cell do not translate into a regular matrix with equal-length columns. Once I fix
2010 May 04
2
read.table: skipping trailing delimiters
Hi, I am trying to read a tab-delimited file that has trailing tab delimiters. It's a simple file with two legitimate fields. I'm using the first as row.names, and the second should be the only column in the resulting data frame. Initially, R was filling the last column with NA's, but I was able to stop that by setting
2006 Jun 12
2
Chapters
I'm surprised this isn't a FAQ, but I searched all over and could not find a reference to it. Chambers (1998) makes repeated references to "Chapters" in S (e.g., p. 6), but I can find no reference to "Chapters" in R. Since Chapters were not used in earlier versions of S, I'm wondering if R uses them or not. If it does, how does one get them to work? I've
2010 Jul 27
2
Introductory statistics and introduction to R
Hi, I have a bright, diligent second-year graduate student who wants to learn statistics and R and will, in effect, be taking a tutorial from me on these subjects. (If you've seen some of my questions on this list, please don't laugh.) As an undergrad he majored in philosophy, so this will be his first foray into computer programming and statistics. I'm thinking of having him use
2018 Jan 27
2
Newbie wants to compare 2 huge RDSs row by row.
Each RDS is 40 MBs. What's a slick code to compare them row by row, IDing row numbers with mismatches? Thanks in advance. //
2010 Apr 04
4
ggplot2 geom_rect(): What am I missing here
Hi R fans, As a newbie following the five-hour rule (after hitting my head against the wall for five hours, post to this list), I am appealing for some help understanding geom_rect() in ggplot2. What I want to do is very simple. I want to generate a plot of rectangles. Each one represents a business cycle. The x-values will be pairs representing the start and end of each cycle. The y-values
2010 May 04
1
Flushing print buffer
Hello, I have a function with these lines: test <- function(object,...){ cat("object: has ",nrow(object),"labels\n") cat("Head:\n") head(object,...) cat("\nTail:\n") tail(object,...) } If I feed it a data frame object, it only prints out the tail part. If I comment out the last two lines of
2010 May 03
2
Hierarchical factors
Hello, Hierarchical factors are a very common data structure. For instance, one might have municipalities within states within countries within continents. Other examples include occupational codes, biological species, software types (R within statistical software within analytical software), etc. Such data structures commonly use hierarchical coding systems. For example, the 2007 North
2010 Mar 02
1
Reading data file with both fixed and tab-delimited fields
Hello R wizards, What is the best way to read a data file containing both fixed-width and tab-delimited files? (More detail follows.) _*Details:*_ The U.S. Bureau of Labor Statistics provides local area unemployment statistics at ftp://ftp.bls.gov/pub/time.series/la/, and the data are documented in the file la.txt <ftp://ftp.bls.gov/pub/time.series/la/la.txt>. Each data file has five
2010 Mar 18
1
Do colClasses in readHTMLTable (XML Package) work?
Hi, I can't get the colClasses option to work in the readHTMLTable function of the XML package. Here's a code fragment: require("XML") doc <- "http://www.nber.org/cycles/cyclesmain.html" table <- getNodeSet(htmlParse(doc),"//table") [[2]] # The main table is the second one because it's embedded in the page table. xt
2010 Apr 02
1
Plots don't update with xlab, etc. What am I doing wrong.
Hi, I've been struggling with this problem the last few days and finally discovered it's happening at a very fundamental level. Going through Stephen Turner's tutorial on ggplot2, I entered these base graphics commands: > with(diamonds, plot(carat,price)) > with(diamonds, plot(carat,price), xlab="Weight in Carats", ylab="Price in USD",
2015 May 04
2
Define replacement functions
Hello I tried to define replacement functions for the class "mylist". When I test them in an active R session, they work -- however, when I put them into a package, they don't. Why and how to fix? make_my_list <- function( x, y ) { return(structure(list(x, y, class="mylist"))) } mylist <- make_my_list(1:4, letters[3:7]) mylist mylist[['x']] <- 4:6