Dear Rui,
Many thanks, I got it now, thanks.
In my R code, I have moved the replication term
N <-1000
out <- replicate(N, {
This time I get what I am looking for.
library(boot)
s<- sample(178:798, 1, replace=TRUE)
mean(s)
N <- 1
out <- replica
Hello,
As for the code, I think it's simple. Before calling boot.ci you need to
call boot. And replicate calls the expression between {} N times. After
running boot.ci, the component bca is extracted. See ?boot.ci, section
Value, after bca:
These latter four components will be matrices with
Dear Rui,
I really thank you a lot for your response. Even if I don't fully understand
your R code, there is something strange happening while running the code.
Indeed, I have run this R code here below 20 times and I always got the same
answer : [1] 1
l
Hello,
The problem can be solved with ?replicate.
in the code below I only repeat N <- 1e3, not 1e4.
set.seed(2021)
N <- 1e3
out <- replicate(N, {
boot.out <- boot(data = dat, statistic = med, R = 1)
boot.ci(boot.out, type = "bca")$bca[, 4:5]
})
mean(out[1,] < mean(s) & mean(s) < out[2,
Dear R-experts,
Here below my R code. I am trying to do 2 things :
1) I would like to repeat this R code 1 times
2) Out of the 1 repetitions I would have liked R to tell me how many times
the "true" mean value of the population called "s" in my R example here below
is included in the 1
Thank you very much.
This is exactly what I needed.
Isaac.
-Mensaje original-
De: peter dalgaard [mailto:pda...@gmail.com]
Enviado el: lunes, 10 de diciembre de 2018 15:10
Para: Subirana Cachinero, Isaac
CC: Rui Barradas; r-help@r-project.org
Asunto: Re: [R] repeating the same variable
hin ` `.
>
> Isaac.
>
> -Mensaje original-
> De: Rui Barradas [mailto:ruipbarra...@sapo.pt]
> Enviado el: lunes, 10 de diciembre de 2018 11:27
> Para: Subirana Cachinero, Isaac; r-help@r-project.org
> Asunto: Re: [R] repeating the same variable in formula
>
&g
white spaces or other characters
within ` `.
Isaac.
-Mensaje original-
De: Rui Barradas [mailto:ruipbarra...@sapo.pt]
Enviado el: lunes, 10 de diciembre de 2018 11:27
Para: Subirana Cachinero, Isaac; r-help@r-project.org
Asunto: Re: [R] repeating the same variable in formula
Hello,
The fo
Hello,
The formulas
y ~ cholesterol + age + age
and
y ~ cholesterol + age
are the same formula.
If you want 'age' twice, maybe
g <- y ~ cholesterol + I(age + age)
attr(terms(g), "term.labels")
#[1] "cholesterol" "I(age + age)"
Hope this helps,
Rui Barradas
Às 06:49 de 10/12/2018, Subira
I am using terms.formula function to substract the variables from a formula
environment.
Concretely, with the attr(*, "term.labels") I get the right side terms
specified in the formula.
However, when introducing the same variable two or more times, this appears
only once.
For example, when ty
Hello,
Inline.
On 4/13/2018 1:10 AM, Jim Lemon wrote:
Hi Marna,
Assuming that you are descending into different subdirectories from
the same directory:
Maybe this assumption is not needed.
Since setwd returns the current directory, it is safer to assign that
value to a variable and in the en
Hi Marna,
Assuming that you are descending into different subdirectories from
the same directory:
directories<-c("dir1","dir2","dir3")
for(directory in directories) {
setwd(directory)
# do whatever you want to do
# then return to the directory above
setwd("..")
}
This will allow you to start
Hi R users,
I need to run a analysis using a data for each folder. I do have several
folders. Each folder contains several files but these files name are
similar to the files that is saved into another folders. I need to repeat
the analysis for every folder and would like to save the output in th
Hi,
Use ?rep()
df1 <- read.table(text="Site Scientific.name value size
'Flat Cay' 'S. iserti' 3 2.5
'Flat Cay' 'S. iserti' 2 8
'Flat Cay' 'S. iserti' 1 25
'Flat Cay' 'S. taeniopter
I don't think you answered the OP's query, although I confess that I
am not so sure I understand it either (see below). In any case, I
believe the R level loop (i.e. apply()) is unnecessary. There is a
unique (and a duplicated()) method for data frames, so simply
unique(x)
returns a data frame wi
Hi,
Try ?duplicated()
apply(x,2,function(x) {x[duplicated(x)]<-"";x})
A.K.
Hi all,
I have a dataset of around a thousand column and a few thousands
of rows. I'm trying to get all the possible combinations (without
repetition) of the data columns and process them in parallel. Here's a
simpl
Arun has given you a number of ways to do what you (seem to) want. If
this is fast enough, then you're done.
If not, then the key to speeding things up is to do things
differently. Note that a 1 x 9 matrix is a just a vector. Since each
element of the vector is a "different computation", apparentl
HI,
May be this helps:
example <- function(X,n){
lst1 <- list()
for(i in 1:n){
cell1 <- sample(X,1)
cell2 <- sample(X,1)
table1 <- cbind(cell1,cell2)
lst1[[i]] <- table1
}
do.call(rbind,lst1)
}
#or
example1 <- function(X,n){
table1 <- vector()
for(i in 1:n){
cell1 <- sample(X,1)
cell2 <- sample
16
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Iakub Henschen
> Sent: Monday, November 11, 2013 8:42 AM
> To: r-help@r-project.org
> Subject: Re:
> n<-7
> rep(seq(1,n,2), each=4)+c(0,1,0,1)
[1] 1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 8
rep(), seq(), rbind(), apply() ... whatever: internally there will always
be iteration via some loop :-)
Ia.
On Mon, Nov 11, 2013 at 11:16 AM, Carl Witthoft wrote:
> Here's a rather extreme solution:
>
> foo<-re
Here is another solution that is a bit more flexible
tmp <- seq(8)
# split into your desired groups
max.groups <- 2
tmp.g <- split(tmp, ceiling(seq_along(tmp)/max.groups))
# do repeats, unlist, numeric index
as.numeric(unlist(rep(tmp.g, each = 2)))
Hope this works for you,
Charles
On Mon, Nov
Here's a rather extreme solution:
foo<-rep(1:6,each=2)
Rgames> foo
[1] 1 1 2 2 3 3 4 4 5 5 6 6
Rgames> foo[rep(c(1,3,2,4),3)+rep(c(0,4,8),each=4)]
[1] 1 2 1 2 3 4 3 4 5 6 5 6
In the general case, then, it would be something like
foo<- rep(1:N, each = 2) # foo is of length(2*N)
foo[rep(c(1,
> f1
function(x) {
one <- matrix(1:x, nrow=2)
as.vector(rbind(one, one))
}
> f1(8)
[1] 1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 8
Pat
On 11/11/2013 12:11, Federico Calboli wrote:
Hi All,
I am trying to create an index that returns something like
1,2,1,2,3,4,3,4,5,6,5,6,7,8,7,8
and so on and
Hi,
first off, thanks for the suggestion. I managed to solve it by doing:
IND = rep(c(T,T,F,F), 5)
X = rep(NA, 20)
X[IND] = 1:10
X[!IND] = 1:10
which avoids any function -- I think mapply, apply etc call a for loop
internally, which I'd rather avoid.
BW
F
On 11 Nov 2013, at 12:35, andrija
Hi. Here are two approaches:
c(mapply(function(x,y) rep(c(x,y), 2), (1:10)[c(T,F)], (1:10)[c(F,T)]))
c(tapply(1:10, rep(1:(10/2), each=2), rep, 2), recursive=T)
Andrija
On Mon, Nov 11, 2013 at 1:11 PM, Federico Calboli
wrote:
> Hi All,
>
> I am trying to create an index that returns someth
Hi All,
I am trying to create an index that returns something like
1,2,1,2,3,4,3,4,5,6,5,6,7,8,7,8
and so on and so forth until a predetermined value (which is obviously even).
I am trying very hard to avoid for loops or for loops front ends.
I'd be obliged if anybody could offer a suggestion
Hi,
rep(seq_along(v),v)
#[1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 5 5 5 6 6
A.K.
- Original Message -
From: Stefan Petersson
To: r-help@r-project.org
Cc:
Sent: Friday, May 17, 2013 6:53 AM
Subject: [R] Repeating sequence elements
I want to create a sequence, repeating each element
Try
rep(1:length(v), v)
HTH,
Jorge.-
On Fri, May 17, 2013 at 8:53 PM, Stefan Petersson wrote:
> I want to create a sequence, repeating each element according to a vector.
>
> I have this:
>
> v <- c(4, 4, 4, 3, 3, 2)
>
> And want to create this:
>
> 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 5 5 5 6 6
>
Hello,
At an R prompt, type
?rep
Then use
v <- c(4, 4, 4, 3, 3, 2)
rep(1:6, v)
Hope this helps,
Rui Barradas
Em 17-05-2013 11:53, Stefan Petersson escreveu:
I want to create a sequence, repeating each element according to a vector.
I have this:
v <- c(4, 4, 4, 3, 3, 2)
And want to crea
I want to create a sequence, repeating each element according to a vector.
I have this:
v <- c(4, 4, 4, 3, 3, 2)
And want to create this:
1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 5 5 5 6 6
TIA
// s
R version 3.0.0 (2013-04-03)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 L
This is no longer a question for which the Subject is accurate. Please do not
continue using inaccurate subject lines.
On Feb 27, 2013, at 9:38 AM, Zjoanna wrote:
> Hi,
> I need to change one or several parameters and run the same code several
> times, how to create a macro with parameters in R?
The short answer is ... because it was from Nabble.
The longer answer is that the filters needed to be tightened on Nabble
postings because of a an autobot spammer and the moderation queue was
being swamped with cases.
If you send your questions as email (from your email client) to r-help@r
Hi there,
Just wondering why my post was rejected?
cheersRachel
Subject: repeating autocovariate functions
From: r-help-ow...@r-project.org
To: moy...@hotmail.com
Date: Sat, 2 Feb 2013 02:56:27 +0100
Message rejected by filter rule match
--Forwarded Message Attachment--
Date: Fri, 1 Feb 201
HI,
You could also use:
res1<-sapply(1:3,function(x) g,simplify=FALSE)
#or
res2<-replicate(3,g,simplify=FALSE)
identical(res1,res2)
#[1] TRUE
A.K.
- Original Message -
From: Anser Chen
To: r-help@r-project.org
Cc:
Sent: Friday, November 30, 2012 12:50 PM
Subject: [R] rep
Hi,
Try this:
lapply(1:3,function(x) g)
A.K.
- Original Message -
From: Anser Chen
To: r-help@r-project.org
Cc:
Sent: Friday, November 30, 2012 12:50 PM
Subject: [R] repeating matrices in a list
Suppose I have the following square, non-negative matrices
> g=matri
You are so close:
rep(list(g), 3)
[[1]]
[,1] [,2] [,3]
[1,] 0.00 2.04
[2,] 0.25 0.00
[3,] 0.00 0.60
[[2]]
[,1] [,2] [,3]
[1,] 0.00 2.04
[2,] 0.25 0.00
[3,] 0.00 0.60
[[3]]
[,1] [,2] [,3]
[1,] 0.00 2.04
[2,] 0.25 0.00
[3,] 0.00 0.60
Sa
Suppose I have the following square, non-negative matrices
> g=matrix(c(0,2,4,0.25,0,0,0,0.6,0),3,3,byrow=T);
I want to create a list where this matrix is repeated multiple times. if I
do this brute force (manually), using
> env <- list(g,g,g)
works fine. Yields
[[1]]
[,1] [,2] [,3]
[1
This is pretty confusing writeup, but if you have iterations, then yes, you
need a loop or a recursion.
A loop is probably easier, take a look at
?"for"
or
?apply
for this.
there are several derivates of apply
for example, say your outputs are what the code below gives you for each file,
encapsulate them into a function and call the function ??
-- Bert
On Thu, Oct 11, 2012 at 11:09 AM, KoopaTrooper wrote:
> I'm trying to figure out how to repeat a series of commands in R and have the
> outputs added to a dataframe after each iteration.
>
> My code starts this way...
>
> a<-read.
I'm trying to figure out how to repeat a series of commands in R and have the
outputs added to a dataframe after each iteration.
My code starts this way...
a<-read.csv("File1.csv")
b<-read.csv("File2.csv")
a$Z<-ifelse(a$Z=="L",sample(1:4,length(a$Z),replace=TRUE),ifelse(a$Z=="M",sample(5:8,lengt
Hi Petr and Jean,
thanks very much, problem solved! Really appreciate your help.
Jennifer
--
View this message in context:
http://r.789695.n4.nabble.com/repeating-a-function-across-a-data-frame-tp4638643p4638678.html
Sent from the R help mailing list archive at Nabble.com.
_
As Petr suggests, the dist() function will do much of the work for you.
For example ...
# example matrix of data
nsamples <- 40
nreadings <- 46
dat <- matrix(runif(nsamples*nreadings), nrow=nsamples)
# Euclidean distance between the ROWS of dat
distance <- dist(dat)
Jean
JenniferH wrote on
Hi
did you find function dist? It seems that it can do directly what you
want.
Regards
Petr
>
> Hello everyone. Like others on this list, I'm new to R, and really not
much
> of a programmer, so please excuse any obtuse questions! I'm trying to
> repeat a function across all possible combina
Hello everyone. Like others on this list, I'm new to R, and really not much
of a programmer, so please excuse any obtuse questions! I'm trying to
repeat a function across all possible combinations of vectors in a data
frame. I'd hugely appreciate any advice!
Here's what I'm doing:
I have some
Thank you for replies. I sort out the problem by defining the reassign
matrix.
Best Wishes,
efulas
--
View this message in context:
http://r.789695.n4.nabble.com/Repeating-tp4614371p4615072.html
Sent from the R help mailing list archive at Nabble.com.
___
Hello,
efulas wrote
>
> By the way, my "for" function is below, I can't find the mistake
>
>
> rand.max.t<- function(n){
> f<-rep(NA,n)
>
> for (i in 1:n) {
> reassign[i]<-matrix(c(sample(id),data1),203,3)
> new.data<-reassign[,1]
> random.cas=reassign[new.data==0,2:3]
> random.con=reassign[
On May 7, 2012, at 6:28 AM, efulas wrote:
By the way, my "for" function is below, I can't find the mistake
rand.max.t<- function(n){
f<-rep(NA,n)
for (i in 1:n) {
reassign[i]<-matrix(c(sample(id),data1),203,3)
new.data<-reassign[,1]
random.cas=reassign[new.data==0,2:3]
random.con=reassign[ne
I don't see anything that looks like it should throw an error, but I
haven't tested your code without "data1" and "id" -- you might look at
? replicate() though -- it's designed for these sorts of things. E.g.,
replicate(100, mean(rexp(50)))
gets me a hundred draws of the mean of 50 random expone
By the way, my "for" function is below, I can't find the mistake
rand.max.t<- function(n){
f<-rep(NA,n)
for (i in 1:n) {
reassign[i]<-matrix(c(sample(id),data1),203,3)
new.data<-reassign[,1]
random.cas=reassign[new.data==0,2:3]
random.con=reassign[new.data==1,2:3]
f<- list(x=random.cas[,1],y=ra
Dear All,
I have a codes which calculates the result of Ripley's K function of my
data. I want to repeat this process 999 times. However, i am getting an
error when i use the "for i in" function. Is there any way to repeat this
analysis 999 times. Here are the codes i used ;
data4 <- matrix(c(s
Dear R experts,
I would like to please ask for your help with repeating steps in an apply
statement.
I have a dataframe that lists multiple variables for a given id and visit,
as well as drug treatment.
> head(exp)
id visit variable1 variable2 variable3 variable4 drug
1 3 113
Could you just initialize RepeatPlot = "y" and then wrap your whole
script in while(RepeatPlot == "y") { ## YOUR STUFF ENDING WITH A
POSSIBLE MODIFICATION OF RepeatPlot }?
Michael
On Mon, Nov 7, 2011 at 1:49 PM, Amit Patel wrote:
> Hi
>
> I have implented boxplots in my script to create box plot
Hi
I have implented boxplots in my script to create box plots
BoxplotsCheck <- readline(prompt = "Would you like to create boxplots for any
Feature? (y/n):")
if (BoxplotsCheck == "y"){
BoxplotsFeature <- readline(prompt = "Which Feature would you like to
create a Boxplot for?:")
Boxp
>
> Hi Petr,
>
> Thank you for the reply. Unfortunately my repetition is not uniform, but
> dependent on values given in column B, which varies by each row.
>
> Does this make it any clearer?
Not much.
let say
> A <- letters[1:10]
> B <- sample(1:3, 10, replace =TRUE)
> A
[1] "a" "b" "c"
I would appreciate help in knowing how to repeat categorical variable code
given in column=A, by the number in a matching column=B.
For example, I have a categorical variable code attributed to a household=A
and want to replicate the code for all member of the household, as given in
column=B. I wou
On 05.07.2011 16:47, Daniel Malter wrote:
Thanks, Uwe, for sending me this the second time.
Daniel,
I do not track names, sorry for posting twice.
> I send my responses through nabble.
Great, so you found the main problem already.
So #1 does not seem to be an option;
It is an option:
Thanks, Uwe, for sending me this the second time. I send my responses through
nabble. So #1 does not seem to be an option; #2 I sometimes forget.
Regards,
Daniel
Uwe Ligges-3 wrote:
>
> On 02.07.2011 20:51, Daniel Malter wrote:
>> You can just tell the function to create 1000 random numbers. Se
On 02.07.2011 20:51, Daniel Malter wrote:
You can just tell the function to create 1000 random numbers. See ?runif for
the specifics. The arguments are n, min, and max. 'n' is the one you are
looking for.
Thanks for providing help on R-help, but for the future please
- respond to the OP rath
If you want to repeat an entire function, use replicate as in
replicate(15,sapply(1,function(x) runif(x)))
Here, sapply(1,function(x) runif(x)) draws on uniformly distributed
variable. replicate(15,...) is the wrapper function that tells to do this 15
times. The benefit here is that you can repli
You can just tell the function to create 1000 random numbers. See ?runif for
the specifics. The arguments are n, min, and max. 'n' is the one you are
looking for.
Da.
--
View this message in context:
http://r.789695.n4.nabble.com/Repeating-a-function-in-R-tp3640508p3640966.html
Sent from the R h
On May 11, 2011, at 9:28 AM, NUFC09 wrote:
Ive been given an normal distribution, and have calculated the maximum
likelihood function. I need to repeat this experiment 50 times, and
200
times, and plot the results in two histograms and compare them.
I need to create a code to repeat this ex
Ive been given an normal distribution, and have calculated the maximum
likelihood function. I need to repeat this experiment 50 times, and 200
times, and plot the results in two histograms and compare them.
I need to create a code to repeat this experiment. How do i go about doing
this? Thanks
--
Hi:
The r functions are vectorized, so the loop is unnecessary:
drift <- rbinom(55, 80, 0.4)
or within a function,
drift <- function(p0 = 0.4, N = 40, ngen = 55) rbinom(ngen, 2 * N, p0)
To repeat it 1000 times, you have at least two options:
(1) [1000 columns]
simmat <- replicate(1000, drif
Hi,
try this;
output <- list()
times <- 1000
drift <-function(p0=0.4,N=40,ngen=55){
p = p0
for( i in 1:ngen){
p = rbinom(1,2*N,p)/(2*N)
}
return( p )
}
for(i in 1:times){
result <- drift(0.4, 40, 55)
output <- c(output, list(resu
Hello all,
I currently have this function:
drift <-function(p0=0.4,N=40,ngen=55){
p = p0
for( i in 1:ngen){
p = rbinom(1,2*N,p)/(2*N)
}
return( p )
}
I want to repeat it 1000 times, then do some analysis on the results. I've
tried u
Hi:
Perhaps you had something like this in mind:
df<-data.frame(a1=1:10, a2=11:20, a3=21:30, b1=101:110, b2=111:120,
b3=121:130)
avars <- names(df)[grep('^a', names(df))]
bvars <- names(df)[grep('^b', names(df))]
cvars <- paste('c', 1:length(avars), sep = '')
df <- within(df, for(i in seq_along(c
Hi Al,
Assuming that the order of the matrices resulting from selecting
"avars" and "bvars" is identical (it is at least in the example you
gave), then you can do:
dat <- data.frame(a1=1:10, a2=11:20, a3=21:30, b1=101:110, b2=111:120,
b3=121:130)
avars <- paste("a", 1:3, sep = '')
bvars <- paste
Hi all,
I frequently encounter datasets that require me to repeat the same calculation
across many variables. For example, given a dataset with total employment
variables and manufacturing employment variables for the years 1990-2010, I
might have to calculate manufacturing's share of total e
A1.056, Coupure Links 653, 9000 Gent
ring: 09/264.59.36
-- Do Not Disapprove
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Rustamali Manesiya
Sent: donderdag 13 januari 2011 5:12
To: r-help@r-project.org
Subject: [R] Repeating
How can achieve this in R using seq, or rep function
c(-1,0,1,0,-1,0,1,0,-1,0)
The range value is between-1 and 1, and I want it such that there could be
n number of points between -1 and 1
Anyone? Please help Thanks
Rusty
[[alternative HTML version deleted]]
_
Hi All,
For those still interested the code submitted by Phil (see below) worked a
treat and produced a vector with the optimal 'nsplit' collated from 50 runs
of the rpart model. I then produced a histogram for the vector called answer
and chose my modal number for nsplits from which I had my appr
thanks Phil, I have your solution and another which I will attempt in the
next day or so and will post results to the list then.
cheers
andy
On Wed, Oct 13, 2010 at 10:30 AM, Phil Spector wrote:
> Andrew -
> I think
>
> answer = replicate(50,{fit1 <- rpart(CHAB~.,data=chabun, method="anova",
Hi there,
I'm working on a biological dataset that contains up to 40 species and 100
sites each. The response variable is index (trend), dependent is year - each
combination has an index for each year between 1994 and 2008 inclusive. So
my input file is along the following lines: species, site, y
I think you want something like this:
optimal.nSplit = rep(NA, 50) # This will hold the result
for (run in 1:50)
{
fit1 = rpart(...)
cpTable = fit1$cptable
bestRow = which.min(cpTable[, "xerror"]);
optimal.nSplit[run] = cpTable[bestRow, "nsplit"]
}
In any case, look at
?rpart
?printcp
?r
Andrew -
I think
answer = replicate(50,{fit1 <- rpart(CHAB~.,data=chabun, method="anova",
control=rpart.control(minsplit=10,
cp=0.01, xval=10));
x = printcp(fit1);
Hi All,
I have to say upfront that I am a complete neophyte when it comes to
programming. Nevertheless I enjoy the challenge of using R because of its
incredible statistical resources.
My problem is this .I am running a regression tree analysis using
"rpart" and I need to run the calculat
AM
To: R (r-help@R-project.org)
Subject: [R] Repeating values in a list
I have a list that looks like this ...
> have <- list(a=7,b=3,c=1)
> have
$a
[1] 7
$b
[1] 3
$c
[1] 1
and I want to have a simple way to change it to the following without re-typing
the values ...
> desire <
e,c(1,1,2))
$a
[1] 7
$b
[1] 3
$c
[1] 1 1
From: Dennis Murphy [mailto:djmu...@gmail.com]
Sent: Saturday, September 18, 2010 8:25 PM
To: Derek Ogle
Cc: R (r-help@R-project.org)
Subject: Re: [R] Repeating values in a list
Hi:
How about
> have <- list(a=7,b=3,c=1)
> lapply(have, rep, 2
Hi:
How about
> have <- list(a=7,b=3,c=1)
> lapply(have, rep, 2)
$a
[1] 7 7
$b
[1] 3 3
$c
[1] 1 1
HTH,
Dennis
On Sat, Sep 18, 2010 at 6:19 PM, Derek Ogle wrote:
> I have a list that looks like this ...
>
> > have <- list(a=7,b=3,c=1)
> > have
> $a
> [1] 7
>
> $b
> [1] 3
>
> $c
> [1] 1
>
>
I have a list that looks like this ...
> have <- list(a=7,b=3,c=1)
> have
$a
[1] 7
$b
[1] 3
$c
[1] 1
and I want to have a simple way to change it to the following without re-typing
the values ...
> desire <- list(a=c(7,7),b=c(3,3),c=c(1,1))
> desire
$a
[1] 7 7
$b
[1] 3 3
$c
[1] 1 1
In othe
On Behalf Of Andrew Anglemyer
> Sent: Wednesday, 28 July 2010 9:22 AM
> To: r-help@r-project.org
> Subject: [R] repeating rows in R
>
> I'm somewhat a new user and have been trying to figure out how to repeat
> rows a certain number of time based on a variable. Currently, the
34
3.3 34
>
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Andrew Anglemyer
Sent: Wednesday, 28 July 2010 9:22 AM
To: r-help@r-project.org
Subject: [R] repeating rows in R
I'm somewhat a new user and have been t
I'm somewhat a new user and have been trying to figure out how to repeat
rows a certain number of time based on a variable. Currently, the number of
rows is not reflective of the number of observations. To get the number of
observations (n=22 in this case), I have to multiply by the variable
NoRe
If I perceive the issue:
Day <- c(rep(97, each = 11), rep(98:278, each = 12))
-
A R learner.
--
View this message in context:
http://r.789695.n4.nabble.com/Repeating-Name-for-Rows-tp2221457p2221492.html
Sent from the R help mailing list archive at Nabble.com.
Hello,
I have a large data frame (47:2186), where i want to label every 12th row.
This command works,
Day <-rep(97:278, each = 12)
However i need 97 to only labeled 11 rows and then from 98:278 can be
labeled every 12 times.
Thanks!
__
R-help@r-proj
Thanks! I've figured out how to fix it, but how I got here is still a
puzzle. :-) Cheers, Don
On Sat, Oct 17, 2009 at 5:36 PM, Peter Ehlers wrote:
>
> Donald Braman wrote:
>
>> Can someone help me understand this results?
>>
>> levels(as.factor(miset1$facts_convict))
>>>
>> [1] "1" "1" "2"
Donald Braman wrote:
Can someone help me understand this results?
levels(as.factor(miset1$facts_convict))
[1] "1" "1" "2" "3" "4" "5" "6"
Don't know how you got your data that way, but I
wonder if you've done str() on your data after
whatever procedure you used to get to this stage.
Here's
Can someone help me understand this results?
> levels(as.factor(miset1$facts_convict))
[1] "1" "1" "2" "3" "4" "5" "6"
converting to numeric and back doesn't seem to help:
> levels(as.factor(as.numeric(miset1$facts_convict)))
[1] "1" "1" "2" "3" "4" "5" "6"
It's messing up my ologits. Any way
88 matches
Mail list logo