I am trying to understand ``deviance'' in classification tree output
from tree package.
library(tree)
set.seed(911)
mydf <- data.frame(
name = as.factor(rep(c("A", "B"), c(10, 10))),
x = c(rnorm(10, -1), rnorm(10, 1)),
y = c(rnorm(10, 1), rnorm(10, -1)))
mytree <- tree(name ~ ., da
p <- unlist(Map(f, 1:nrow(df)))
df2 <- df[rowindex_rep, ]
Regards,
radmuzom
From: R-help on behalf of Eric Berger
Sent: Sunday, July 8, 2018 3:21 PM
To: catalin roibu
Cc: R Project Help
Subject: Re: [R] replicate rows
Hi Catalin,
This should work. I set the number of repetitions
Hi Catalin,
This should work. I set the number of repetitions and sample sizes as
variables so it would be clear how to modify for your actual case.
nreps<- 3
sampSize <- 2
w <- unlist( lapply(1:nreps, function(i) {
rep(paste("R",i,sep=""),sampSize) } ) )
aa2 <- cbind( as.data.frame(aa), w)
Dear R users,
I want to replicate sampled rows in data frame. The sampling results must
be in this form:
a b Rep
[1,] 3 4.0 R1
[2,] 6 8.0 R1
[3,] 1 0.1 R2
[4,] 6 8.0 R2
[5,] 1 0.1 R3
[6,] 5 7.0 R3
I have a code but I didn't succeed to insert to rep column.
This is my code:
a<-c(1,2,3,4,
Only your pdf attachment made it through. You would need to follow the Posting
Guide regarding file types to achieve successful transmission.
I will say that open-ended debugging of your code does not fit the Posting
Guide recommendations either... this is an R language mailing list, not a
res
I'm not sure why you'd want to, but here's one way to do it:
plotdat2[rep(1:nrow(plotdat), each=100), ]
This puts all the replicates of each row together.
plotdat2[rep(1:nrow(plotdat), times=100), ]
while this repeats each row then starts over.
If that answer doesn't make sense, then you shou
?rep (to replicate indices)
plotdat2[rep(1:3,e=100), ]
This seemspretty basic. Have you gone through any R tutorials yet? If
not, please do so before posting further. There are many good ones on
the web.
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming
Hi, There!
I have this data frame:
> plotdat2
FirmicutesLowerUpper fTissue2
1 63.48023 59.15983 68.11614 CAECUM
2 61.42512 57.24651 65.90875COLON
3 44.68343 41.62523 47.96632RUMEN
How can I replicate each line 100 times?
I`m new in R command line, so sorry if my quest
I am very confuse,
I send with a wrong subject.
All my Apologizes
-
De : Guibert TCHINDE
Date d'envoi : jeudi 1 août 2013 18:51
À : r-help@r-project.org
Cc : R help
Objet : RE : [R] Conversion of matrix in r to integer
Dear List,
I am trying to repli
Yes. You want the survey package,
Use the svrepdesign() function to create a survey object containing
the replicate weights, and the rest of the functions in the package to
do analyses
-thomas
On Fri, May 11, 2012 at 9:24 AM, Samantha Tornello wrote:
> Hello everyone! I am analyzing a publi
Hello everyone! I am analyzing a public use dataset which has both basic
weights and replicated weights. I have found that only Stata seems to work
with replicate weights but I would rather use R. Does anyone know if R can
use replicate weights?
If this is possible, could someone share some links
Hi>
> Hello,
>
> I have a matrix of 17 rows and 20 columns. I want to replicate this
matrix
> 20 times, but I only want to replicate the rows. How do I do that?
Replicate index.
x<-matrix(1:4, 2,2)
x[rep(1:2, 20),]
Regards
Petr
>
> Kind regards / Met vriendelijke groet / Med venlig hilsen,
>
3-02-2012, 11:26 (+); Schumacher, G. escriu:
> I have a matrix of 17 rows and 20 columns. I want to replicate this
> matrix 20 times, but I only want to replicate the rows. How do I do
> that?
If x is your matrix, this
x[rep(1:17, 20),]
will give you a matrix with 340 rows and 20 columns wh
It is not clear to me exactly what you are trying to do. Can you show
a short example of some input and then what the output would look
like?
When you say you only "want to replicated the rows", what happens to
the columns? Is each matrix going to have only one column?
So some more clarificatio
Hello,
I have a matrix of 17 rows and 20 columns. I want to replicate this matrix 20
times, but I only want to replicate the rows. How do I do that?
Kind regards / Met vriendelijke groet / Med venlig hilsen,
Dr. Gijs Schumacher
Postdoctoral Researcher
Department of Political Science and Public
On Oct 11, 2011, at 4:22 PM, Bert Gunter wrote:
Replicate the row indices?
x[rep(seq_len(nrow(x)), k), ]
Or the column indices.
x[ , rep(seq_len(length(x)), k) ]
--
David,
-- Bert
On Tue, Oct 11, 2011 at 12:55 PM, Martin Batholdy
wrote:
Hi,
is there a way to replicate a data.frame
Replicate the row indices?
x[rep(seq_len(nrow(x)), k), ]
-- Bert
On Tue, Oct 11, 2011 at 12:55 PM, Martin Batholdy
wrote:
> Hi,
>
>
> is there a way to replicate a data.frame like you can replicate the entries
> of a vector (with the repeat-function)?
>
> I want to do this:
>
> x <- data.frame(
Hi,
is there a way to replicate a data.frame like you can replicate the entries of
a vector (with the repeat-function)?
I want to do this:
x <- data.frame(x, x)
(where x is a data.frame).
but n times.
And it should be as cpu / memory efficient as possible, since n is pretty big
in my cas
Hi Jorge!
2011/8/25 Jorge I Velez :
> Try ("x" is your data):
> x[rep(1:nrow(x), each = 6),]
Yes, it works. Thanks! I see that the row names are now: 1, 1.1,
1.2, 1.3, 1.4, 1.5, 2, 2.1 .
It does not bother me, but is this going to be a problem later on? I
need to further manipulate the
Hi Henri-Paul,
Try ("x" is your data):
x[rep(1:nrow(x), each = 6),]
HTH,
Jorge
On Thu, Aug 25, 2011 at 3:22 PM, Henri-Paul Indiogine <> wrote:
> Greetings!
>
> I am just now learning to use R for my dissertation project. I need
> to manipulate a lot of text and numeric data. I created a da
Greetings!
I am just now learning to use R for my dissertation project. I need
to manipulate a lot of text and numeric data. I created a data frame
that has 7 columns and 127 unique rows. Now I need to replicate each
line 6 times and then later change values in the first 2 columns.
I am tryin
On Apr 22, 2011, at 18:50 , Douglas Bates wrote:
> What about reading a deck of punched cards with the cards statement in
> SAS? How do you propose to do that in R?
Actually, with the new text= argument to read.table in r-devel, it should be
rather easy (given that you can find a card-punc
On Fri, Apr 22, 2011 at 11:27 AM, Gabor Grothendieck
wrote:
> Since this involves time series within each id group I thought it
> would be interesting to see if this could be formulated using
> zoo series. The approach is to read it in, and convert it to a long
> form by just stacking the start
On Thu, Apr 21, 2011 at 5:34 PM, peter dalgaard wrote:
>
> On Apr 21, 2011, at 16:00 , Bert Gunter wrote:
>
>> Folks:
>>
>> It is perhaps worth noting that this is probably a Type III error: right
>> answer to the wrong question. The right question would be: what data
>> structures and analysis s
Since this involves time series within each id group I thought it
would be interesting to see if this could be formulated using
zoo series. The approach is to read it in, and convert it to a long
form by just stacking the start and stop times in a data frame
and converting that to zoo using the c
Hi Paul,
On Fri, Apr 22, 2011 at 10:21 AM, Paul Miller wrote:
>
> Hello Everyone,
>
> It seems to me that Bert’s assertion about my question is not entirely
> accurate.
>
> In my question, I wrote:
>
> I'm hearing in some places that R may not be able to accomplish all of the
> data manipulatio
On Apr 21, 2011, at 16:00 , Bert Gunter wrote:
> Folks:
>
> It is perhaps worth noting that this is probably a Type III error: right
> answer to the wrong question. The right question would be: what data
> structures and analysis strategy are appropriate in R? As usual, different
> language arc
Folks:
It is perhaps worth noting that this is probably a Type III error: right
answer to the wrong question. The right question would be: what data
structures and analysis strategy are appropriate in R? As usual, different
language architectures mean that different paradigms should be used to be
Oops, I missed the HAART part. Fortunately that translates straightforwardly:
n.dat$HAART <- with(n.dat, ifelse((NRTI >= 3 & NNRTI==0 & PI==0) |
(NRTI >= 2 & (NNRTI >= 1 | PI >= 1)) |
(NRTI == 1 & NNRTI >= 1 & PI >= 1),
I think this is kind of like asking "will your Land Rover make it up
my driveway?", but I'll assume the question was asked in all
seriousness.
Here is one solution:
## Read in test data;
dat <- read.table(textConnection("iddrug start stop
1004NRTI 07/24/9501/05/99
[*** PLEASE NOTE: I am sending this message on behalf of
Paul Miller:
Paul Miller
(to whom this message has also been copied). He has been
trying to send it, but it has never got through. Please
do not reply to me, but either to the list and/or to Paul
at that address ***]
=
On Sat, Nov 13, 2010 at 10:37 PM, Jeff Newmiller - jdnew...@dcn.davis.ca.us
<+cran+miller_2555+a7f4a7aeab.jdnewmil#dcn.davis.ca...@spamgourmet.com>wrote:
>
> Anyway, I recommend you learn from David before criticizing his assistance.
>
> >On Fri, Nov 12, 2010 at 5:28 PM,
> David Winsemius -
> >d
Most software for curve fitting uses linear fits in conjunction with some
combination of logarithms of your original in order to obtain logarithmic,
power or exponential curve fits. The nls approach is arguably more correct, but
it will yield different results than "normal", and may be finicky w
On Nov 13, 2010, at 10:12 PM, cran.30.miller_2...@spamgourmet.com wrote:
> On Fri, Nov 12, 2010 at 5:28 PM, David Winsemius -
> cran.30.miller_2...@spamgourmet.com
> <+cran
> +miller_2555+c0e7477398.dwinsemius#comcast@spamgourmet.com> wrote:
>
> On Nov 12, 2010, at 5:07 PM, David Winsemiu
On Fri, Nov 12, 2010 at 5:28 PM, David Winsemius - dwinsem...@comcast.net
<+cran+miller_2555+c0e7477398.dwinsemius#comcast@spamgourmet.com> wrote:
>
> On Nov 12, 2010, at 5:07 PM, David Winsemius wrote:
>
>
>> On Nov 12, 2010, at 4:22 PM, cran.30.miller_2...@spamgourmet.com wrote:
>>
>> Hi -
On Nov 12, 2010, at 5:07 PM, David Winsemius wrote:
On Nov 12, 2010, at 4:22 PM, cran.30.miller_2...@spamgourmet.com
wrote:
Hi -
I have a dataframe of (x,y) values. I'd like to fit an exponential
curve to the data for further statistical analysis (pretty much the
same
functionality
On Nov 12, 2010, at 4:22 PM, cran.30.miller_2...@spamgourmet.com wrote:
Hi -
I have a dataframe of (x,y) values. I'd like to fit an exponential
curve to the data for further statistical analysis (pretty much the
same
functionality provided by Excel's LOGEST worksheet array function).
C
Hi -
I have a dataframe of (x,y) values. I'd like to fit an exponential
curve to the data for further statistical analysis (pretty much the same
functionality provided by Excel's LOGEST worksheet array function). Can
someone point me to the (set of) functions/ package that is best suited to
p
Dear all,
I use the following to create a list of identical grobs,
require(grid)
rep.grob <- function(g, n){
replicate(n, g, simplify=FALSE)
}
This approach suffers two problems:
1- R CMD check is not happy about the S3-like name. How can / Should I
make this a real S3 method?
2- I don't know
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of wendy
> Sent: Saturday, February 20, 2010 6:58 PM
> To: r-help@r-project.org
> Subject: [R] replicate matrix
>
>
> Hi all,
>
> I have a ma
You can just rep() it, and c() with extra data, and then matrix() it again:
> m <- matrix(c(1,4,3,6),2)
> matrix(c(rep(m, 3), c(2, 5)), nrow(m))
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]1313132
[2,]4646465
On Sun, Feb 21, 2010 at 10:58 AM,
try this:
mat <- matrix(c(1,4,3,6), 2, 2)
cbind(
do.call(cbind, rep(list(mat), 3)),
c(2, 5)
)
I hope it helps.
Best,
Dimitris
wendy wrote:
Hi all,
I have a matrix, for example
[,1] [,2]
[1,] 13
[2,] 46
I want to replicate the matrix twice and add an extra column at
You can try something like:
mtx <- matrix(1:4, ncol = 2)
mtx.rep <- t(apply(mtx, 1, rep, r))
mtx.rep <- cbind(mrx.rep, new.column)
where r is your desired number of replications .
Hope it helps,
Boyko
Joshua Wiley-2 wrote:
>
> Hello Wendy,
>
> The simplest solution that comes to mind is t
Hello Wendy,
The simplest solution that comes to mind is to just use cbind.
For instance:
> x <- matrix(1:4, nrow=2)
> x
[,1] [,2]
[1,]13
[2,]24
> cbind(x,x,x,c(2,5)) # repeat x here as many times as needed
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]1313
Hi all,
I have a matrix, for example
[,1] [,2]
[1,] 13
[2,] 46
I want to replicate the matrix twice and add an extra column at the end,
which is
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 13 13 132
[2,] 46 46 465
I found 'rep' o
Hi,
Zitat von "Charles C. Berry" <[EMAIL PROTECTED]>:
> On Thu, 6 Nov 2008, Oliver Bandel wrote:
>
> > Hello Charles,
> >
>
> [snip]
>
> >> dim( as.matrix(replicate(10, sample(x, 3) ) ) )
> > [1] 3 10
> >> dim( as.matrix(replicate(10, sample(x, 2) ) ) )
> > [1] 2 10
> >> dim( as.matri
On Thu, 6 Nov 2008, Oliver Bandel wrote:
Hello Charles,
[snip]
dim( as.matrix(replicate(10, sample(x, 3) ) ) )
[1] 3 10
dim( as.matrix(replicate(10, sample(x, 2) ) ) )
[1] 2 10
dim( as.matrix(replicate(10, sample(x, 1) ) ) )
[1] 10 1
=
So, the
Hello Charles,
thank you for the hint.
Zitat von "Charles C. Berry" <[EMAIL PROTECTED]>:
[...]
> > This looks good (and correct to me).
>
> Look again .
>
> It is not the same as what you have above.
[...]
OK, yes, you are right!
I mixed the two parameters...
Now I get the same problem als
On Thu, 6 Nov 2008, Oliver Bandel wrote:
Hello,
for a simulation I tried the following:
=
sampmeanvec <- function (from, n, repititions)
{
print( paste("samplesize n:", n, "repititions:", repititions) )
samples.mat <- as.matri
Hello,
for a simulation I tried the following:
=
sampmeanvec <- function (from, n, repititions)
{
print( paste("samplesize n:", n, "repititions:", repititions) )
samples.mat <- as.matrix( replicate( repititions, sample(from, n)
yes, this works, thank yo. very smart solution!
-R
> Date: Sat, 19 Jul 2008 19:55:58 -0400
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Re: [R] replicate matrix blocks different numbers of times into new
> matrix
olve my
> problem?
>
> Best,
>
> Ralph
>
>
>> Date: Sat, 19 Jul 2008 21:39:25 +0200
>> From: [EMAIL PROTECTED]
>> To: [EMAIL PROTECTED]
>> CC: r-help@r-project.org
>> Subject: Re: [R] replicate matrix blocks di
9:25 +0200
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> CC: r-help@r-project.org
> Subject: Re: [R] replicate matrix blocks different numbers of times into new
> matrix
>
> Ralph S. wrote:
>> Hi,
>>
>> I am trying to replicate blocks of a matrix (defined
Ralph S. wrote:
Hi,
I am trying to replicate blocks of a matrix (defined by factors) into another matrix, but an unequal, consecutive number of times for each factor.
I need to find an elegant and fast way to do this, so loops will not work.
An example of what I am trying to do is the follow
Hi,
I am trying to replicate blocks of a matrix (defined by factors) into another
matrix, but an unequal, consecutive number of times for each factor.
I need to find an elegant and fast way to do this, so loops will not work.
An example of what I am trying to do is the following:
# the data
55 matches
Mail list logo