Hi Folks
Iam a new user of R and I have a question . Hopefully anyone help me in that
issue
I have that dataset as following
Sample Population Species Tissue R GB
1 Bari1_062-1 Bari1 ret seed 94.52303 80.70346 67.91760
2 Bari1_062-2 Bari1
Have you read the tutorial that comes with the R distribution? This is a very
basic database calculation that you will
encounter (or some slight variation of it) over and over. The solution is a
few lines of code, and someone may write it
out for you, but if no one does
You have 20
On 11/5/2014 5:41 AM, Noha Osman wrote:
Hi Folks
Iam a new user of R and I have a question . Hopefully anyone help me in that
issue
I have that dataset as following
Sample Population Species Tissue R GB
1 Bari1_062-1 Bari1 ret seed 94.52303
While you should definitely read the tutorial that Don is referring
to, I'd recommend you take a different approach and use more R
idiomatic code here.
In base R, this could be addressed with few approaches. Look for help
on the following functions:
* tapply
* by
* aggregate
I'd rather
On 05-11-2014, at 14:41, Noha Osman nmo_...@usc.edu wrote:
Hi Folks
Iam a new user of R and I have a question . Hopefully anyone help me in that
issue
I have that dataset as following
Sample Population Species Tissue R GB
1 Bari1_062-1 Bari1
It's a great method, but there is a memory problem, DFS would occupy a large
memory. So from this point of view, i prefer the loop.
for (i in 1 : nrow(unique)){
tmp=get(past0(DF,i))[1,]
assign(paste0(df,i),tmp)
dfi=dfi[,1:3]
names(dfi)=names(tmp[c(1,4,5)])
dfi=rbind(dfi,tmp[c(1,4,5)])
That code will not work. get() and assign() are troublesome for a
variety of reasons. E.g.,
* adding made-up names to the current environment is dangerous. They
may clobber fixed names in the environment. You may be confused about
what the current environment is (especially when refactoring
Dear all,
I was able to create 102 distinct dataframes (DFs1, DFs2, DFs3, etc) using
the assign() in a loop.
Now, I would like to perform the following transformation for each one of
these dataframes:
df1=DFs1[1,]
df1=df1[,1:3]
names(df1)=names(DFs1[c(1,4,5)])
df1=rbind(df1,DFs1[c(1,4,5)])
I was able to create 102 distinct dataframes (DFs1, DFs2, DFs3, etc) using
the assign() in a loop.
The first step to making things easier to do is to put those data.frames
into a list. I'll call it DFS and your data.frames will now be DFs[[1]],
DFs[[2]], ..., DFs[[length(DFs)]].
DFs -
I've tried several things but I don't manage to get this plot right. Any
help greatly appreciated!
I'm running a for loop to produce 4 plots at once. Each plot should only
show data points for a specific group (i.e. 4 plots for groups 1 to 4).
The coordinates of the points should be petal
On Jun 20, 2014, at 9:18 AM, Bea GD wrote:
I've tried several things but I don't manage to get this plot right. Any help
greatly appreciated!
I'm running a for loop to produce 4 plots at once. Each plot should only show
data points for a specific group (i.e. 4 plots for groups 1 to 4). The
Hi Arun,
Thanks a lot for your script. Ill work on it tomorrow.
Cheers
On 24/04/2014, at 11:54 AM, arun kirshna [via R]
ml-node+s789695n4689356...@n4.nabble.com wrote:
HI,
I guess you got an output like this using my script:
##Please use ?dput() to show the example data.
FA -
HI,
I guess you got an output like this using my script:
##Please use ?dput() to show the example data.
FA - structure(list(Sample = c(L1 Control, L1 Control, L1 Control,
BBM Control, BBM Control, BBM Control, L1 Ash, L1 Ash,
L1 Ash, BBM Ash, BBM Ash, BBM Ash), C14.0 = c(0.456509192,
Hi Arun,
Your script works but it does not do what I was after. To be a bit more
specific, this the table FA in which Im working on ( but the original one
has 34 fatty acids instead of 3: C14.0, C15.0, and C15.1).
SampleC14:0C15:0C15:1
L1 Control0.4565091920.4695626870.774909216
L1
Hi,
Using the example data from library(gvlma)
library(gvlma)
data(CarMileageData)
CarMileageNew - CarMileageData[,c(5,6,3)]
lst1 - list()
y - c(NumGallons, NumDaysBetw)
for(i in seq_along(y)){
lst1[[i]] - gvlma(lm(get(y[i])~MilesLastFill,data=CarMileageNew))
lst1}
pdf(gvlmaplot.pdf)
Thank you Arun for your quick answer.
Ill try it and ill let you know.
Cheers
On 21/04/2014, at 11:30 PM, arun kirshna [via R]
ml-node+s789695n4689190...@n4.nabble.com wrote:
Hi,
Using the example data from library(gvlma)
library(gvlma)
data(CarMileageData)
CarMileageNew -
Hi
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of bett kimutai
Sent: Wednesday, June 26, 2013 3:17 AM
To: Law, Jason; r-help@r-project.org
Subject: Re: [R] Loops
Thanks for you response. The issue is that I need to run
Dear All,
I have spent most of my time trying to figure out how to simulate the number
of breaks in a pipe using monte carlo simulation.
i have 20,000 individual pipes that i have to run, and for each pipe i have to
run 1000 times while checking some conditions and therefore, i have to use a
Dear All,
I have spent most of my time trying to figure out how to simulate the number
of breaks in a pipe using Monte Carlo simulation.
i have 20,000 individual pipes that i have to run, and for each pipe i have to
run 1000 times while checking some conditions and therefore, i have to use a
[mailto:r-help-boun...@r-project.org] On
Behalf Of bett kimutai
Sent: Tuesday, June 25, 2013 1:32 PM
To: r-help@r-project.org
Subject: [R] Loops
Dear All,
I have spent most of my time trying to figure out how to simulate the number
of breaks in a pipe using Monte Carlo simulation.
i have 20,000
Subject: RE: [R] Loops
Not sure what you're trying to do, but it looks like most of what you're
attempting to do in the code can be done just using vectors rather than loops,
at least the inner loop. For example:
k - 1.15
l - exp((1 / k) * (7.16 - 0.44 + 0.12 - 0.016))
z - (log(1 / p) * l)^k
See
I have to use a loop (while or for) to return the result of hadamard
product. now it returns a matrix, but when I use is.matrix() to check, it
returns FALSE, whats wrong?
Matrix.mul - function(A, B)
{
while(is.matrix(A) == FALSE | is.matrix(B) == FALSE )
{print(error)
The comments on StackOverflow are fair, I believe...
Please dput() your matrices, so that your code becomes reproducible!
On Wednesday 12 June 2013 11:14:35 maggy yan wrote:
I have to use a loop (while or for) to return the result of hadamard
product. now it returns a matrix, but when I use
, January 27, 2013 6:17 AM
Subject: Re: [R] Loops
Hello,
I think there is an error in the expression
100-(100*abs(fa1[i]/sum(fa1[i])-(1/3)))
Note that fa1[i]/sum(fa1[i]) is always 1. If it's fa1[i]/sum(fa1), try
the following, using lists to hold the results.
# Make up some data
set.seed(6628
Dear Contributors,
I am asking help on the way how to solve a problem related to loops for
that I always get confused with.
I would like to perform the following procedure in a compact way.
Consider that p is a matrix composed of 100 rows and three columns. I need
to calculate the sum over some
Hello,
I think there is an error in the expression
100-(100*abs(fa1[i]/sum(fa1[i])-(1/3)))
Note that fa1[i]/sum(fa1[i]) is always 1. If it's fa1[i]/sum(fa1), try
the following, using lists to hold the results.
# Make up some data
set.seed(6628)
p - matrix(runif(300), nrow = 100)
idx -
Dear Contributors,
I am asking help on the way how to solve a problem related to loops for
that I always get confused with.
I would like to perform the following procedure in a compact way.
Consider that p is a matrix composed of 100 rows and three columns. I need
to calculate the sum over
On 27.01.2013 12:50, Richard D. Morey wrote:
Dear Contributors,
I am asking help on the way how to solve a problem related to loops for
that I always get confused with.
I would like to perform the following procedure in a compact way.
Consider that p is a matrix composed of 100 rows and three
.
- Original Message -
From: Rui Barradas ruipbarra...@sapo.pt
To: Francesca francesca.panco...@gmail.com
Cc: r-help@r-project.org
Sent: Sunday, January 27, 2013 6:17 AM
Subject: Re: [R] Loops
Hello,
I think there is an error in the expression
100-(100*abs(fa1[i]/sum(fa1[i])-(1/3)))
Note that fa1[i
Hi
I'm running QDA on some data and calculating the discriminant function.
qda.res - qda(type ~ npreg + glu + bp + skin + bmi + ped + age)
ind_yes - c(1:N)[type == Yes]
ind_no - c(1:N)[type == No]
cov_yes - cov(table[ind_yes, 1:7] )
cov_no - cov(table[ind_no, 1:7] )
covar-list(cov_no,
I've been struggling to get a loop to work. I want to create a new
variable in each loop with data from some function.
for example:
# part of the names for the variables to be created
Frags - c(F04, F05, F07, F09, F11, F13, F14, F17, F18,
F19, P20, Main)
for(obs in Frags) {
A.*obs* -
You can use the assign() function. E.g., assign(a, 3,)
But the more R thing to do is to create a list of your results (which
you can name) and to handle that whole object. Then if you want to do
things to each object you create, it's as simple as lapply
Michael
On Tue, Jan 24, 2012 at 7:27 PM,
Dear R help listers,
I am trying to replicate results in Gelman and Hill's book (Chapter 3
in regressions and multilevel models). Below I estimated two models
(chp3.1 and chp3.3 in R codes) with the same data and dependent
variable but different independent variables. I have been using Stata
for
Hi
Dear R help listers,
I am trying to replicate results in Gelman and Hill's book (Chapter 3
in regressions and multilevel models). Below I estimated two models
(chp3.1 and chp3.3 in R codes) with the same data and dependent
variable but different independent variables. I have been using
Thanks a lot,
it was very helpful, I did something like that:
EV - ifelse(sprd mediaSDP sprd_d = mediaSDP_d, -1, 0)
SV - ifelse(sprd media sprd_d = media_d, -17, 0)
EC - ifelse(sprd mediaSDN sprd_d = mediaSDN_d,1,0)
SC - ifelse(sprd media sprd_d = media_d,17,0)
in order to have 4
Dear all,
this is my first post and I´m very new at R, I don´t know if somebody can
help with an issue.
I´m doing some exercices and I don´t know if for example I can convert this
for in an operation with vectors:
for (i in 2:n){
if (ES[i-1]==0 sprd[i-1]mediaSDP[i-1]
Look at ?ifelse. You'll need to nest them however. If you are feeling a little
more ambitious this can be done with ?switch, but for clarity, I'd rather see
pre-allocation followed by assignments Something along this pattern:
out - numeric(50)
x - sample(3, 50, TRUE)
out[x==3] - A
out[x==2] -
Thank you so much!
foreL-8
b0f-matrix(nrow=9, ncol=foreL)
ct-1 ### use this as the index of b0f
for(ar.ord in 1:3){
for(ma.ord in 1:3){
b0f[ct,]-c(predict(arima(para_qtr[1:(n-8),1],order=c(ar.ord,1,ma.ord)),
n.ahead=foreL)$pred)
ct-ct+1 ### increment the counter
}
}
this one works! Best regards!
The first thing I'd mention is that *apply are really just well implemented
loops themselves so you can't expect true magic from them. However, if you
really want to use them rather than just a regular loop (which seems more
intuitive for a request like this), this might do what you are looking
Dear forum,
I would like to forecast e.g. with the arima-model. To figure out which
model works best I am going to predict with this models.
my first code:
for(ar.ord in 1:3){
for(ma.ord in 1:3){
print(predict(arima(para_qtr[1:(n-8),1],order=c(ar.ord,1,ma.ord)),
n.ahead=8)$pred)
}
}
this one
A little bit change of your code may do the work
foreL-8
b0f-matrix(nrow=9, ncol=foreL)
ct-1 ### use this as the index of b0f
for(ar.ord in 1:3){
for(ma.ord in 1:3){
b0f[ct,]-c(predict(arima(para_qtr[1:(n-8),1],order=c(ar.ord,1,ma.ord)),
n.ahead=foreL)$pred)
ct-ct+1 ### increment the counter
}
}
Look at the combinations function in gtools and index by the rows of that
output for a single loop. Pass values as the three parameters.
Sorry for being terse - writing on my phone.
Michael
On Sep 14, 2011, at 5:36 PM, Fred christoph_wege...@gmx.de wrote:
Dear forum,
I would like to
Hi Michael,
First of all thanks for your response.
I do know that if I make my stimation on a single data the regression has no
sense but it will be getting sense in the growing next estimations.
I change my asking doubt.
I want to use this regressions as a first filter. Only this.
Can anyone
Hi all,
I have a time series a column vector with the ordered data so that the first
column is the first observation and so on.
The fact is that I want to run a multiple regression with only intercept.
My first task is to run the regression on the first observation (1 from 276)
and at the same
I may be totally off base with this, but I'm wondering what exactly this
would suggest or why you want to do it. Specifically multiple regression
with only intercept -- how is it multiple if you don't have any regressors?
Furthermore, you want to run a regression on a single data point --
really?
Hi:
Try this:
## Function that takes a data frame as input and outputs a data frame:
chrSumm - function(d) { # d is a data frame
colnames(d) - c(chr,start,end,base1,base2,
totalreads,methylation,strand)
TR - nrow(d)
RG1 - sum(d['totalreads'] = 1)
percent -
Hello,
I have an R script that I use as a template to perform a task for multiple
files (in this case, multiple chromosomes).
What I would like to do is to utilize a simple loop to parse through each
chromosome number so that I don't have to type the same code over and over
again in the R
-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of a217
Sent: Wednesday, 10 August 2011 4:32 p.m.
To: r-help@r-project.org
Subject: [R] Loops for repetitive task
Hello,
I have an R script that I use as a template to perform a task for
multiple
files
Dear R help,
I am fairly new in data management and programming in R, and am trying to write
what is probably a simple loop, but am not having any luck. I have a dataframe
with something like the following (but much bigger):
Dates-c(12/10/2010,12/10/2010,12/10/2010,13/10/2010,
]
Namens Chandra Salgado Kent
Verzonden: dinsdag 2 augustus 2011 9:12
Aan: r-help@r-project.org
Onderwerp: [R] Loops to assign a unique ID to a column
Dear R help,
I am fairly new in data management and programming in R, and am trying to
write what is probably a simple loop, but am
AM
To: r-help@r-project.org
Subject: [R] Loops to assign a unique ID to a column
Dear R help,
I am fairly new in data management and programming in R, and am trying to
write what is probably a simple loop, but am not having any luck. I have a
dataframe with something like the following
Station, TX 77843-4352
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Chandra Salgado Kent
Sent: Tuesday, August 02, 2011 2:12 AM
To: r-help@r-project.org
Subject: [R] Loops to assign a unique ID to a column
Dear R help,
I
On Wed, Jul 20, 2011 at 10:43 PM, David Winsemius
dwinsem...@comcast.net wrote:
On Jul 21, 2011, at 1:04 AM, Daniel Malter wrote:
http://mlg.eng.cam.ac.uk/dave/rmbenchmark.php
I haven't ever tried it myself, but online sources suggest that Matlab
possibly gains speed by internally avoiding
On Jul 20, 2011, at 1:34 AM, Daniel Malter wrote:
snipped
requests, except that you were referring to SAS and had heard that R
does
not like loops. (This is factually wrong. But R can be slow looping).
Where did you hear this? Can you cites any references?
--
David Winsemius, MD
West
From: David Winsemius [dwinsem...@comcast.net]
Sent: Wednesday, July 20, 2011 9:01 AM
To: Daniel Malter
Cc: r-help@r-project.org
Subject: Re: [R] loops and simulation
On Jul 20, 2011, at 1:34 AM, Daniel Malter wrote:
snipped
requests, except that you were
From: David Winsemius [dwinsem...@comcast.net]
Sent: Wednesday, July 20, 2011 9:01 AM
To: Daniel Malter
Cc: r-help@r-project.org
Subject: Re: [R] loops and simulation
On Jul 20, 2011, at 1:34 AM, Daniel Malter wrote:
snipped
requests, except that you were
I dare the conjecture that if you had written the code, you would know how to
do this. This suggests that you are asking us to do your homework, which is
not the purpose of this list. A simple inclusion of the code in a for or
while loop and storing the estimated parameters with the index of the
Yes, there are in Europe. And there are summer classes in the US, as well.
And no, this list is not so much about helping beginners to learn R. For
that, there is a myriad of online sources. Rather, this list is for people
who have exhausted their ability to (elegantly) solve a problem.
Also, it
Is there a way to apply paste to list(form1 = EQ1, form2 = EQ2, form3 = EQ3,
form4 = EQ4) such that I don't have to write form1=EQ1 for all my models (I
might have a list of 20 or more)? I also need the EQs to read the formulas
associated with them.
For example, below, I was able to automate
Hello,
I am very new to R and data analysis in general.
I am trying to generate values to append to my data frame using
conditional statements.
I am playing with this simple example:
a - c(1:4)
b - c(meep, foo, meep, foo)
d - cbind(a, b)
now what I want to do is , each time there is a meep in
You are working with a matrix, so the $ operator is not allowed (e.g.,
d$c).
Also in your test, you have to test against the second column (e.g., d[i,
2])
try this:
a - c(1:4)
b - c(meep, foo, meep, foo)
d - cbind(a, b)
for(i in seq(along=d[,2])) {if (d[i,2]==meep) { print(oops)}
+
Hey Laura,
Just to add a cautionary note, in
a - c(1:4)
b - c(meep, foo, meep, foo)
d - cbind(a, b)
d is a matrix and will only be one type of matrix. Since you have
both integer (a) and character (b) data, it has to be at the character
level. From the help for cbind:
The type of a
Thank you so much all!
How a simple problem can get complicated by not having enough
knowledge, but hopefully I am learning
Have a great Sunday!
L
On Sun, Apr 18, 2010 at 4:56 PM, jim holtman jholt...@gmail.com wrote:
You are working with a matrix, so the $ operator is not allowed (e.g.,
I would prefer version 1.
Version to creates a global variable R which you do not really need
since it contains the same values as d$r.
In option 2, you should probably remove the variable r itself
after it has been appended to d.
On 4/18/2010 5:23 PM, Laura Ferrero-Miliani wrote:
Thanks for
it did help to create the separate vectors. The problem is, I would like
to continue working with each vector on its own and make some further
analysis.
For that i need to allocate each vector in the filePatterns a unique name,
which I just can't do.
I'm not so great in R loops and the help
hello everybody,
I have a directory with over 3000 files with different names. I would like
to make some vectors with the file names which are belong together.
I'm trying to do it with a for loop in R:
SF - c(ad, cd, cer, stress, salty, PC, high, transfer,
cold, heat) # the pattern to look
[EMAIL PROTECTED] wrote:
hello everybody,
I have a directory with over 3000 files with different names. I would like
to make some vectors with the file names which are belong together.
I'm trying to do it with a for loop in R:
SF - c(ad, cd, cer, stress, salty, PC, high, transfer,
cold,
hi!!
Below I have 4 columns vector of c and d which are unequal in length.These c
and d have 2 columns each where these 2 columns represent an interval values. I
easily get these overlapping interval values by using these code:
s-apply(c,1,rev)
])}
tot
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
--
View this message in context:
http://www.nabble.com/R-loops-tp15135671p15135671.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https
On 1/28/2008 8:48 AM, cvandy wrote:
I'm a new user and am having trouble with loops.
In the following, I'm trying to add the results of test and the loops are
not working.
I've simplified the loop. What am I doing wrong?
Thanks!
test-numeric(20)
tot-numeric(20)
for(i in 1:20){test[i]-1}
Hi Garth,
Your code is really confusing! You should start by reading the help file
on the for() function and understanding what it does:
?for
Your line
for(i in 1:nboot){
}
is simply starting a loop around the variable 'i', which will change
values following the sequence 1:nboot.
It seems
Hi,
I'm new to R (and statistics) and my boss has thrown me in the deep-end with
the following task:
We want to evaluate the impact that sampling size has on our ability to create
a robust model, or evaluate how robust the model is to sample size for the
purpose of cross-validation
72 matches
Mail list logo