Hello Rui,
it's very helpful.
Thank you,
Kai
On Wednesday, July 14, 2021, 10:07:57 AM PDT, Rui Barradas
wrote:
Hello,
Just before for(j in 1:nrow(ora)) include the following code line (I
have removed the underscore):
sdif <- vector("list", length = nrow(ora))
In the loop:
sdif[[j
Hello,
Just before for(j in 1:nrow(ora)) include the following code line (I
have removed the underscore):
sdif <- vector("list", length = nrow(ora))
In the loop:
sdif[[j]] <- sqldf(etc)
Also, once again, why noquote? It's better to form file names with
file.path:
rdcsv <- file.path(
thanks
>
> m
>
>
> - Messaggio originale -
> Da: "Bert Gunter"
> A: "Massimo Bressan"
> Cc: "r-help"
> Inviato: Mercoledì, 22 novembre 2017 17:32:33
> Oggetto: Re: [R] assign NA to rows by test on multiple col
same basic
structure as the simplified example I posted
thanks
m
- Messaggio originale -
Da: "Bert Gunter"
A: "Massimo Bressan"
Cc: "r-help"
Inviato: Mercoledì, 22 novembre 2017 17:32:33
Oggetto: Re: [R] assign NA to rows by test on multiple columns of
Do you mean like this:
mydf <- within(mydf, {
is.na(A)<- !A_flag
is.na(B)<- !B_flag
}
)
> mydf
A A_flag B B_flag
1 8 10 5 12
2 NA 0 6 9
3 10 1 NA 0
4 NA 0 1 5
5 5 2 NA 0
Cheers,
Bert
Bert Gunter
"The trouble with h
Hi--
I too misread the question twice and i may have mistakenly posted non-text
answer earlier. Below is a step by step solution that works provided that
your real data frame has the same structure (alternative columns as in your
example). You could combine all the steps in 2 statements.
Best of
OPS,
Sorry i did not read the post carfully. Mine will not work if you have
zeros on columns A and B.. But you could modify it to work for specific
columns i believe.
EK
On Wed, Nov 22, 2017 at 8:37 AM, Ek Esawi wrote:
> Hi *Massimo,*
>
> *Try this.*
>
> *a <- mydf==0mydf[a] <- NAHTHEK*
>
> On
Hi *Massimo,*
*Try this.*
*a <- mydf==0mydf[a] <- NAHTHEK*
On Wed, Nov 22, 2017 at 5:34 AM, Massimo Bressan <
massimo.bres...@arpa.veneto.it> wrote:
>
>
> Given this data frame (a simplified, essential reproducible example)
>
>
>
>
> A<-c(8,7,10,1,5)
>
> A_flag<-c(10,0,1,0,2)
>
> B<-c(5,6,2,1,0
;Rui Barradas"
A: "Massimo Bressan" , "r-help"
Inviato: Mercoledì, 22 novembre 2017 11:49:08
Oggetto: Re: [R] assign NA to rows by test on multiple columns of a data frame
Hello,
Try the following.
icol <- which(grepl("flag", names(mydf)))
mydf[icol] <- lapply
p"
Inviato: Mercoledì, 22 novembre 2017 11:49:08
Oggetto: Re: [R] assign NA to rows by test on multiple columns of a data frame
Hello,
Try the following.
icol <- which(grepl("flag", names(mydf)))
mydf[icol] <- lapply(mydf[icol], function(x){
is.na(x) <- x == 0
Hello,
Try the following.
icol <- which(grepl("flag", names(mydf)))
mydf[icol] <- lapply(mydf[icol], function(x){
is.na(x) <- x == 0
x
})
mydf
# A A_flag B B_flag
#1 8 10 5 12
#2 7 NA 6 9
#3 10 1 2 NA
#4 1 NA 1 5
#5 5 2 0 NA
Dear Bert,
This is awesome, thanks a lot!
Best,
Marlin
On Sun, 2016-12-11 at 06:52 -0800, Bert Gunter wrote:
> Use list indexing, "[[" not "[" .
>
> > df <- data.frame(a=1:3,b=letters[1:3])
> > x <- "new"
> > df[[x]]<- I(list(1:5,g = "foo", abb = matrix(runif(6),nr=3)))
> > df
>
> a b
If you see my previous example, I have tried something like
> df[,n3] <- I(mylist)
However, in my case, the name of the new column is in a variable (by
user input) which can not be directly used by the dollar assign. On the
other hand, "[<-" does not work correctly even if I wrap the list into
"
Glad to help.
However, I need to publicly correct my misstatement. Both "[[" and "["
can be used and are useful for list indexing. As ?"[" clearly states,
the former selects only a single column, while the latter can select
several.
Also:
"Both [[ and $ select a single element of the list. The m
Use list indexing, "[[" not "[" .
> df <- data.frame(a=1:3,b=letters[1:3])
> x <- "new"
> df[[x]]<- I(list(1:5,g = "foo", abb = matrix(runif(6),nr=3)))
> df
a b new
1 1 a 1, 2, 3,
2 2 b foo
3 3 c 0.248115
> df$new
[[1]]
[1] 1 2 3 4 5
$g
[1] "foo"
$abb
[,1]
?data.frame says:
"If a list or data frame or matrix is passed to data.frame it is as if
each component or column had been passed as a separate argument
(except for matrices of class "model.matrix" and those protected by
I). "
So doing what Help says to do seems to do what you asked:
> df <- da
Mark:
I do not understand what you mean by plot labels, which generally mean
the x and y axis labels that can be given with xlab and ylab
parameters in the xyplot call. Clearly, however, this is not what you
mean. If you mean the labels in the key for the groups, you should
create the grouping fac
Check the size of df_both. It would be that there are no Command fields
that contain both a 't1' and 't2'.
You can so do:
sum(grepl("t1", df$Command) & grepl("t2", df$Command))
to see how many Command fields contain both.
Jim Holtman
Data Munger Guru
What is the problem that you are trying t
now after this:
df_both <- subset(df, grepl("t1", Command) & grepl("t2", Command))
I use factor to apply the subset to df but then the Command level becomes 0
df_both$Command=factor(df_both$Command)
str(df_both)
$ Protocol : Factor w/ 0 levels:
Do you know what is the r
'grepl' returns a logical vector; you have to use this to get your subset.
You can use:
df_tq <- subset(df, grepl("t1", Command))
df_t2 <- subset(df, grepl("t2", Command))
# if you want to also get a subset that has both, use
df_both <- subset(df, grepl("t1", Command) & grepl("t2", Command))
my problem is that in Command I have 2229 levels and I want to do subsets based
on the names I have in Command. for example if the name has t1 or t2 in it or
if it has both of them.and then I need to plot in a way that colors are names
with t1,names with t2 and names with both. But now even t
You never did provide a reproducible example or say how you wanted to
plot. Here is a way to get a subset of t1 or t2, and you can then use it
as input to ggplot:
library(dplyr)
your_subset <- df %>%
mutate(key = grep(".*(t1|t2).*", "\\1", Command, value = TRUE))
%>%
filter(!(
consistent structure to the strings (a second dash, which may be
implied by the original question).
Best,
John
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Georges
> Monette
> Sent: April 9, 2016 3:04 PM
> To: r-help@r-project.org
> Sub
Hi,
I couldn't resist these two suggestions:
strings <- c("ASk/20005-01-45/90", "Alldatk/25-17-4567/990")
x <- as.numeric(gsub("^[^-]*-|-.*$","",strings))
or
x <- as.numeric(sub("^[^-]*-([0-9]+)-.*$","\\1",strings))
Best,
Georges
-
Georges Monette, York University, Toron
You are not using that function as it was designed to be used. You should read
the help for gsub...
?gsub
And if you don't know what the term "regular expression pattern" that is
mentioned there means then you will probably need to study one of the many fine
tutorials that are available on th
Dear Val,
Your question isn't entirely clear (to me), but this is what I think you want
to do:
-- snip
> strings <- c("ASk/20005-01-45/90", "Alldatk/25-17-4567/990")
> location <- regexpr("-[0-9]*", strings)
> x
[1] "01" "17"
> x <- substring(strings, location +
> > What I need is this:
> > [[1]]
> > [1] 1 2 3
> > [[1]]
> > [2] 1 2 3
> > [[1]]
> > [2] 1 2 3
Try
rep(list(1:3), 3)
S Ellison
***
This email and any attachments are confidential. Any use...{{dropped:8}}
Hi,
On Wed, Mar 9, 2016 at 10:22 AM, Jan Kacaba wrote:
> Hello I would like to assign a vector to list sequence. I'm trying my code
> bellow, but the output is not what inteded.
>
> # my code
> mls=vector(mode="list") # my list
> cseq=c(1:3) # my vector
> mls[cseq]=cseq
>
> I get following:
> [
I don't disagree with the other answers, but I'd like to talk about what I
see as a more underlying issue.
Generally speaking, functions return the value of the last expression
within them.
myfun <- function(x) {
z <- sqrt(x)
2
}
Then
y <- myfun(7)
assigns 2 to y because 2 was the last expr
That's it ! Sorry for writing in a hurry, Merm!
Il 16/apr/2015 14:14, "Jim Lemon" ha scritto:
> Hi merm,
> In case Sergio's message is a little cryptic:
>
> return_a_list<-function() {
> a<-"First item of list"
> b<-c(2,4,6,8)
> c<-matrix(1:9,nrow=3)
> return(list(a,b,c))
> }
>
> x<-return_a_
Hi merm,
In case Sergio's message is a little cryptic:
return_a_list<-function() {
a<-"First item of list"
b<-c(2,4,6,8)
c<-matrix(1:9,nrow=3)
return(list(a,b,c))
}
x<-return_a_list()
x
Jim
On Thu, Apr 16, 2015 at 7:21 PM, Sergio Fonda wrote:
> Collect in a vector or dataframe or list the
Collect in a vector or dataframe or list the variables of interest and
output it.
Il 16/apr/2015 10:57, "merm" ha scritto:
> Hi!
>
> So I'm trying as the header suggests to assign the value(s) output by a
> function to a variable, say 'y'
>
> Problem is from what I gather any variables introduced
Hi Petr,
your solution works also perfectly, thanks a lot! Again, I have learned new
things :)
(Sorry for problems with the dput...)
Best wishes,
Zuzana
On 21 January 2015 at 11:57, PIKAL Petr wrote:
> Hi
>
> I am not sure if I catch it correctly but from your example state has
> preferen
Hi
I am not sure if I catch it correctly but from your example state has
preference over state new except in the case where state is 0.
I would change state_bef 0 to NA and use na.locf function from zoo package.
test$state_bef[test$state_bef=="0"] <- NA
test$state_bef <- na.locf(test$state_bef,
Hi Jim,
your code works just perfectly, it is exactly what I was looking for, thank
you very much!!! I'm glad to learn something new, I haven't seen the use of
"drow in 1:(dim(all)[1])" before.
I made the code a bit shorter, excluding the use of "stat_bef" column,
which I created just for my inte
Hi Zuzana,
>From your description it seems that you want to repeat the last
"state_new" value when there are repeated zeros in both "state" and
"state_bef". If that is the case, you may need to step through the
data frame like this:
for(drow in 1:(dim(test)[1])) {
if(test$state[drow] != 0) test$s
Here's another one: match(d, unique(d)).
Arun
From:Â Greg Snow 538...@gmail.com
Reply:Â Greg Snow 538...@gmail.com
Date:Â March 12, 2014 at 8:41:31 PM
To:Â T Bal studentt...@gmail.com
Cc:Â r-help r-help@r-project.org
Subject:Â Re: [R] Assign numbers in R
Here are a couple more optio
Here are a couple more options if you want some variety:
> d <- c(8,7,5,5,3,3,2,1,1,1)
> as.numeric( factor(d, levels=unique(d)) )
[1] 1 2 3 3 4 4 5 6 6 6
> cumsum( !duplicated(d) )
[1] 1 2 3 3 4 4 5 6 6 6
What would you want the output to be if your d vector had another 8
after the last 1? T
No, this is not a homework. Thank you so much!
On Wed, Mar 12, 2014 at 10:39 AM, Kehl Dániel wrote:
> Hi,
>
> is this homework?
> Try
> d <- c(8,7,5,5,3,3,2,1,1,1)
>
> r <- rep(1,length(d))
>
> for (i in 2:length(d)) {
>
> if (d[i] != d[i-1]) {
> r[i]=r[i-1]+1;
> }
> else {
> r[i]
Hi,
Try:
cumsum(c(TRUE,d[-1]!=d[-length(d)]))
A.K.
On Wednesday, March 12, 2014 5:28 AM, T Bal wrote:
Hi,
I have the following numbers:
d <- c(8,7,5,5,3,3,2,1,1,1)
I want to convert these into the following numbers:
r:
1,2,3,3,4,4,5,6,6,6
So if two numbers are different increment it if t
Hi,
is this homework?
Try
d <- c(8,7,5,5,3,3,2,1,1,1)
r <- rep(1,length(d))
for (i in 2:length(d)) {
if (d[i] != d[i-1]) {
r[i]=r[i-1]+1;
}
else {
r[i] = r[i-1];
}
}
Although I am sure there are better solutions!
HTH
daniel
Feladó:
Hello,
Try the following.
r <- cumsum(c(TRUE, diff(d) != 0))
Hope this helps,
Rui Barradas
Em 12-03-2014 09:13, T Bal escreveu:
Hi,
I have the following numbers:
d <- c(8,7,5,5,3,3,2,1,1,1)
I want to convert these into the following numbers:
r:
1,2,3,3,4,4,5,6,6,6
So if two numbers are
Hello,
For your example, the following will work:
R> d <- c(8,7,5,5,3,3,2,1,1,1)
R> idx <- 1:length(unique(d))
R> rep(idx, rle(d)$length)
[1] 1 2 3 3 4 4 5 6 6 6
HTH,
Pascal
On Wed, Mar 12, 2014 at 6:13 PM, T Bal wrote:
> Hi,
> I have the following numbers:
>
> d <- c(8,7,5,5,3,3,2,1,1,1)
>
>
Hi Weijia,
This will give you the rownames of the split variables.
lst1 <- split(a,list(a$COUNTRY,a$SITEID))
res <- t(sapply(lst1,function(x) {
x$SCRNDT <- as.Date(x$SCRNDT, "%d-%b-%y")
unlist(lapply(split(b,b$TMPT),function(y){
sum(x$SCRNDT >=
HI Weijia,
Please check whether this is what you wanted.
Weijia <- load("/home/arunksa111/Downloads/arun_help.RData" )
a[sapply(a,is.factor)] <-lapply(a[sapply(a,is.factor)],as.character)
str(a)
b[sapply(b,is.factor)] <- lapply(b[sapply(b,is.factor)],as.character)
str(b)
b$DT_ETP <- as.Date(b$D
Hi,
Please use ?dput() to show the dataset. Also, it is not clear about how you
store the time interval.
dat <- read.table(text="
GroupID Date
1 1 10-Dec-12
2 1 11-Dec-12
3 2 13-Dec-12
4 2 15-Dec-12
5 3 06-Dec-12
6 3 19-Dec-12",s
This works too! Thank you.
Such a relief after few days spent on trying to solve it.
Lilia
On 13 March 2013 19:52, jim holtman wrote:
> I forgot the 'seq':
>
> > data=data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2))
> > data$tripid <- cumsum(c(TRUE, diff(data$beh) != 0))
> > data$seq <- ave
Fantastic! Thank you so much
On 13 March 2013 19:48, arun wrote:
> Hi,
> Try this:
> data1<-data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2))
> data1<-within(data1, {trip.id<- cumsum(c(1,abs(diff(beh; Seq<-ave(row,
> trip.id,FUN=seq)})
> data1
> # row beh Seq trip.id
> #11
I forgot the 'seq':
> data=data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2))
> data$tripid <- cumsum(c(TRUE, diff(data$beh) != 0))
> data$seq <- ave(data$beh, data$tripid, FUN = function(x) seq_along(x))
> data
row beh tripid seq
11 1 1 1
22 1 1 2
33 1 1
try this:
> data=data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2))
> data$tripid <- cumsum(c(TRUE, diff(data$beh) != 0))
> data
row beh tripid
11 1 1
22 1 1
33 1 1
44 2 2
55 2 2
66 2 2
77 1 3
88 1 3
9
Hi,
Try this:
data1<-data.frame(row=seq(1:10),beh=c(1,1,1,2,2,2,1,1,2,2))
data1<-within(data1, {trip.id<- cumsum(c(1,abs(diff(beh;
Seq<-ave(row,trip.id,FUN=seq)})
data1
# row beh Seq trip.id
#1 1 1 1 1
#2 2 1 2 1
#3 3 1 3 1
#4 4 2 1 2
#5
Hi
What language are you comming from?
colnames(ScoutRSM.mat) <- paste("X", 1:39, sep="")
Regards
Petr
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Prew, Paul
> Sent: Saturday, February 23, 2013 1:35 AM
> To: r-help@r-p
, 2013 7:22 PM
To: Prew, Paul
Cc: r-help@r-project.org
Subject: Re: [R] assign index to colnames(matrix)
On 02/23/2013 11:34 AM, Prew, Paul wrote:
> Hello, I’m trying to follow the syntax of a script from a journal
> website. In order to create a regression formula used later in the
> sc
On 02/23/2013 11:34 AM, Prew, Paul wrote:
Hello, I’m trying to follow the syntax of a script from a journal website.
In order to create a regression formula used later in the script, the
regression matrix must have column names “X1�, “X2�, etc. I have tried
to assign these column
Hello,
Em 11-02-2013 01:26, Pete Brecknock escreveu:
malaka wrote
Hi,
I want to assign the ar1 , ma 1 and the intercept estimated by the
following code to three variables a, b and c respectively.
Can anyone help me with this please?
code:
a0 = 0.05; a1 = 0.1; b1 = 0.85
nu = rnorm(2500)
epsi
malaka wrote
> Hi,
> I want to assign the ar1 , ma 1 and the intercept estimated by the
> following code to three variables a, b and c respectively.
>
> Can anyone help me with this please?
>
> code:
>
> a0 = 0.05; a1 = 0.1; b1 = 0.85
> nu = rnorm(2500)
> epsi = rep(0, 2500)
> h = rep(0, 2500)
>
On Aug 1, 2012, at 8:50 AM, John linux-user wrote:
Hi everyone,
I try to add many vectors (L1,L2,L3) to multiple list objects
(a.list,
b.list) in a workspace. Somethings like below, but it is not
working. Any suggestions will be appreciated. Best, John
lf=ls(pattern=".lst")
for
I'm afraid I don't quite understand what you're getting at: can you
say what you're trying to do big-picture wise.
This advice might help making a reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
Best,
Michael
PS -- Just a hunch -- but
Dear
Rui Barradas
David Winsemius
ONKELINX, Thierry
David Carlson
I really appreciate your helps.
I did not realize that there were such many ways to do it.
Among them, I just pick up the simple one and it worked out.
It was like this.
<>
n <- 10
p <- 9
dataset <- data.frame(matrix(rep(seq
-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of ONKELINX, Thierry
> Sent: Friday, June 29, 2012 10:11 AM
> To: David Winsemius; lynx
> Cc: r-help@r-project.org
> Subject: Re: [R] assign object with loop (translation from SAS to R)
>
> You can use a combi
.
~ John Tukey
-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens
David Winsemius
Verzonden: vrijdag 29 juni 2012 16:18
Aan: lynx
CC: r-help@r-project.org
Onderwerp: Re: [R] assign object with loop (translation from SAS to R)
On Jun 28
On Jun 28, 2012, at 9:18 PM, lynx wrote:
I have a dataset named DM with p1, p2, , p9 (9 columns,
numerical values)
I would like to calculate to multify each pair of columns (p1p2,
p1p3,...
p1p9, p2p3, p2p4 p8p9) and assign them in p1p2, p1p3,... p1p9,
p2p3,
p2p4 p8p9
In SAS,
Hello,
See inline.
Em 29-06-2012 02:18, lynx escreveu:
I have a dataset named DM with p1, p2, , p9 (9 columns, numerical values)
I would like to calculate to multify each pair of columns (p1p2, p1p3,...
p1p9, p2p3, p2p4 p8p9) and assign them in p1p2, p1p3,... p1p9, p2p3,
p2p4 p8p9
On Apr 10, 2012, at 8:59 AM, David Winsemius wrote:
On Apr 10, 2012, at 3:16 AM, aajit75 wrote:
I have got solution using within function as below
dd$Seg <- 1
dd <- within(dd, Seg[x2> 0 & x3> 200] <- 1)
In this instance the first of your assignments appears superfluous.
dd <- within(dd,
On Apr 10, 2012, at 3:16 AM, aajit75 wrote:
I have got solution using within function as below
dd$Seg <- 1
dd <- within(dd, Seg[x2> 0 & x3> 200] <- 1)
In this instance the first of your assignments appears superfluous.
dd <- within(dd, Seg[x2> 100 & x3> 300] <- 2)
dd <- within(dd, Seg[x2>
On 10-04-2012, at 08:44, aajit75 wrote:
> Hi Experts,
>
> This may be simple question, I want to create new variable "seg" and assign
> values to it based on some conditions satisfied by each observation.
>
> Here is the example:
> ##Below are the conditions
>
> ##if variable x2 gt 0 and x3 gt
I have got solution using within function as below
dd$Seg <- 1
dd <- within(dd, Seg[x2> 0 & x3> 200] <- 1)
dd <- within(dd, Seg[x2> 100 & x3> 300] <- 2)
dd <- within(dd, Seg[x2> 200 & x3> 400] <- 3)
dd <- within(dd, Seg[x2> 300 & x3> 500] <- 4)
I sthere any better way of doing it!!
--
View th
I am not sure that I understand but does something like this do what you want?
ec<-1:10
vec[vec==4] <- 100
vec <- 1:10
vec[ vec==4 | vec==8] <- 100
vec <- 1:10
aa <- 50
vec[vec==4] <- aa
John Kane
Kingston ON Canada
> -Original Message-
> From: marc_...@yahoo.fr
> Sent: Sun, 18 Mar 2
On Mar 18, 2012, at 2:24 PM, Marc Girondot wrote:
Assign can be used to set a value to a variable that has name as a
value of another variable. Example:
name<-"essai"
assign(name, "plouf")
essai
[1] "plouf"
OK.
But how to do the same when it is only an element of a vector, data
frame an
Do not use assign(). It is a relic from the 1980s.
Instead, decide where you want your
variables to live, perhaps in a list,
where<-list()
or perhaps in an environment,
where<-new.env()
or
where<-environment().
Then use where[[varName]] to refer to the variable. You can
use further subse
Your code isn't reproducible...(note the "legend " block -- that's
not code) and (if I had to guess) it looks like you are using
attach(). Don't do that...
What do you mean it doesn't work? You say something about plotting
lines, but your "working" code (the first block) doesn't do that...
If
Dear all,
Thanks all of u for your help. Now I've another similar problem. I want to
plot within the same plot, different lines, each one in a different color
depending on the factor level. I've been able to do it like this, but if i
try with rainbow colors it doesn't work. Can anybody help me wi
On 02/16/2012 01:35 AM, agent dunham wrote:
Dear community,
I've plotted data and coloured depending on the factor variable v3.
In the legend, I'd like to assign properly the same colors than in the
factor (the factor has 5 levels).
I've been trying this but it doesn't work.
plot(var1, var2,
This is certainly not a reproducible example, but this works fine for me.
lets = factor(sample(letters[1:3], 10, TRUE))
plot(1:10, 1:10, col = lets)
legend("topleft", legend = levels(lets), col = seq.int(length(lets)), lty = 1)
Michael
On Wed, Feb 15, 2012 at 9:35 AM, agent dunham wrote:
> Dear
On 12-01-06 12:18 PM, Michael Pearmain wrote:
Hi All,
I've just recently discovered the cmpfun function, and was wanting to to
create a function to assign this to all the functions i have created, but
without explicitly naming them.
I've achieved this with:
foo<- function(x) { print(x)}
bar<-
On Thu, 01-Dec-2011 at 10:13AM -0800, lglew wrote:
|> Hi R-users,
|>
|> I'm trying to produce decompositions of a multiple time-series, grouped by a
|> factor (called "area"). I'm modifying the code in the STLperArea function of
|> package ndvits, as this function only plots produces stl plots, i
On Dec 1, 2011, at 1:13 PM, lglew wrote:
Hi R-users,
I'm trying to produce decompositions of a multiple time-series,
grouped by a
factor (called "area"). I'm modifying the code in the STLperArea
function of
package ndvits, as this function only plots produces stl plots, it
does not
retu
Thanks Michael! Yeah, that dealt with one of the problems.
I still get the following error message:
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 (type 'list') cannot be handled by 'cat'
I know that this has something to do with writing the names of the output
file, an
I think part of your problem is the loop:
you probably mean
for(i in unique(area))
Michael
On Thu, Dec 1, 2011 at 1:13 PM, lglew wrote:
> Hi R-users,
>
> I'm trying to produce decompositions of a multiple time-series, grouped by a
> factor (called "area"). I'm modifying the code in the STLperA
Have a look at package multcomp at:
http://cran.r-project.org/package=multcomp
I hope it helps.
Best,
Dimitris
On 8/31/2011 2:30 PM, eldor ado wrote:
dear R community,
i appologize as this is kind of a newbie question, but:
I want to assign group letters (like in anova post-hoc tests) to
On Mon, Jun 27, 2011 at 10:34 AM, Berry Boessenkool
wrote:
>
>
> Hey all,
>
> I learned that using the equals sign "=" to assign objects is generally OK,
> but will not work in some cases.
> As I always use "<-" for assignments, I have not encoutered any problems.
>
> Could somebody provide an ex
On 06/27/2011 10:34 AM, Berry Boessenkool wrote:
Hey all,
I learned that using the equals sign "=" to assign objects is generally OK, but
will not work in some cases.
As I always use "<-" for assignments, I have not encoutered any problems.
Could somebody provide an example or explanation, w
I'm not an expert but some third party libraries won't recognize = as an
assignment for some objects (I learned this empirically) when the
assignment is made within a function. Using <- protects you from these
unknows, as you have discovered on your own.
Regards
David
On 6/27/2011 8:34 AM, Be
Oh, right. Now I see.
Thanks for your help.
Dominik
On Thu, 09 Jun 2011 15:33:43 +0200, Uwe Ligges
wrote:
> On 09.06.2011 14:31, Dominik P.H. Kalisch wrote:
>> Hi Uwe,
>>
>> thanks for your help. I didn't know that function (mea culpa)...
>> With merge() it works what I want to do.
>> But I'm st
On 09.06.2011 14:31, Dominik P.H. Kalisch wrote:
Hi Uwe,
thanks for your help. I didn't know that function (mea culpa)...
With merge() it works what I want to do.
But I'm still interessted, for a learning purpose, why the loop didn't
work. So here are the str() results:
str(cluster)
int [
Hi Uwe,
thanks for your help. I didn't know that function (mea culpa)...
With merge() it works what I want to do.
But I'm still interessted, for a learning purpose, why the loop didn't
work. So here are the str() results:
> str(cluster)
int [1:18, 1:2] 12051000 12052000 12053000 12054000 1206000
On 07.06.2011 16:24, Dominik P.H. Kalisch wrote:
Hi,
I have two matrices of the following form:
cluster (n=18):
12062 1
12063 2
12064 2
12065 3
12066 5
KreisSA (n=2304)
12062
12062
12067
12065
12063
12067
I try to assign the cluster[,2] to KreisSAa by the follwoing loop:
n <- nrow(cluster)
On May 18, 2011, at 1:35 PM, Asan Ramzan wrote:
Hello R-help
Below is the output from the predict() function. How can I assign $y
to a
variable.
Newvar <- predict(function,df2)$y
--
David.
$x
V1
1 36.28
2 34.73
3 33.74
4 69.87
5 58.88
6 89.44
7 43.97
8 41.94
9
Hi,
You probably need ?get, though you might want to read this first,
library(fortunes)
fortune(236)
HtH,
baptiste
On 13 April 2011 13:04, Sparks, John James wrote:
> Dear R Helpers,
>
> I am trying to change the name of an object using the assign function.
> When I use paste on the new obje
That column of your data frame contains a factor, rather than character
values. You don't tell us how you created the data frame, but you might
be interested in the stringsAsFactors option to data.frame() and read.table().
Or, if you do actually want a factor for that column, you can use factor()
Hi John,
The error arises because the "hold" data frame contains factors. This
happens by default when creating data frames with character data as
you did. Factors have a set number of levels and new values cannot be
assigned to them that fall outside their specified levels, hence the
error. Th
Hi Marcos,
I'd be glad to help, but your example is not usable for anyone but
yourself - I don't have the files that your code reads and I don't have
any idea what the resulting data frames look like. Please provide
examples of the data and the result.
Andreas
Marcos Amaris Gonzalez schrieb
As I partially showed, I guess that the problem of assigning the value
99 to any object in the workspace can be dealt with a more precise
regular expression.
Maybe that would do:
ls(pattern="^a[1-9]$")
or
ls(pattern="^a[0-9]+$")
In any case, I agree that alternatives are better
Ivan
Le 2/21
If instead of having a1, a2, etc. as global variables you put them into a list
then this becomes simple.
The general rule is that if you ever want to do the same (or similar) think to
a set of variable, then they should not have been separate variables, but part
of a bigger one. Lists work wel
Hi,
This works for me:
pat <- ls(pattern="^a") ## I would anchor "a" to the beginning with "^"
for safety!
for (i in seq_along(pat))assign(pat[i], value=99)
Or this with lapply:
lapply(pat, FUN=function(x) assign(x, value=99, envir=.GlobalEnv))
See ?assign
HTH,
Ivan
Le 2/21/2011 17:22, Nuno
Hi Nuno,
Yes, you can do
for(i in ls(pattern="a"))
{
assign(i, 99)
}
but honestly this is a bad idea. It will try to assign the value of 99
to any object in your workspace that contains an a, which sounds
really scary to me.
Better I think to use a list:
ab.list <- list(a1=1, a2=2, a3=3, a4=4
David and Bill,
Thank you so much for your rapid and exceptional help. Bill, the reason I had
gone with lists within the list was because I thought I might use the list for
holding other information - and because it was easier to get the column name.
Your simple-list suggestion is cleaner and I'
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Tim Howard
> Sent: Wednesday, February 09, 2011 12:44 PM
> To: r-help@r-project.org
> Subject: [R] assign factor levels based on list
>
> All,
>
> Given a data frame and a list
On Feb 9, 2011, at 4:18 PM, David Winsemius wrote:
On Feb 9, 2011, at 3:44 PM, Tim Howard wrote:
All,
Given a data frame and a list containing factor definitions for
certain columns, how can I apply those definitions from the list,
rather than doing it the standard way, as noted below.
On Feb 9, 2011, at 3:44 PM, Tim Howard wrote:
All,
Given a data frame and a list containing factor definitions for
certain columns, how can I apply those definitions from the list,
rather than doing it the standard way, as noted below. I'm lost in
the world of do.call, assign, paste, and
1 - 100 of 139 matches
Mail list logo