similar to: Trying to "expand" some data - Newbie needs help

Displaying 14 results from an estimated 14 matches similar to: "Trying to "expand" some data - Newbie needs help"

2008 Nov 05
1
How do I read a text (.csv) file to match a matrix/cross tab? (Object confusion??)
I'm having a problem reading data to set control totals for a dataframe. I want to adjust a dataframe based on a 2-d table of values, which I get by using : > CurrentX1Sums <- as.matrix(xtabs(~tripid_nu+lineon, data=SurveyData)) > CurrentX2Sums <- apply(CurrentX1Sums, 1, sum) I've created a .csv file with new (target) sums that looks like this: tripid_nu Warner
2008 Oct 31
0
Why are these different?
I want to import some "target values" to normalize elements of a dataframe. I'm summarizing the existing totals using as.matrix(xtabs(~tripid_nu+lineon, data=SurveyData)) and reading a .csv table of target values. I can't even get them to list out as similar data items. My idea is to do something like this, but I don't know how to do it in R
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
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 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
2008 Oct 22
0
newbie Syntax questions: Re-Calculating expansion factors
I have a dataframe with many hundreds of survey records containing: tripid_nu, lineon, MuchOtherData, X1, X2, X3, X4 tripid_nu = identifier for each "Trip" {E.g. for EB MTA-901 leaving the first stop at 07:24} lineon = identifier for each of the stop locations Where X1 is the ratio (for each trip/stop combination) of some target number to the number of records.
2012 Jun 08
1
noob requesting help
I'm fairly new to R and still learning how to use it. I could really use some help with the following problem. I have a huge .csv file containing thousands of measurements on 34 different birds. Measurements include longitude, latitude, altitude, speed, time, etc. All birds have a different number (ranging from 121 to 542). All measurements have a tripID (1 for the first trip of every bird, 2
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
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:
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 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)
2008 Aug 18
1
Survey Design / Rake questions
I'm trying to learn how to calibrate/postStratify/rake survey data in preparation for a large survey effort we're about to embark upon. As a working example, I have results from a small survey of ~650 respondents, ~90 response fields each. I'm trying to learn how to (properly?) apply the aforementioned functions. My data are from a bus on board survey. The expansion in the