Displaying 16 results from an estimated 16 matches for "adply".
Did you mean:
ddply
2017 Oct 11
6
changing "," to "." in data.frame
...ble.com/How-to-replace-all-commas-with-semicolon-in-a-string-tt4721187.html#a4721192
so copying the code of Ulrik(I hope:-)) I tried
(making some data)
AX <-
data.frame(a=chartr(".",",",rnorm(5)),b=chartr(".",",",rnorm(5)),c=rnorm(5))
library(plyr)
adply(AX, 2, function(x){
if(!is.numeric(x[[1]]){
gsub(",", ".", x[[1]])
}else{
x[[1]]
}
})
and got the unwelcome error
Error: unexpected '{' in:
"adply(AX, 2, function(x){
if(!is.numeric(x[[1]]){"
Here is:
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platfor...
2010 Dec 01
1
Difference between loops and vectorization
Hello R-helpers,
A fundamental question ...I'm trying to understand the differences
between loop and vectorization ... I understand that it should be a
natural choice to use apply / adply when it is needed to perform the
same function across all rows of a data frame.
Any pointers on why this is so? Unable to find the right reading place
on the WWW which explains the concept.
Thanks for your help.
S
2017 Oct 11
0
changing "," to "." in data.frame
...a-string-tt4721187.html#a4721192
>
> so copying the code of Ulrik(I hope:-)) I tried
>
> (making some data)
>
> AX <-
> data.frame(a=chartr(".",",",rnorm(5)),b=chartr(".",",",rnorm(5)),c=rnorm(5))
>
>
> library(plyr)
>
> adply(AX, 2, function(x){
> if(!is.numeric(x[[1]]){
> gsub(",", ".", x[[1]])
> }else{
> x[[1]]
> }
> })
>
> and got the unwelcome error
>
> Error: unexpected '{' in:
> "adply(AX, 2, function(x){
> if(!is.numeric(x[[1]]){"
>
>...
2011 May 16
1
Extracting the dimnames of an array with variable dimensions
Hi list,
In a function I am writing, I need to extract the dimension names of
an array. I know this can be acheived easily using dimnames() but my
problem is that I want my function to be robust when the number of
dimensions varies. Consider the following case:
foo <- array(data = rnorm(32), dim = c(4,4,2),
dimnames=list(letters[1:4], LETTERS[1:4], letters[5:6]))
# What I want is to extract
2010 Nov 16
1
Batch Processing Files
...iles so that I can
1. import each data file
2. find the minimum value recorded in column 2 and the previous 5 data
points
3. and average these 10 values to get a mean, minimum value.
Currently I have imported the data files using the following
filenames=list.files()
library(plyr)
import.list=adply(filenames, 1, read.csv)
and I know how to write a code to calculate the minimum value and the 5
preceding values in a single column, in a single file. I think the
problem I am running into is scaling this code up so that I can import
multiple files and calculating mean, minimum value for the 2^...
2011 Aug 05
2
Which is more efficient?
Greetings all,
I am curious to know if either of these two sets of code is more efficient?
Example1:
## t-test ##
colA <- temp [ , j ]
colB <- temp [ , k ]
ttr <- t.test ( colA, colB, var.equal=TRUE)
tt_pvalue [ i ] <- ttr$p.value
or
Example2:
tt_pvalue [ i ] <- t.test ( temp[ , j ], temp[ , k ], var.equal=TRUE)
-------------
I have three loops, i, j, k.
One to test the all of
2013 Apr 10
6
means in tables
Hi.
I have 2 tables, with same dimensions (8000 x 5). Something like:
tab1:
V1 V2 V3 V4 V5
14.23 1.71 2.43 15.6 127
13.20 1.78 2.14 11.2 100
13.16 2.36 2.67 18.6 101
14.37 1.95 2.50 16.8 113
13.24 2.59 2.87 21.0 118
tab2:
V1 V2 V3 V4 V5
1.23 1.1 2.3 1.6 17
1.20 1.8 2.4 1.2 10
1.16 2.6 2.7 1.6 11
1.37 1.5 2.0 1.8 13
1.24 2.9 2.7 2.0 18
I need generate a table of averages, the
2008 Sep 30
0
New package: plyr
...object they input
(first letter) and output (second letter):
* llply = from a list to a list
* alply = from an array (or vector, or matrix) to a list
* ldply = from a list to a data.frame
* d_ply = from a data.frame, ignore output
* and so on for llply, laply, ldply, l_ply, alply, aaply, adply,
a_ply, dlply, daply, dply, d_ply
plyr also provides:
* m*ply which works in a similar way to mapply
* r*ply which works in a similar way to replicate
You can find out more at http://had.co.nz/plyr/, including a 20 page
introductory guide, http://had.co.nz/plyr/plyr-intro.pdf.
Regards,
Had...
2008 Sep 30
0
New package: plyr
...object they input
(first letter) and output (second letter):
* llply = from a list to a list
* alply = from an array (or vector, or matrix) to a list
* ldply = from a list to a data.frame
* d_ply = from a data.frame, ignore output
* and so on for llply, laply, ldply, l_ply, alply, aaply, adply,
a_ply, dlply, daply, dply, d_ply
plyr also provides:
* m*ply which works in a similar way to mapply
* r*ply which works in a similar way to replicate
You can find out more at http://had.co.nz/plyr/, including a 20 page
introductory guide, http://had.co.nz/plyr/plyr-intro.pdf.
Regards,
Had...
2012 Jan 12
1
parallel computation in plyr 1.7
Dear all,
I have a question regarding the possibility of parallel computation in plyr
version 1.7.
The help files of the following functions mention the argument '.parallel':
ddply, aaply, llply, daply, adply, dlply, alply, ldply, laply
However, the help files of the following functions do not mention this
argument: ?d_ply, ?aply, ?lply
Is it because parallel computation is not supported for these latter
functions? Or is it just because the documentation was not updated for
these functions after addin...
2011 Jan 04
0
plyr 1.4
...riable names if explicit names not provided (Fixes
#17)
* `arrays` with names should be sorted correctly once again (also fixed a bug
in the test case that prevented me from catching this automatically)
* `m_ply` no longer possesses .parallel argument (mistakenly added)
* `ldply` (and hence `adply` and `ddply`) now correctly passes on .parallel
argument (Fixes #16)
* `id` uses a better strategy for converting to integers, making it possible
to use for cases with larger potential numbers of combinations
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / R...
2011 Jan 04
0
plyr 1.4
...riable names if explicit names not provided (Fixes
#17)
* `arrays` with names should be sorted correctly once again (also fixed a bug
in the test case that prevented me from catching this automatically)
* `m_ply` no longer possesses .parallel argument (mistakenly added)
* `ldply` (and hence `adply` and `ddply`) now correctly passes on .parallel
argument (Fixes #16)
* `id` uses a better strategy for converting to integers, making it possible
to use for cases with larger potential numbers of combinations
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / R...
2012 Apr 19
3
How to "flatten" a multidimensional array into a dataframe?
Hi,
I have a three dimensional array, e.g.,
my.array = array(0, dim=c(2,3,4), dimnames=list( d1=c("A1","A2"),
d2=c("B1","B2","B3"), d3=c("C1","C2","C3","C4")) )
what I would like to get is then a dataframe:
d1 d2 d3 value
A1 B1 C1 0
A2 B1 C1 0
.
.
.
A2 B3 C4 0
I'm sure there is one function to do
2013 Apr 29
0
interesting behavior from aaply
...ata was rearranged from a flat matrix to
a [, , 4] array for larger input matrixes. I'm sure something clever is
happening that I'm just not seeing - anyone have any insight? I can provide
the code for index.frames() if you like, but it's pretty turgid stuff.
For now I'm just using adply(), since it gives an output that I'd expect.
Best
toy.mat <- all.combinations[10:30,]
> aaply(toy.mat,1, index.frames)
Var1 1 2 3 4
46 3599.848 3665.454 12946.41 12946.41
51 3600.020 3666.424 12946.41 12946.41
56 3600.167 3667.301 12946.41 12946.4...
2013 Apr 09
4
Converting matrix to data frame without losing an assigned dimname
Hello All,
Would like to be able to convert a matrix to a dataframe without losing an assigned dimname.
Here is an example that should illustrate what I'm talking about.
tableData <- state.x77[c(7, 38, 20, 46), c(7, 1, 8)]
names(dimnames(tableData)) <- c("State", "")
tableData
State Frost Population Area
Connecticut 139 3100 4862
2010 Nov 09
3
Row-wise recurive function call
Dear Group,
I have a following dataset:
> a
A B C D
1 22 3 31 40
2 26 31 36 32
3 3 7 49 16
4 24 40 27 26
5 20 45 47 0
6 34 43 11 18
7 48 48 24 2
8 3 16 39 48
9 20 49 7 21
10 17 36 47 10
> dput(a)
structure(list(A = c(22L, 26L, 3L, 24L, 20L, 34L, 48L, 3L, 20L,
17L), B = c(3L, 31L, 7L, 40L, 45L, 43L, 48L, 16L, 49L, 36L),
C = c(31L, 36L, 49L, 27L, 47L, 11L, 24L,