Displaying 20 results from an estimated 5000 matches similar to: "Compare two data sets"
2008 Mar 07
3
Combine two columns
Is there a way to combine two columns within a data frame?
Example data:
id snp AL1 AL2
1500 30 A B
1510 30 A A
1520 30 A B
This is what I would like:
indv snp AL1AL2
1500 30 AB
1510 30 AA
1520 30 AB
Any help is greatly appreciated.
Alysta
2008 May 11
1
Finding unmatched data between two dataframe using several factors
Hi R users
I am trying to find unmatched data from two dataframes. I would like to
find unmatched data based on several factors. For the following data:
dat1 <- data.frame(x = paste("A", 1:6, sep=""),
y = c("andy","bob","ciaran","dan", "eion",
"fred"))
dat1
dat2
2010 Mar 22
1
Replacing elements of list
Dear all,
I have following two list object, both are basically collection of matrices
:
dat1 <- matrix(rnorm(25*6), ncol=6)
dat1 <- split(dat1, seq(5,25,by=5))
dat1 <- lapply(dat1, matrix, ncol=6)
dat2 <- matrix(rnorm(25*4), ncol=4)
dat2 <- split(dat2, seq(5,25,by=5))
dat2 <- lapply(dat2, matrix, ncol=4)
Now I want to replace last 4 columns of each matrix at "dat1"
2012 Jun 07
3
conditional statement to replace values in dataframe with NA
Hello and thanks for helping.
#some data
L3 <- LETTERS[1:3]
dat1 <- data.frame(cbind(x=1, y=rep(1:3,2), fac=sample(L3, 6, replace=TRUE)))
#When x==1 and y==1 I want to replace the 1 values with NA
#I can select the rows I want:
dat2<-subset(dat1,x==1 & y==1)
#replace the 1 with NA
dat2$x<-rep(NA,nrow(dat2)
dat2$y<-rep(NA,nrow(dat2)
#select the other rows and rbind
2012 Jul 01
2
list to dataframe conversion-testing for identical
HI R help,
I was trying to get identical data frame from a list using two methods.
#Suppose my list is:
listdat1<-list(rnorm(10,20),rep(LETTERS[1:2],5),rep(1:5,2))
#Creating dataframe using cbind
dat1<-data.frame(do.call("cbind",listdat1))
colnames(dat1)<-c("Var1","Var2","Var3")
#Second dataframe conversion
2010 Mar 30
2
Need help to split a given matrix is a "sequential" way
I need to split a given matrix in a sequential order. Let my matrix is :
> dat <- cbind(sample(c(100,200), 10, T), sample(c(50,100, 150, 180), 10,
> T), sample(seq(20, 200, by=20), 10, T)); dat
[,1] [,2] [,3]
[1,] 200 100 80
[2,] 100 180 80
[3,] 200 150 180
[4,] 200 50 140
[5,] 100 150 60
[6,] 100 50 60
[7,] 100 100 100
[8,] 200 150 100
[9,]
2013 May 07
4
create unique ID for each group
Hey All,
I have a dataset(dat1) like this:
ObsNumber ID Weight
1 0001 12
2 0001 13
3 0001 14
4 0002 16
5 0002 17
And another dataset(dat2) like this:
ID Height
0001 3.2
0001 2.6
0001
2005 Dec 29
1
S4 classes: referencing slots with other slots
For those who suggest other ways to do this, I ALREADY HAVE ANOTHER
DESIGN SOLUTION, DESCRIBED AT THE END.
That being said, I want to know if it's possible to reference a slot
in an S4 class from another slot, i.e. I'd like to have the "self.*"
semantics of Python so that I can reuse a slot. That is, for various
reasons it would be nice to be able to do something like:
2013 Sep 02
1
R dataframe and looping help
HI,
You may try this:
dat1<- read.table(text="
CustID TripDate Store Bread Butter Milk Eggs
1 2-Jan-12 a 2 0 2 1
1 6-Jan-12 c 0 3 3 0
1 9-Jan-12 a 3 3 0 0
1 31-Mar-13 a 3 0 0 0
2 31-Aug-12 a 0 3 3 0
2 24-Sep-12 a 3 3 0 0
2 25-Sep-12 b 3 0 0 0
",sep="",header=TRUE,stringsAsFactors=FALSE)
dat2<- dat1[,-c(1:3)]
res<- lapply(seq_len(ncol(dat2)),function(i)
2007 Jun 23
2
Names of objects passed as ... to a function?
Dear list,
I have a function whose first argument is '...'. Each element of '...'
is a data frame, and there will be at least 2 data frames in '...'. The
function processes each of the data frames in '...' and returns a list,
whose components are the processed data frames. I would like to name the
components of this returned list with the names of the original data
2013 Jan 04
2
Can you help me please
HI Fares,
You could try this:
dat1<- read.table(text="
date????? donation
3jan2003?? 20235
4jan2003?? 25655
5jan2003?? 225860
6jan2003?? 289658
7jan2003?? 243889
8jan2003?? 244338
9jan2003?? 243889
",sep="",header=TRUE,stringsAsFactors=FALSE)
The post is not very specific as to what you need.? I hope this works for you.
library(xts)
2004 Jul 16
3
sas to r
I would be incredibly grateful to anyone who'll help me translate some
SAS code into R code.
Say for example that I have a dataset named "dat1" that includes five
variables: wshed, site, species, bda, and sla. I can calculate with the
following SAS code the mean, CV, se, and number of observations of
"bda" and "sla" for each combination of
2013 Mar 22
3
Distance calculation
Hi Elisa,
I hope this is what you wanted.
dat1<-read.csv("peaks.csv",sep=",")
#Subset
dat2<-dat1[1:5,]
res1<-do.call(cbind,lapply(seq_len(nrow(dat2)),function(i) do.call(rbind,lapply(split(rbind(dat2[i,],dat2[-i,]),1:nrow(rbind(dat2[i,],dat2[-i,]))), function(x) {x1<-rbind(dat2[i,],x);
2009 Nov 21
3
"subset" or "condition" as argument to a function
Dear Rxperts!
I was wondering if it is possible to write a function which can take in
argument of a subset or condition.. Of course, I am aware of the alternate
methods like coplot, par.plot, xyplot etc... I am specifically interested in
using conditions/subsets with "plot"..
A simple fragmented example is shown here..
pltit <- function(y,x,dat,dat1,dat2,sbst) {
plot(y~x, data=dat,
2010 Jul 29
1
Crash report: projection pursuit & predict
Folks,
The projection pursuit regression function in the base R seems to crash when the optimization level is set to zero, i.e. the initial ridge terms are accepted without refitting. I encountered this problem in an out-of-sample prediction exercise using predict. But further investigation suggests the issue is with the ppr fit and predict just sppeds up the crash. The other optlevels seem to be
2008 May 06
3
Spatial join between two datasets using x and y co-ordinates
Hi R users
I am trying to create a spatial join between two datasets.
The first data set is large and contains descriptive data including x
and y co-ordinates.
The second dataset is small and has been selected spatially. The only
data contained within the second dataset is the x and y coordinates only
i.e. no descriptive data.
The aim of a join made between the two datasets is to select
2009 Jun 23
2
Partitioning matrix
Let say, I have following matrix :
dat <- matrix(rnorm(40), 2, 20)
Now I want to partition this like this :
dat1 <- dat[1,]
dat2 <- dat[2,]
But point is that, dat1 and dat2 become vector object. How can I force them
to be matrix object with dimension (1x20) ?
Thanks,
--
View this message in context: http://www.nabble.com/Partitioning-matrix-tp24161021p24161021.html
Sent from the R
2012 Aug 31
3
fitting lognormal censored data
Hi ,
I am trying to get some estimator based on lognormal distribution when we have left,interval, and right censored data. Since, there is now avalible pakage in R can help me in this, I had to write my own code using Newton Raphson method which requires first and second derivative of log likelihood but my problem after runing the code is the estimators were too high. with this email ,I provide
2009 Aug 07
1
RMySQL - overwrite record, not table
Hi, useR-
In RMySQL, how do I overwrite records? (equivalent to "replace" query).
For example, suppose that dat2 is a newer data.frame than dat1.
con <- dbConnect(MySQL())
res <- dbWriteTable(con, "DBname", dat1, row.names=F, append=T, replace=T)
res <- dbWriteTable(con, "DBname", dat2, row.names=F, append=T, replace=T)
This would not update/replace the
2011 May 17
1
Subsetting depth profiles based on maximum depth by group with plyr
Hello,
Apologies for a similar earlier post. I didn't include enough details in
that one.
I am having a little trouble subsetting some data based on a grouping
variable. I am using an instrument that does depth profiles of a water
column. The instrument records on the way down as well as the way up. So
thanks to an off-list reply I can subset the data so that all data collected
at the