Hello,
As for the first question, you can do something like
Timeframemin<-10
Timefram<-1
uFrame <- seq(Timeframemin, Timefram, by = 10)
for(u in uFrame) {}
As for the second question, the answer is yes, there is a print()
function, which can be used for your purpose.
Hope this helps
Hi all,
I want to execute a loop of a program:
for (u in Timeframemin:Timeframe){}
Imagine that Timeframemin<-10
Timefram<-1
Is it posible to execute the loop but only proving from 10 to 1 but
jumping 10 each time, for example, execute for 10,20,30.to Timeframe.
Other question is,
The unlist-sapply-seq_len bit is unnecessarily convoluted, since the
infcprodessa function can accept vector inputs.
z <- infcprodessa( ab$a, TINF, ab$b, ab$b-TINF )
possibles <- ab[ z >= 15 & z <= 20, ]
possibles[ which.min( possibles$a ), ]
--
On 26-01-2013, at 12:31, Andras Farkas wrote:
>
> Sorry Jeff, probably the new version of Yahoo mail doing the html, I switched
> back to the older one hope that takes care of the problem. Let me clarify the
> code below:
>
> TINF <-1
> a <-c(500,750,1000,1250,1500,1750,2000)
> b <-c(8,12,18
Andras
--- On Sat, 1/26/13, Jeff Newmiller wrote:
> From: Jeff Newmiller
> Subject: Re: [R] Loop question?
> To: "Andras Farkas" , "r-help@r-project.org"
>
> Date: Saturday, January 26, 2013, 2:09 AM
> Please read the Posting Guide
> no html email
Here's a toy example which you can apply the logic of:
dfr <- expand.grid(1:3,1:2)
results <- apply(dfr, 1, sum)
dfr[results==4,]
On 25 January 2013 22:19, Andras Farkas wrote:
>
> Dear All
>
> I have the following data (somewhat simplyfied):
>
> TINF <-1
> a <-c(500,750,1000,1250,1500,1750,
Please read the Posting Guide
no html email
reproducible example please
In general, you can use expand.grid to generate all combinations of inputs,
compute results as a vector just as long as the expand.grid data frame has
rows, and identify which results meet your criteria by a logical test, an
Dear All
I have the following data (somewhat simplyfied):
TINF <-1
a <-c(500,750,1000,1250,1500,1750,2000)
b <-c(8,12,18,24,36,48,60,72,96)
following function:
infcprodessa <-function (D, tin, tau, ts)
(D * (1 - exp(-0.048 * tin))/(tin * (0.048*79) * (1 - exp(-0.048 * tau *
exp(-0.0
tto
To: "r-help@r-project.org"
Cc:
Sent: Wednesday, January 2, 2013 12:00 PM
Subject: [R] loop correction needed
Dear useRs,
i have a data frame with 16 lists in it. each list has variable number of
lines. i want to create a loop which will start deleting every 32nd line in
each list,
On Jan 2, 2013, at 9:00 AM, eliza botto wrote:
Dear useRs,
i have a data frame with 16 lists in it. each list has variable
number of lines. i want to create a loop which will start deleting
every 32nd line in each list, till the end of each list. more
precisely if a list has 200 rows i w
Dear useRs,
i have a data frame with 16 lists in it. each list has variable number of
lines. i want to create a loop which will start deleting every 32nd line in
each list, till the end of each list. more precisely if a list has 200 rows i
want to delete row number 32, 64, 96 and so on...for th
Hi Listers
I need to calculate and then plot a frequency histogram of the best tree
calculated using the 1-se rule. I have included some code that has worked
well for me in the past but it was only for selecting the minimum
cross-validation error. I include the code for my model, some relevant
out
hello guys!
thank u for the help, but u didnt understood what i need.
1st, it is a[i] cuz i want to sum 1 + x[i], for all i's not j.
but i've solved it! :)
like i said, my code is more complex, but, if you need to integrate several
functions in a loop, thats what you should do:
w2 = seq(-1,-1/3,l
On 30-11-2012, at 19:34, Berend Hasselman wrote:
>
> On 30-11-2012, at 16:08, faeriewhisper wrote:
>
>> Hi guys!
>> I have to compute something and i don't know what i'm doing wrong. my code
>> is a bit complex, but imagine that is something like this:
>>
>> a = c(1,2,3,4)
>> ia = length(a)
On 30-11-2012, at 16:08, faeriewhisper wrote:
> Hi guys!
> I have to compute something and i don't know what i'm doing wrong. my code
> is a bit complex, but imagine that is something like this:
>
> a = c(1,2,3,4)
> ia = length(a)
>
> x = seq(1,100,length=0.1)
> ib = length(x)
>
> int1 =
Hello,
Your code doesn't run without initializing 'ss' to something. And I've
made some changes, but I don't understand what you are trying to do. See
comments inline.
a = c(1,2,3,4)
ia = length(a)
x = seq(1, 100, by=0.1) # It was 'length = 0.1' (!)
ib = length(x)
ss <- numeric(ia) # Ne
Now i've managed to do this:
funcs <- list()
funcs[]
# loop through to define functions
for(i in 1:ib-1){
# Make function name
funcName <- paste( 'func', i, sep = '' )
# make function
func = paste('function(x){sin(x + a[', i,'])))}',sep = '')
funcs[[funcName]] = eval(parse(
Hi guys!
I have to compute something and i don't know what i'm doing wrong. my code
is a bit complex, but imagine that is something like this:
a = c(1,2,3,4)
ia = length(a)
x = seq(1,100,length=0.1)
ib = length(x)
int1 = numeric(ib)
b = numeric(ib)
for(j in 1:ia) {
H = function(x) {
__
From: eliza botto
To: "smartpink...@yahoo.com"
Sent: Tuesday, November 27, 2012 1:53 PM
Subject: RE: [R] loop command to matrix
thanks arun. i m more interested in learning commands.
thankyou so much
eliza
> Date: Tue, 27 Nov 2012 10:45:37 -0800
> From: smartpink...@ya
137.0 -97.28571
A.K.
- Original Message -
From: eliza botto
To: "r-help@r-project.org"
Cc:
Sent: Tuesday, November 27, 2012 12:51 PM
Subject: [R] loop command to matrix
Dear UseRs,Extremely sorry for a basic question. I have a matrix of 19 rows and
365 columns. what
Sorry again,
project is part of the rgdal package.
Tagmarie
--
View this message in context:
http://r.789695.n4.nabble.com/loop-with-date-tp4650961p4651005.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing
thanks rui!! how can it be that you advise something and it doesn't work :)
eliza
> Date: Tue, 27 Nov 2012 18:14:41 +
> From: ruipbarra...@sapo.pt
> To: eliza_bo...@hotmail.com
> CC: r-help@r-project.org
> Subject: Re: [R] loop command to matrix
>
> Hello,
>
Hello,
Try
x <- matrix(1:18, ncol = 6)
sapply(seq_len(ncol(x)), function(i) x[, i] - rowMeans(x[, -i]))
Hope this helps,
Rui Barradas
Em 27-11-2012 17:51, eliza botto escreveu:
Dear UseRs,Extremely sorry for a basic question. I have a matrix of 19 rows and 365
columns. what i want to do is
Dear UseRs,Extremely sorry for a basic question. I have a matrix of 19 rows and
365 columns. what i want to do is the following...First i want to leave out
column number 1 and want to calculate the row wise mean of the remaining
columns, which will obviously give me 365 values in one column, an
Ok, sorry, I thought the more complex details might be confusing and nobody
might answer.
Here is something which looks more like my real dataframe and also what I
want to do with it:
That's my data frame:
myframe <- data.frame (Timestamp=c("24.09.2012 09:00", "24.09.2012 10:00",
"24.09.2012 1
4.00
It is better to show the complex data as an example using dput()
A.K.
- Original Message -
From: Tagmarie
To: r-help@r-project.org
Cc:
Sent: Tuesday, November 27, 2012 9:02 AM
Subject: [R] loop with date
Hello,
I tried to construct my very first loop today and completly
Here is an example of an approach:
> myframe <- data.frame (Timestamp=c("24.09.2012 09:00", "24.09.2012 10:00",
+ "24.09.2012 11:00",
+"25.09.2012 09:00", "25.09.2012 10:00",
+ "25.09.2012 11:00"),
+ Speed=c(1,1,2,5,1,6))
> myframestime <
On Tuesday, November 27, 2012, Tagmarie wrote:
> Hello,
> I tried to construct my very first loop today and completly failed :-(
> Maybe someone can help me?
> I have a dataframe somewhat like this one:
>
> myframe <- data.frame (Timestamp=c("24.09.2012 09:00", "24.09.2012 10:00",
> "24.09.2012 11
Hello,
I tried to construct my very first loop today and completly failed :-(
Maybe someone can help me?
I have a dataframe somewhat like this one:
myframe <- data.frame (Timestamp=c("24.09.2012 09:00", "24.09.2012 10:00",
"24.09.2012 11:00",
"25.09.2012 09:0
(res3,3)
# V1 V2
#1 -0.001 -0.001
#2 0.003 0.003
#3 -1.181 0.169
A.K.
- Original Message -
From: iembry
To: r-help@r-project.org
Cc:
Sent: Sunday, November 18, 2012 8:41 PM
Subject: [R] loop to subtract arrays / error
Hi everyone, I am having trouble with creating a
Hi Arun, thanks for your assistance. That worked as well.
Irucka
<-Original Message->
>From: arun [smartpink...@yahoo.com]
>Sent: 11/19/2012 7:22:09 AM
>To: iruc...@mail2world.com
>Cc: r-help@r-project.org
>Subject: Re: [R] loop to subtract arrays / error
>
Hi Rui, thank-you.
That was simple and worked great.
Irucka
<-Original Message->
>From: Rui Barradas [ruipbarra...@sapo.pt]
>Sent: 11/19/2012 4:13:24 AM
>To: iruc...@mail2world.com
>Cc: r-help@r-project.org
>Subject: Re: [R] loop to subtract arrays / error
&g
Hi Rui Barradas, how are you?
Thank-you very much. That worked perfectly.
Irucka Embry
<-Original Message->
>From: Rui Barradas [ruipbarra...@sapo.pt]
>Sent: 11/19/2012 4:05:11 AM
>To: iruc...@mail2world.com
>Cc: r-help@r-project.org
>Subject: Re: [R] loop to su
Hello,
Or simpler, since Vobsr only has one column:
Xjj <- as.vector(Vobsr) - Vsimr
Hope this helps,
Rui Barradas
Em 19-11-2012 10:05, Rui Barradas escreveu:
Hello,
Try the following.
Xjj <- matrix(nrow = 101, ncol = 1000)
for (i in 1:dim(Vsimr)[2]) {
Xjj[, i] <- Vobsr - Vsimr[, i]
}
H
Hello,
Try the following.
Xjj <- matrix(nrow = 101, ncol = 1000)
for (i in 1:dim(Vsimr)[2]) {
Xjj[, i] <- Vobsr - Vsimr[, i]
}
Hope this helps,
Rui Barradas
Em 19-11-2012 01:41, iembry escreveu:
Hi everyone, I am having trouble with creating a loop to subtract arrays.
In R, this is what
Hi everyone, I am having trouble with creating a loop to subtract arrays.
In R, this is what I have done:
> Vobsr <- read.csv("Observed_Flow.csv", header = TRUE, sep =",") # see data
> below
> Vsimr <- read.csv("1000Samples_Vsim.csv", header = TRUE, sep =",") # see
> data below
> Vobsr <- as.matr
Hey John,
thanks for making me notice that document - I just skipped over it the past
hour and I think I like that very condensed If you want to do this ->it
works like that approach. Besides that I had the impression, though that
it's content - while more strongly condensed - is basically not too
In Line
John Kane
Kingston ON Canada
> -Original Message-
> From: bochrist...@web.de
> Sent: Fri, 2 Nov 2012 05:34:48 -0700 (PDT)
> To: r-help@r-project.org
> Subject: Re: [R] Loop over several Variables, add on question
>
> Hey Petr,
>
> thanks for answer
Thanks very much Petr, that one did just fine!
I just wanted to say that it's not that I did no reading at all (in fact I
use a book called R for Stata users by Muenchen/Hilbe and another German
book called Programming in R when you translate the title) - so yes I am
aware that R works quite diff
g
> Subject: Re: [R] Loop over several Variables, add on question
>
> Hey Petr,
>
> thanks for answering. First to your question: I use rename from the
> reshape package.
> You are probably right to assume that I do not have a to extensive
> reading background in R -
Inline.
On Fri, Nov 2, 2012 at 5:34 AM, bchr wrote:
> Hey Petr,
>
> thanks for answering. First to your question: I use rename from the reshape
> package.
> You are probably right to assume that I do not have a to extensive reading
> background in R - basically I had to dive right in (which prob
Hey Petr,
thanks for answering. First to your question: I use rename from the reshape
package.
You are probably right to assume that I do not have a to extensive reading
background in R - basically I had to dive right in (which probably isn't a
good idea, but I could not change that). Having a s
Hi
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of bchr
> Sent: Friday, November 02, 2012 11:57 AM
> To: r-help@r-project.org
> Subject: [R] Loop over several Variables, add on question
>
> Hey ev
Hey everyone,
I have again a loop question:
After generating the dataset using Jan’s approach from my previous posting
(http://r.789695.n4.nabble.com/Loop-over-several-variables-td4648112.html) I
want to rename the Variables in the new dataset so that all y will be called
tiy. Doing it separately
Oh hey Jan, sorry, I just saw I did not read correctly and mistook your quote
of Don's mail as a signature. So thank's to you for the second posting
Bernhard
--
View this message in context:
http://r.789695.n4.nabble.com/Loop-over-several-variables-tp4648112p4648132.html
Sent from the R help
Hey Don,
I just saw your second post ... that's even better!
Thanks again
Bernhard
--
View this message in context:
http://r.789695.n4.nabble.com/Loop-over-several-variables-tp4648112p4648131.html
Sent from the R help mailing list archive at Nabble.com.
Hey Don,
many thanks, I tried that and it works just fine. I have two questions
though:
1. In Addition to generating the t1-t5 (I have five iterations, in fact),
the code will generate an additional ti(without subscript), which seems to
be a copy of ti5. Is that what it should do ( and if yes, wh
Or
ti <- aggregate(dataframename[paste0("y", 1:3)],
by=dataframename["aggregationvar"],
sum,na.rm=TRUE)
which gives you all results in one data.frame.
Jan
"MacQueen, Don" schreef:
Many ways. Here is one:
### supposing you have y1, y2, and y3 in your data frame
for (i in
Many ways. Here is one:
### supposing you have y1, y2, and y3 in your data frame
for (i in 1:3) {
yi <- paste('y',i,sep='')
ti <- aggregate(dataframename[[yi]],
by=data.frame(dataframename$aggregationvar),
sum,na.rm=TRUE)
assign( paste('ti',i,sep='') , ti, '.GlobalE
Hey everybody,
I am looking for a way to loop commands over several variables in a
dataframe. Basically I want to do something like this:
ti1<-aggregate(dataframename$y1,
by=data.frame(dataframename$aggregationvar),
sum,na.rm=TRUE)
This works fine as it is but i wan
On Oct 17, 2012, at 7:23 AM, Charles Determan Jr wrote:
Greetings R users,
My goal is to generate quartile groups of each variable in my data
set. I
would like each experiment to have its designated group added as a
subsequent column. I can accomplish this individually with the
followin
Hello,
There's no function cut2() but it's not very difficult to write one.
I've named your data example 'dat', it saves keystrokes.
Try the following.
dat <- structure(...etc...)
cut2 <- function(x, g = 0){
cut(x, breaks = c(-Inf, seq(min(x), max(x), length.out = g)))
}
fun <- function(
Greetings R users,
My goal is to generate quartile groups of each variable in my data set. I
would like each experiment to have its designated group added as a
subsequent column. I can accomplish this individually with the following
code:
brks <- with(data_variables,
cut2(var2, g=
,1,sum))
#or
res1<-mapply(FUN=function(i) mat1[,i]-rowSums(mat1), 1:ncol(mat1))
A.K
- Original Message -
From: eliza botto
To: "r-help@r-project.org"
Cc:
Sent: Friday, October 5, 2012 4:05 PM
Subject: [R] loop for column substraction of a matrix
Dear useRs,
I have a
Dear Arun and Barradas,
millions of thanks. you guys always rock.
regards
eliza
> Date: Fri, 5 Oct 2012 14:41:38 -0700
> From: smartpink...@yahoo.com
> Subject: Re: [R] loop for column substraction of a matrix
> To: eliza_bo...@hotmail.com
> CC: ruipbarra...@sapo.pt; r-help@r-proj
1[,i]-apply(mat1,1,sum
#or
res1<-sapply(1:ncol(mat1), function(i) mat1[,i]-apply(mat1,1,sum))
#or
res1<-mapply(FUN=function(i) mat1[,i]-rowSums(mat1), 1:ncol(mat1))
A.K
- Original Message -
From: eliza botto
To: "r-help@r-project.org"
Cc:
Sent: Friday, October 5, 201
: Friday, October 5, 2012 4:05 PM
Subject: [R] loop for column substraction of a matrix
Dear useRs,
I have a matrix with 38 columns and 365 rows. what i want to do is the
following.
1. subtracting from each column, first itself and then all the remaining
columns. More precisely, from colu
Hello,
1. Let me refrase it a bit. For each column, sum all others and take the
symmetric.
mat <- matrix(1:30, ncol = 3)
sapply(seq_len(ncol(mat)), function(i) -rowSums(mat[, -i]))
2. write.table (maybe using sep = "\t" ?) and send the file to printer.
Hope this helps,
Rui Barradas
Em 05
Dear useRs,
I have a matrix with 38 columns and 365 rows. what i want to do is the
following.
1. subtracting from each column, first itself and then all the remaining
columns. More precisely, from column number 1, i will first subtract
itself(column 1) and then the remaining 37 columns.
Does anyone know how to loop in GME using a list of text values. I am trying
to create home ranges for each animal in a point shapefile of locations.
Here is an example of the Command Text I am trying to use:
l<-'SGF4037', 'SGF4244';
for (i in ls()){
kde(in=paste("SGF.shp"), out=paste(i,"_SGF.i
Hello,
For example:
url <- c("http://www.example.com";, "http://www.example5.com";)
res <- vector("list", length(url))
for (i in 1:length(url)) res[[i]] <- try(readLines(url[i]), silent = TRUE)
res[[2]]
## [1] "Error in file(con, \"r\") : cannot open the connection\n"
## attr(,"class")
## [1] "tr
I have a loop over readLines(URL[i]) which works fine until it hits a bad URL
(e.g., a
URL that returns a 404 Error).
How can I handle this with a test for this error condition.
I read the tryCatch( … ) description but can't figure out how to apply it here.
Perhaps
there is something else that
Hello,
Simple, look carefully at what you have, rho is a function (type
closure), the vector is rhoes.
And you are trying to print rho[i], the i-th function in the "vector"
called rho.
print( rhoes[i] ) # works
Hope this helps,
Rui Barradas
Em 26-07-2012 06:40, Rafael_Leon escreveu:
Hi e
Hi everyone,
I've got the following problem:
I've got a matrix [1000,2] and two vectors. In very matrix row there is two
coefficients b0 and b1. The vectors are two variables x and y. I want to do
a loop to take b0 and b1 and with x and y calculate the residual of a linear
model and calculate t
Thank you Rui. Very helpful. Yolande.
On Wed, Jul 18, 2012 at 1:37 PM, Rui Barradas wrote:
> Hello,
>
> Try the following.
>
>
> for(i in 1:dim(diveData_2008)[1]){
> # Which dive is this observation from
> thisIndex <- as.character(index(diveData_**2008[i,]))
> thisIndex <- as.PO
Hello,
Try the following.
for(i in 1:dim(diveData_2008)[1]){
# Which dive is this observation from
thisIndex <- as.character(index(diveData_2008[i,]))
thisIndex <- as.POSIXct(thisIndex)
dive_id <- diveCond_all$dive_id[diveCond_all$timestamp == thisIndex]
#
it is a function from library(xts)
On Wed, Jul 18, 2012 at 1:15 PM, Jean V Adams wrote:
> What is the function index() that you use in this line of code?
> thisIndex <- as.character(index(diveData_2008[i,]))
>
> Is it from some package? Or a function you wrote yourself?
> I'm trying to run the
What is the function index() that you use in this line of code?
thisIndex <- as.character(index(diveData_2008[i,]))
Is it from some package? Or a function you wrote yourself?
I'm trying to run the code you submitted, but I don't have a function
called index().
Jean
Yolande Tra wrote on 07/18
Hello,
I have the following loop for two data sets: diveData_2008 and
diveData_2009. It uses two other data: diveCond_all and fishTable. The
problem is at the point to identify the dive_id for the given index (index
is timestamp). It keeps on saying
for the1st loop
Error in fishReport$dive_id[i] <
>>> (Intercept) Market
>>> -31
>>>
>>>
>>> $Stock2
>>>
>>> Call:
>>> lm(formula = x ~ Market, data = dat1)
>>>
>>> Coefficients:
>>> (Intercept) Market
>>>
Market 1 1 1
A.K.
From: Bert Gunter
To: arun
Cc: Akhil dua ; R help
Sent: Wednesday, July 4, 2012 2:48 PM
Subject: Re: [R] loop for regression
Please carefully read ?lm. As I previously told the OP, no looping/apply is
necessary. The
gt;>
>> Coefficients:
>> (Intercept) Market
>> -21
>>
>>
>> $Stock3
>>
>> Call:
>> lm(formula = x ~ Market, data = dat1)
>>
>> Coefficients:
>> (Intercept) Market
>> -11
>
gt;
> Coefficients:
> (Intercept) Market
> -11
>
> A.K.
>
>
>
>
> - Original Message -
> From: Akhil dua
> To: r-help@r-project.org
> Cc:
> Sent: Wednesday, July 4, 2012 1:08 AM
> Subject: [R] loop for regression
>
ct.org
Cc:
Sent: Wednesday, July 4, 2012 1:08 AM
Subject: [R] loop for regression
-- Forwarded message --
From: Akhil dua
Date: Wed, Jul 4, 2012 at 10:33 AM
Subject:
To: r-help@r-project.org
Hi everyone I
have data on stock prices and market indices
and I need to run a sepera
Hi,
A few comments. First a for loop is probably not optimally efficient.
Consider instead (using a bulit in example dataset):
lm(cbind(mpg, hp) ~ cyl + vs, data = mtcars)
which gives:
Call:
lm(formula = cbind(mpg, hp) ~ cyl + vs, data = mtcars)
Coefficients:
mpg hp
(Inter
?lm
and note in particular the section beginning "If response is a matrix..."
-- Bert
On Tue, Jul 3, 2012 at 10:08 PM, Akhil dua wrote:
> -- Forwarded message --
> From: Akhil dua
> Date: Wed, Jul 4, 2012 at 10:33 AM
> Subject:
> To: r-help@r-project.org
>
>
> Hi everyone I
> h
Homework? (We don't do homework here).
-- Bert
On Tue, Jul 3, 2012 at 10:08 PM, Akhil dua wrote:
> -- Forwarded message --
> From: Akhil dua
> Date: Wed, Jul 4, 2012 at 10:33 AM
> Subject:
> To: r-help@r-project.org
>
>
> Hi everyone I
> have data on stock prices and market ind
-- Forwarded message --
From: Akhil dua
Date: Wed, Jul 4, 2012 at 10:33 AM
Subject:
To: r-help@r-project.org
Hi everyone I
have data on stock prices and market indices
and I need to run a seperate regression of every stock on market
so I want to write a "for loop" so that I wo
Hello,
Sorry, forgot to Cc the list.
Em 01-07-2012 01:24, R. Michael Weylandt
escreveu:
I might think replicate() is slightly more idiomatic, but I'm not in a position
to check if simplify=FALSE will keep a list.
It does:
class(replicate(20, f(1))) # "matrix"
class(replicate(20, f(1), s
I might think replicate() is slightly more idiomatic, but I'm not in a position
to check if simplify=FALSE will keep a list.
Best,
Michael
On Jun 30, 2012, at 7:13 PM, Rui Barradas wrote:
> Hello,
>
> You can avoid the loop using lapply.
>
> f <- function(x) sample(100, 10)
> samp.list <- l
Hello,
You can avoid the loop using lapply.
f <- function(x) sample(100, 10)
samp.list <- lapply(1:20, f)
will choose 20 samples of 10 integers up to 100 and put them in a list.
All you need is to write a function f(). f() must have an argument, even
if it doesn't use it. If you need other ar
23.65078
---
A.K.
- Original Message -
From: solafah bh
To: R help mailing list
Cc:
Sent: Saturday, June 30, 2012 3:34 PM
Subject: [R] loop in list
Hello
I have a loop to sample 20 samples and I want to put them in one list, how I
can make this??
Regards
Sulafah
[[alternative HTM
Instead of a loop you can use the replicate or lapply functions which
will create lists for you.
otherwise you can start with an empty list (mylist <- list() )
then add to the list in each iteration of the loop:
for(i in 1:10) {
mylist[[i]] <- myfunction(i)
}
On Sat, Jun 30, 2012 at 1:34
Hello
I have a loop to sample 20 samples and I want to put them in one list, how I
can make this??
Regards
Sulafah
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE d
Hi Jan,
Glad it helped you in some way. I am also copying to rhelp as your solution
might be useful for future reference.
A.K.
- Original Message -
From: Jan Näs
To: arun
Cc:
Sent: Friday, June 29, 2012 5:02 AM
Subject: Re: [R] loop through and modify multiple data frames
Thank
0.5 7.5
2 Trud 0.4 6.0
3 Sind 0.6 9.0
4 Rav 0.8 12.0
There might be an easy way in loop to get the same result.
A.K.
- Original Message -
From: Jan Näs
To: r-help@r-project.org
Cc:
Sent: Thursday, June 28, 2012 5:10 AM
Subject: [R] loop through a
Hi Jan,
You can do it in two ways. The simplest one is the following.
The first option is to use $. Here is how:
dogs <- data.frame(a = 1:10, b = 10:1)
dogs$c <- dogs$a+dogs$b
dogs
The second way it to use
?within
Contact
Details:--
Hi
Newbie question:
I have a set of data frames that I want to do the same calculations on each.
I've found out that I can put them in a list and loop through the list
to do the calculation, but not put the results back into each
data.frame..
For example three data frames cats, dogs, birds
wher
You can use main = unique(d$Subject) to solve this problem.
HTH,
b.
On 27 June 2012 08:49, Marcel Curlin wrote:
> Well at this point I have what I need (rough plot for data exploration) but
> the simplicity of the first approach is quite elegant and it has become a
> learning project. I have su
Well at this point I have what I need (rough plot for data exploration) but
the simplicity of the first approach is quite elegant and it has become a
learning project. I have succeeded in formatting the overall plot OK but
have not been able to solve the problem of titles or any kind of
label/legen
Try this alternative solution using only base functions:
# split the data into 4 data.frames
l <- split(data, data$Subject)
names(l)
# set up the graph parameters
par(mfrow=n2mfrow(length(l)), mar=c(4,4,1,1), mgp = c(2, 1, 0))
# good old for loop over the subject names
for( n in names(l)){
d <-
This solution works really nicely & I learned much by working through it.
However but I am having trouble with subplot formatting; setting
main=d$Subject results in the correct title over each plot but repeated
multiple times. Also I can't seem to format the axis labels and numbers to
reduce the sp
Hi,
Here's one approach:
plot_one <- function(d){
with(d, plot(Xvar, Yvar, t="n")) # set limits
with(d[d$param1 == 0,], lines(Xvar, Yvar, lty=1)) # first line
with(d[d$param1 == 1,], lines(Xvar, Yvar, lty=2)) # second line
}
par(mfrow=c(2,2))
plyr::d_ply(data, "Subject", plot_one)
HTH,
Hello, I have longitudinal data of the form below from N subjects; I am
trying to create figure with N small subplots on a single page, in which
each plot is from only one subject, and in each plot there is a separate
curve for each value of param1.
So in this case, there would be four plots on t
Thank you Jeff,
that sounds like the solution to my problem
but how would I do that code-wise?
could you please help?
--
View this message in context:
http://r.789695.n4.nabble.com/Loop-Help-tp4633558p4633701.html
Sent from the R help mailing list archive at Nabble.com.
_
@angel,
You can try append option in write.table
for e.g.
for(i in 1:20)
write.table(i,"out.txt",append=T,sep="\t",row.names=F,col.names=F)
This will help you save your all results by writing each results on
subsequent rows.
Hope this helps
Ozgur
>Hello Jim
>thank you so much for your respons
On Jun 18, 2012, at 5:47 AM, @ngel wrote:
I think that for now I'll keep it
There is no "it" in this message. Users of Nabble often fail to read
the POsitng Guide where it is requested that you include context.
as is and try to clean the data in excel.
Could someone please tell me how c
Then don't do that.
write.csv is designed to write a complete matrix or data frame in one call.
Combine your list of matrices into one (e.g. using sapply) and write that in
one call afterward rather than piecewise as you do the calculations.
-
Hello Jim
thank you so much for your response.
When I use write.csv, on the csv file is saved only the last loop
So when I write
results.matrix <- apply(degree_w(net.static[[i]]), 2, mean)
write.csv(results.matrix, file = "results.csv")
instead of getting a 550 line document with all loop result
What do you mean by "only the last j"? write.csv writes to a file you
specify and I assume that you are changing the file name if you are
making successive writes. You need to provide more detail.
On Mon, Jun 18, 2012 at 5:47 AM, @ngel wrote:
> I think that for now I'll keep it as is and try to
201 - 300 of 632 matches
Mail list logo