Displaying 10 results from an estimated 10 matches similar to: "noob requesting help"
2012 Apr 03
2
Grouping and/or splitting
I have a dataframe imported from csv file below:
Houseid,Personid,Tripid,taz
1,1,1,4
1,1,2,7
2,1,1,96
2,1,2,4
2,1,3,2
2,2,1,58
There are three groups identified based on the combination of first and
second columns. How do I split this data frame?
I tried
aa <- split(inpfil, inpfil[,1:2])
but it has problems.
Output desired is
aa[1]
Houseid,Personid,Tripid,taz
1,1,1,4
1,1,2,7
aa[2]
2006 May 10
3
Unique?
Hello,
I have sample data set that looks like:
YEAR MONTH DAY CONTINUE SPL TIMEFISH
TIMEUNIT AREA COUNTY DEPTH DEPUNIT GEAR TRIPID
CONVUNIT
1992 1 26 1 SP0073928 8
H 7 25 4 NA 1000000
02163399054 161
1992 1 26 1 SP0073928 8
H 7 25 4 NA 1000000
02163399054 8
1992 1 26 2 SP0004228 8
H 7 25 4 NA 1000000
02163399054 161
1992 1 26 2 SP0004228 8
H 7 25 4 NA 1000000
02163399054 8
1992
2006 May 03
4
Aggregate?
Hello,
I have a data set with a grouping variable (TRIPID) and several other
variables. TRIPID is repeated in some areas and I would like to use a
function like aggregate to sum the variable UNITS according to TRIPID.
However I would also like to retain the other variables as they are in
the data set with the new summed TRIPID.
So what I have is something like this:
YEAR MONTH DAY
2006 May 03
4
Aggregate?
Hello,
I have a data set with a grouping variable (TRIPID) and several other
variables. TRIPID is repeated in some areas and I would like to use a
function like aggregate to sum the variable UNITS according to TRIPID.
However I would also like to retain the other variables as they are in
the data set with the new summed TRIPID.
So what I have is something like this:
YEAR MONTH DAY
2012 Jul 13
1
R combining many vectors of predictable name into one date frame
G'day R (power) users,
I have a many vectors, called:
ib1
ib2
ib3
...
ib100
and I would like them in one data frame (df) such that:
> df
ib1 ib2 ib3 ib4 ..... ib100
x x x x x
x x x x x
x x x x x
I have attempted:
hold.list <- list(objects(pattern="ib"))
df <- data.frame(hold.list)
but that
2008 Oct 30
1
Trying to "expand" some data - Newbie needs help
I want to calculate "expansion factors" for elements in my dataframe
based on a 2-d cross classification. Since I'll have "missing values"
(many combinations will have no record) I'll need a second "expansion
factor" for each "row". I've included my "work to date" below, but I'm
not very close to getting this right.
My
2012 Apr 03
1
Compare by row and insert previous row value (Or non Time Series Lag)
I have the following sample dataset (CSV input here:http://goo.gl/YR8LP.
CSV output here: http://goo.gl/EFCC8) which I want to transform as follows.
For each person in a household I want to create two new variables OrigTAZ
and DestTAZ. It should take the value in TripendTAZ and put that in
DestTAZ. For OrigTAZ it should put value of TripendTAZ from the previous
row. For the first trip of every
2013 Mar 13
3
Assign the number to each group of multiple rows
Dear R users,
My data have repeating "beh" parameter : 1 or 2 - type of animal behavior
in subsequent locations. I need to assign unique number to each sequence of
locations.
My data is:
>data=data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2))
>attach(data)
>data
row beh
1 1 1
2 2 1
3 3 1
4 4 2
5 5 2
6 6 2
7 7 1
8
2006 May 16
3
subset
Hello everyone,
I have a large dataset (x) with some rows that have duplicate variables
that I would like to remove. I find which rows are the duplicates with
X1<-which(duplicated(x)). That gives me the rows with duplicated
variables. Now, how can I remove just those rose from the original data
frame. I think I can create a new data frame without the duplicates
using subset. I have tried:
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)