similar to: Calculating difference between values in data frame based on separate column

Displaying 20 results from an estimated 10000 matches similar to: "Calculating difference between values in data frame based on separate column"

2011 Oct 20
1
Applying function with separate dataframe (calibration file) supplying some inputs
Hello, I am not entirely sure the subject line captures what I am trying to do, but hopefully this description of the problem will help folks to see my challenge and hopefully offer constructive assistance. I have an experimental setup where I measure the decrease in oxygen in small vials as an organism, such as an oyster, consumes the oxygen. Each vial is calibrated before the experiment and
2011 Aug 23
3
Linear Regression with 2 grouping variables
Hi all, I have a data set that looks a bit like this. feed1 RFU Site Vial Time lnRFU 1 44448 1 1 10 10.702075 2 47521 1 1 20 10.768927 3 42905 1 1 30 10.66674 4 46867 1 1 40 10.755069 5 42995 1 1 50 10.668839 6 43074 1 1 60 10.670675 7 41195 1 1 70 10.626072 8 47090 1 2 10 10.759816 9 48100 1
2004 Aug 03
1
(Lattice) How to improve the readability of a bwplot, i.e. separating groups somehow
Hi all, first of all thanks for the answer to my previous question on lattice some time ago. In particular to Patrick Connolly for advices on netiquette (I hope this time I'm doing right....) and to Deepayan Sarkar fro the help on lattice. Now, my nowaday problem. Please consider the following mydf<-cbind.data.frame( RESPONSE = c(rnorm(9,rep(2:4,each=3),10),
2004 Oct 26
1
indexing within the function "aggregate"
Hi all, I'm trying to work out the following problem, but I can't imagine how. I have the following (much reduced & oversimplified) dataset My.df <- cbind.data.frame(PPM=c(15.78, 15.81, 15.87, 15.83, 15.81, 15.84, 15.91, 15.90, 15.83, 15.81, 15.93, 15.83, 15.70, 15.92, 15.76, 15.81, 15.91, 15.75, 15.84, 15.86, 15.82, 15.79,
2003 May 13
1
assessing the fit of a LME model
Dear All, I would like to ask a couple of questions on a LME model. I tested 4 selection lines at 4 food concentrations against a standard competitor stock. I had 3 replicate cages per selection line. In each cage I have 10 vials. I counted the number of wild type flies and competitor stock emerging in each vial. My main question is: is there any difference between selection lines? I did fit
2010 Apr 21
1
Degrees of Freedom Not Allocated to Residuals in Reduced Model
##I am trying to test for fixed factor main effects in an unbalanced mixed effects model but when I fit the reduced model for "mic" factor effects, the extra degrees of freedom are being allocated to a nested term rather than the residuals. The model has inc, mic and spp are independent variables and vial nested within spp. inc and spp are already coded as factors since they were
2011 Feb 26
1
Transform a dataset from long to wide using reshape2
I seem to be running into the same problem reported in https://stat.ethz.ch/pipermail/r-help/2010-November/258265.html I cannot seem to transform a dataset from long to wide using reshape2. Clearly I am missing something very simple but a look at the manual and the reshape paper in JSS does not suggest anything. Any advice would be welcome ===========================load
2011 Sep 09
4
reshape data from long to wide format
This is my reproducible example: example<-structure(list(SENSOR = structure(1:6, .Label = c("A", "B", "C", "D", "E", "F"), class = "factor"), VALUE = c(270, 292.5, 0, 45, 247.5, 315), DATE = structure(1:6, .Label = c(" 01/01/2010 1", " 01/01/2010 2", " 01/01/2010 3", " 01/01/2010
2012 Nov 17
3
Reshaping a dataframe
Seems like this should be easy but I'm struggling a bit. How do I rearrange a data frame to go from the first one to the second shown below ? State Date lbs TX 200701 400 TX 200702 650 TX 200703 950 TX 200704 1000 FL 200701 200 FL 200702 300 FL 200703 500 FL 200704 333 NJ 200701 409 NJ 200702 308 NJ 200703 300 NJ 200704 800 Date TX FL NJ 200701 400 200 409 200702 650
2011 Aug 02
2
Data frame to matrix - revisited
Hi, I've tried to look through all the previous related Threads/posts but can't find a solution to what's probably a simple question. ? I have a data frame comprised of three columns e.g.: ? ID1?ID2?Value a?b?1 b?d?1 c?a?2 c?e?1 d?a?1 e?d?2 ? I'd like to convert the data to a matrix i.e.: ? ?a b c d e a n/a 1 2 1 n/a b 1 n/a n/a 1 n/a? c 2 n/a n/a n/a 1 d 1 1 n/a n/a 2 e n/a n/a 1
2011 Aug 08
1
Help on reshape2 data frame rearrangement
Dear help list: I am trying to reshape a data frame from long to wide format and with a reduced variable list using reshape2. The original data frame format is: Site Obs_no LengthSite 1 Obs 1 10Site 1 Obs 2 13Site 1 Obs 3 14.........Site 2 Obs 1 5Site 2 Obs 2 7Site 2 Obs 3 9 Site and Obs_no are factors and Length is a numeric variable. There are 15
2011 Feb 23
1
Fwd: Re: sum data from data.frame in a matrix
Hi Dennis, Thanks for your quick response and sorry for not being clear. That helped, but I need an actual matrix of e.g., 12 x 12 and those functions give me a matrix with only the "filled" locations. I need a 12 by 12 matrix with sums (0 if there's not data and the actual sum where there is) as follows: 1 2 3 4 5 6 7 8 9 10 11 12 1 0 0 0 . . . . . . 0 0 0 2 0 0 0 . 3 0
2011 Feb 03
3
R Data Manipulation - Transposing Data by a Given Column, Like User_ID
Hello, I'd like to transpose data to create an analysis-friendly dataframe. See below for an example, I was unable to use t(x) and I couldn't find a function with options like PROC TRANSPOSE in SAS. The ideal solution handles variable quantities of SITE - but beggars can't be choosers. :-) Thank you in advance, Mike ## INPUT DATA USER_ID<-c(1,1,1,2,2,2,3,3,4) SITE
2011 May 20
1
Factors to Columns
> str(data) 'data.frame': 250 obs. of 3 variables: $ student: chr "A" "B" "C" "D" ... $ data : num 20.2 20.4 22.5 22.1 23.3 ... $ param : Factor w/ 4 levels "AGE","SCHOOL",..: 1 1 1 1 1 1 1 1 1 1 Hi , i would like to split the dataframe so that each level of param is a column At the end it should look like
2011 Oct 27
2
Syntax Check: rshape2 melt()
This is my first excursion into using reshape2 and I want to ensure that the melt() function call is syntactically correct. The unmodifed data frame is organized this way: head(tds.anal) site sampdate param quant 1 UDS-O 2006-12-06 TDS 10800 4 STC-FS 1996-06-14 Cond 280 7 UDS-O 2007-10-04 Mg 1620 9 UDS-O 2007-10-04 SO4 7580 19 JCM-10B 2007-06-21 Ca 79 20
2011 Oct 20
2
Aggregating data help
Hello, I have a dataset with student performance on a math test. There are multiple cases for each student (identified by id) and the concept as a variable. > rtest id test subject grade concept correct tested per_corr year 1 1 83 Mathema 8 8.2.D 1 1 100 2011 2 1 83 Mathema 8 8.3.A 1 2
2011 Aug 08
1
Reshape2 sytax
Hi Hadley et all, I am struggling with reshape2 and melt works and melt_check (filtered151) seems fine My cast command was acast (filtered151, Time ~ Species ~ Number) > melt_check (filtered151) Using time, Species as id variables $id [1] "time" "Species" $measure [1] "Number" When I execute cast the data matrix is in the correct order but the data
2010 Nov 01
2
transforming a dataset for association analysis RESHAPE2
I get the following message when using the reshape2 package line > tDat.m<- melt(Dataset) Using Item, Subject as id variables > tDatCast<- acast(tDat.m,Subject~Item) Aggregation function missing: defaulting to length Note Problem Statement- convert dataframe Subject Item Score 1 Subject 1 Item 1 1 2 Subject 1 Item 2 0 3 Subject 1 Item 3 1 4 Subject 2 Item 1 1 5
2011 Apr 21
1
Stymied by plyr
Hello, This is my first time trying to use plyr, and I'm getting nowhere. I have teacher ratings data (1:4), on 10 components, by external observers and internal observers, in schools in areas. I want to calculate the percentage of each rating given on each component, by each type of observer, within each school, within each area. The data look like this: unit area ext.obs rating comp 11
2012 Dec 13
2
More efficient use of reshape?
Hi all, I have played a bit with the "reshape" package and function along with "melt" and "cast", but I feel I still don't have a good handle on how to use them efficiently. Below I have included a application of "reshape" that is rather clunky and I'm hoping someone can offer advice on how to use reshape (or melt/cast) more efficiently. #For this