similar to: Inserting a blank row to every other row

Displaying 20 results from an estimated 5000 matches similar to: "Inserting a blank row to every other row"

2016 Apr 24
2
Inserting a blank row to every other row
Well, something like this would work (there may be slicker solutions): > z <- data.frame(a=1:3,b = letters[1:3]) > i <- seq_len(nrow(z)) *2 > z <-rbind(z,z) > z[i, ] <- matrix(NA, nr=nrow(z),nc=ncol(z)) > z a b 1 1 a 2 NA <NA> 3 3 c 4 NA <NA> 5 2 b 6 NA <NA> But I agree with you that there is probably a way to handle the underlying
2016 Apr 24
0
Inserting a blank row to every other row
Hi Saba, I don't know how to do what you want and I also cannot see why. If you describe what you hope to achieve there might be a different solution. Best wishes Ulrik Saba Sehrish via R-help <r-help at r-project.org> schrieb am So., 24. Apr. 2016 14:04: > Hi > > I need to insert a blank row after every row in R data frame. I have > achieved it through: > > >
2016 Apr 24
0
Inserting a blank row to every other row
Oh, sorry, I just realized that I messed up the indicing. Here is the correct way: > z <- data.frame(a=1:3,b = letters[1:3]) > i <- seq_len(nrow(z)) > z<-z[rep(i,e=2),] > z[2*i, ] <- matrix(NA, nr=nrow(z),nc=ncol(z)) > z Still doubt that this is a good idea, though. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along
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
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 >
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 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 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 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 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. //
2016 Apr 24
3
Dividing rows in groups
Hi I have two data frames as shown below (second one is obtained by aggregating rows of similar IDs in df1.). They both have similar number of columns but rows of df2 are lesser than rows of df1. df1: ID A B 1 1 2 1 0 3 2 5 NA 2 1 3 3 1 4 4 NA NA 4
2016 Apr 22
2
Finding Highest value in groups
Hi I have two columns in data frame. First column is based on "ID" assigned to each group of my data (similar ID depicts one group). From second column, I want to identify highest value among each group and want to assign the same ID to that highest value. Right now the data looks like: ID Value 1 0.69 1 0.31 2 0.01 2 0.99 3 1.00 4 NA 4
2016 Apr 22
0
Finding Highest value in groups
Assuming your dataframe is in a variable x: > require(dplyr) > x %>% group_by(ID) %>% summarise(maxVal = max(Value,na.rm=TRUE)) On Fri, 2016-04-22 at 13:51 +0000, Saba Sehrish via R-help wrote: > Hi > > > I have two columns in data frame. First column is based on "ID" assigned to each group of my data (similar ID depicts one group). From second column, I
2016 Apr 10
1
working with unequal rows
Hi I have a data frame with rows specifying companies (codes are assigned to companies) and columns specify months (monthly data). The data is based on male (M) and female (F) information for each month. Following is an example of how my data looks like: 01 02 03 04 001 M M M na 001 F M M M 002 M na F F 003 F F F M 003 F F M na 003 M
2017 Sep 12
2
Load R data files
Dear All: It was saved, but there was a space somewhere. So it works for me now. I do have another similar problem. I saved an R data file save(datahs0csv,file=" F:\Fall_2017\5-STA574\2-Notes\1-R\1-R_new\chapter4-Entering_Data/datahs0csv2 .rda") *The new R data file "*datahs0csv2.rda*" is in the directory.* I tried to load the file "" to R, but I got an error
2010 Sep 04
3
Levels in returned data.frame after subset
Dear List, When I subset a data.frame, the levels are not re-adjusted (see example). Why is this? Am I missing out on some basic stuff here? Thanks Ulrik > m <- data.frame(gender = c("M", "M","F"), ht = c(172, 186.5, 165), wt = c(91,99, 74)) > dim(m) [1] 3 3 > levels(m$gender) [1] "F" "M" > s <- subset(m, m$gender ==
2017 Aug 04
4
define a list with names as variables
Hello, I'm having troubles defining a list where names are variables (of type character). Like this, which gives "foo" instead of "world" (the way I meant it is that "world" is the value of the variable foo). Any hint? > f <- function(foo, bar) { list(foo = bar) } > x <- f("hello", "world") > names(x) [1] "foo"
2017 Sep 12
0
Load R data files
The object you load has the same name as the object you saved. In this case datahs0csv and not the name of the file sans .rda On Di., 12. Sep. 2017, 21:26 AbouEl-Makarim Aboueissa < abouelmakarim1962 at gmail.com> wrote: > Dear All: > > > It was saved, but there was a space somewhere. So it works for me now. > > I do have another similar problem. > > I saved an R
2017 Aug 26
0
Find maxima of a function
Please keep the list in cc. Sorry, it didn't work as expected. Maybe someone else have an appropriate solution. Best, Ulrik On Sa., 26. Aug. 2017, 12:57 niharika singhal <niharikasinghal1990 at gmail.com> wrote: > Hi > > Thanks for you mail, > I really appreciate your time on my problem > > I have posted this problem on > > >
2017 Jul 13
2
Help with R script
Using Ulrik?s example data (and assuming I understand what is wanted), here is what I would do: ex.dat <- c("FName: fname1", "Fval: Fval1.name1", "Fval: ", "FName: fname2", "Fval: Fval2.name2", "FName: fname3") tst <- data.frame(x = ex.dat, stringsAsFactors=FALSE) sp <- strsplit(tst$x, ':', fixed=TRUE) chk <-