Displaying 20 results from an estimated 4000 matches similar to: "generating a bar chart with two axis for co-linear variable"
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
2008 Mar 25
2
Compare two data sets
I would like to compare two data sets saved as text files (example below) to determine if both sets are identical(or if dat2 is missing information that is included in dat1) and if they are not identical list what information is different between the two sets(ie output "a1", "a3" as the differing information). The overall purpose would be to remove "a1" and
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
2013 Mar 27
9
conditional Dataframe filling
Hi everyone:
This may be trivial but I just have not been able to figure it out.
Imagine the following dataframe:
a b c d
TRUE TRUE TRUE TRUE
FALSE FALSE FALSE TRUE
FALSE TRUE FALSE FALSE
I would like to create a new dataframe, in which TRUE gets 0 but if
false then add 1 to the cell to the left. So the results for the
example above should be something like:
a b c
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)
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"
2013 Apr 29
4
expanding a presence only dataset into presence/absence
Hello,
I'm working with a very large dataset (250,000+ lines in its' current form)
that includes presence only data on various species (which is nested within
different sites and sampling dates). I need to convert this into a dataset
with presence/absence for each species. For example, I would like to expand
"My current data" to "Desired data":
My current data
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
2012 Aug 13
4
if else elseif for data frames
Hi all,
It seems like I cannot use normal 'if' for data frames. What would be the
best way to do the following.
if data$col1='high'
data$col2='H'
else if data$col1='Neutral'
data$col2='N'
else if data$col='low'
data$col2='L'
else
#chuch a warning?
Note that col2 was not an existing column and was newly assigned for this
2013 Apr 12
2
split date and time
Hi R experts,
For example I have a dataset looks like this:
Number TimeStamp Value
1 1/1/2013 0:00 1
2 1/1/2013 0:01 2
3 1/1/2013 0:03 3
How can I split the "TimeStamp" Column into two and return a new table like
this:
Number Date Time Value
1 1/1/2013 0:00 1
2 1/1/2013 0:01 2
3 1/1/2013 0:03 3
Thank!
[[alternative HTML version
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,]
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 Sep 02
1
Convert chr pieces to numbers that have specific values defined by 2 vectors
Dear all,
I think this is an easy task, but I don't know how to do it. Specifically, I have 69 columns with 300.000 rows. In each cell there is a code like
"2E3", "4RR", etc.
I now have a list that replaces this with values, e.g.,
old new
2E3 5
4RR 3
etc.
The list ist about 1600 rows long, so also to extensive for normal solutions
Do you how to do that? It would
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
2012 Jul 24
5
First value in a row
Hi.
This is likely a trivial problem but have not found a solution.
Imagine the following dataframe:
Lat Lon x1 x2 x3
01 10 NA NA .1
01 11 NA .2 .3
01 12 .4 .5 .6
I want to generate another column that consist of the first value in
each row from columns x1 to x3. That is
NewColumn
.1
.2
.4
Any input greatly appreciated,
Thanks,
Camilo
Camilo Mora, Ph.D.
2012 Oct 04
3
R combining vectors into a data frame but without a continuous common variable
Hello,
I have two different files which I'd like to combine to make one data frame
but I've no idea how to do it! The first file has two columns; one is the
date, the following is a binary code for debris flow events. Then my other
file has also two columns; the date and then precipitation data.
The thing is, is that the two date columns don't all contain the same dates.
The binary
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 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)
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
2008 Sep 17
5
Loop on vector name
[My previous message rejected, therefore I am sending same one with some modification]
I have 3 vectors with object name : dat1, dat2, dat3
Now I want to create a loop, like :
for (i in 1:3)
{
cat(sd(dati))
}
How I can do this in R?
Regards,