Displaying 20 results from an estimated 24 matches for "value_var".
2011 Sep 28
3
Data transformation & cleaning
...56 | Choice A
456 | Choice B
...
I thought that I should do the following
1. Make the data set "wide", counting the observations so the data looks
like this:
ID | Count of Preference A | Count of Preference B
123 | 1 | 1
...
Using
table1 <- dcast(data,ID ~ Page,fun.aggregate=length,value_var='Page' )
2. Create a correlation matrix of preferences
cor(table2[,-1])
How would I restrict my correlation to show preferences that met a minimum
sample threshold? Can you confirm if the two following commands do the same
thing? What would I do from here (or am I taking the wrong approac...
2011 Oct 18
9
readRDS and saveRDS
Hi all,
Is there any chance that readRDS and saveRDS might one day become
read.rds and write.rds? That would make them more consistent with the
other reading and writing functions.
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
2011 Aug 08
1
Help on reshape2 data frame rearrangement
...Site group. The objective is to rearrange to: Site 1 Site 210 513 714 9 ........ I have tried a variety of approaches, none of which worked. The following code does not work but suggests the task might be possible, perhaps in 2 steps. Df2 <- dcast (Data1, Length ~ Site, value_var = "Length") Its output is: Length Site 1 Site 210 10 NA13 13 NA14 14 NA.......5 NA 57 NA 79 NA 9 One easy solution is to reshape in Excel and import a new dataframe for use but I would lik...
2011 Feb 26
1
Transform a dataset from long to wide using reshape2
...mydata <- data.frame( x=sample(LETTERS[23:26],100, replace=TRUE),
y=rnorm(100, mean=2), id=sample(letters[1:4], 100, replace=TRUE))
acast(mydata , id ~ x)
# not so fine
=================================================================
produces this :
Using id as value column: use value_var to override.
Aggregation function missing: defaulting to length
W X Y Z
a 7 5 5 7
b 6 9 6 12
c 1 4 5 6
d 6 14 5 2
Why does reshape2 think it needs an aggregation function here>
Thanks
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
2011 Feb 23
1
Fwd: Re: sum data from data.frame in a matrix
...------
Subject: Re: [R] sum data from data.frame in a matrix
Date: Wed, 23 Feb 2011 00:10:52 -0800
From: Dennis Murphy <djmuser at gmail.com>
To: Nicolas Gutierrez <nicolasg at uw.edu>
Hi:
...and a second way, using the reshape2 package:
library(reshape2)
dcast(df, yloc ~ xloc, value_var = 'yield', fun = sum)
yloc 10 11 12
1 10 0 81 0
2 11 0 0 30
3 12 95 0 0
Dennis
On Tue, Feb 22, 2011 at 11:30 PM, Nicolas Gutierrez <nicolasg at uw.edu
<mailto:nicolasg at uw.edu>> wrote:
Hi all (again),
I have a data frame "pop":...
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
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 Jun 09
2
Reshape:cast; error using "..." in formula expression.
Whenever I use "..." in the formula of the cast function, from the reshape
package, I get the following error:
Error in `[.data.frame`(data, , variables, drop = FALSE) :
undefined columns selected
For example:
data(french_fries) #available in the reshape package
> head(french_fries)
time treatment subject rep potato buttery grassy rancid painty
61 1 1 3 1
2011 Apr 19
0
doSMP package works better than perfect, at least sometimes.
...peedup.elapsed1 <- tstats$meanElapsed_unvectorized /
tstats$meanElapsed_1CoreVectorized
tstats$speedup.elapsed3 <- tstats$meanElapsed_1CoreVectorized /
tstats$meanElapsed_SMPVectorized
speedupVectorizing <- dcast(tstats[c('g','n','speedup.elapsed1')], g~n,
value_var='speedup.elapsed1')
speedupSMP <- dcast(tstats[c('g','n','speedup.elapsed3')], g~n,
value_var='speedup.elapsed3')
return(list(vectoring=speedupVectorizing, smp=speedupSMP))
}
timeSMP(10,1) # make it thrash as much as possible
timeSMP...
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 06
3
Wide to long form conversion
I have some data 'myData' in wide form (attached at the end), and
would like to convert it to long form. I wish to have five variables
in the result:
1) Subj: factor
2) Group: between-subjects factor (2 levels: s / w)
3) Reference: within-subject factor (2 levels: Me / She)
4) F: within-subject factor (2 levels: F1 / F2)
5) J: within-subject factor (2 levels: J1 / J2)
As this is the
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 Oct 21
2
Calculating difference between values in data frame based on separate column
Hi all,
Say I have a data frame something like the one below with different sample
vials, measured before(B) and after(A) some process, with a value recorded
at each measurement point
vial measure value
1 B 26
1 A 12
2 B 45
2 A 30
3 B 32
3 A 27
4 B
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 19
2
trouble with summary tables with several variables using aggregate function
Dear all,
I am having trouble creating summary tables using aggregate function.
given the following table:
Var1 Var2 Var3 dummy
S1 T1 I 1
S1 T1 I 1
S1 T1 D 1
S1 T1 D 1
S1 T2 I 1
S1 T2 I 1
S1 T2 D 1
S1 T2 D 1
S2
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
2011 Sep 22
2
create variables through a loop
HI, Dear R community,
I am trying to created new variables and put into a data frame through a
loop.
My original data set:
head(first)
probe_name chr_id position array1
1 C-7SARK 1 849467 10
2 C-4WYLN 1 854278 10
3 C-3BFNY 1 854471 10
4 C-7ONNE 1 874460 10
5 C-6HYCN 1 874571 10
6 C-7SCGC 1 874609 10
I have
2011 Nov 19
3
reshape data.frame
A late friday afternoon coding question. I'm having a hard time thinking
of the correct search terms for what I want to do.
If I have a df like this:
a <-
data.frame(name=c(rep('a',10),rep('b',15)),year=c(1971:1980,1971:1985),amount=1:25)
name year amount
1 a 1971 1
2 a 1972 2
3 a 1973 3
4 a 1974 4
5 a 1975 5
6 a 1976
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