Displaying 20 results from an estimated 10000 matches similar to: "save in for loop"
2010 May 20
1
use object within rda file in for loop
Dear users,
I would like to process all the lists from all *.rda files that I have
in one folder.
Up to now, I can load all the *.rda files without any problem.
The problem is when I want to access the list saved within each *.rda
file (only one list per rda file).
Here is my code:
fpath <- "D:/R"
listnames <- list.files(path=fpath, pattern=glob2rx("*.rda"),
2010 Nov 01
2
number of items to replace is not a multiple of replacement length
Hey all,
I am writing a function in which I will have a matrix of 4 columns and a
variable amount of rows.
The first to columns will always contain be of the Character type, the third
and fourth columns
can be a variation of data types, usually characters and integers, but
sometimes lists or matrices.
At one point the code makes, for each row, a copy of that row, then it makes
some adjustments
2010 May 20
6
writing function
Dear group,
I am trying to write functions, but as a beginner, everything is not so
obvious.
Let's say I want the results in a list of elemts like this :
tot1, tot2, etc
Here is a function:
toto <-
function(x,y)
{
for(i in x:y){
paste(c("tot",i),collapse="")<-(i*2)
}
}
If I type this :
>toto(1,5)
I get this message error:
Error in paste(c("tot",
2010 Aug 17
2
dims error
Greetings,
I am a very novice user with R, and in the course of running a linking procedure :
P.old<- function (a, c, b, xi){
#a contains a parameters
#c contains c parameters
#b contains b parameters
#xi is a one column vector containing quadrature points for xi(=theta-gamma)for one item
tmp <- a*(xi-b)
2010 Mar 11
3
Help function "?" in R 2.10.1
Hello everyone,
I have versions 2.7.2 and 2.10.1 installed on a machine that has no
access to internet.
In 2.7.2 I can use ? to get help on functions, which in 2.10.1 that
does not work, all I see is "starting httpd help server...done" and
then nothing.
Have I downloaded 2.10.1 incorrectly (=forgot to tick some box for
local help file repository) or is the internet help now the
2010 Sep 16
5
using variable from for loop in naming new variables
Simple one here ... but can't get it to work ...
for (i in 1:4){
paste("stuff",[i]),sep="") <- 3 + i
}
ls()
rm(list=ls())
I just want it to create 4 new variables called stuff1, stuff2, stuff3, stuff4 with the corresponding assignments. I realise that there are more elegant functions but this is just a model of a bigger situation.
Thanks
Jim
2010 May 18
3
"Re: Change class factor to numeric"
sorry I had a mistake sending my question without a subject. I do resend again. Please excuse me.
> Hello
> I have a data array with soil variables (caperf), in which the variable "clay" is factor (as I see entering str(caperf)) . I need to do a regression model, so I need to have arcilla (=clay) as a numeric variable. For that I have entered
>
>
2010 May 20
2
Overlap of leaf labels
Hi,
I have tried looking at the archives but havent found any answer that works
till now (Sorry if i have missed anything)
I am a newbie to R and i am trying to carry out hierarchical clustering
using hclust -> as.dendrogram and then plotting the results as a dendrogram
using the plot function plot(object).
My question is :
In the function "plot", can one decrease the leaf label
2010 Mar 31
1
position of mismatches in all.equal()?
Dear R users,
I would like to compare two dataframes, actually their categorical
variables (as factors) only (there are 12, from column 1 to 12).
The reason I do that is that I got 2 datasets from two different methods
and I would like to be sure that each method used the same data (3D
images) to extract 2 different sets of 3D parameters. Is it clear so far?
So I thought about using
2010 Aug 09
1
bind a data frame columns
Hello guys, I want to rbind the columns of a data frame but I don't know how
to do it, let's say:
A B C
1 2 3
1 2 3
I want to get
1
1
2
2
3
3
It seems very simple but I still didnt get a find of how to do it...Please
help!
--
View this message in context: http://r.789695.n4.nabble.com/bind-a-data-frame-columns-tp2318526p2318526.html
Sent from the R help mailing list archive
2010 Aug 19
1
Help with Vectors and conditional functions
Good morning,
I have something like this: names(coint_tests) <- apply(b,2,paste, collapse="_") which prints 15 names like: A_B, C_D, E_F, ...
AA,B,C,D.. Are time series. Then there is a vector called coint_tests of length 15 which yields "yes" or "no".
I need to add a function to plot the time series Ai_Bi if the coint_tests vectors gives me a "YES".
2010 Sep 01
2
invert order
Dear R-help list users,
I have a huge vector of numbers, how I can invert orden?
For example
x <- 1:10000000
I would like to obtain
x_r <- 10000000:1
Thanks,
Sebastian.
2010 Sep 17
1
ifelse statement
Dear list,
I have a question I'm trying to use the following command in R, but it gives
me an error message.The command is:
data<-ddply(data,c("year","name"), transform, check1=ifelse(check1==1 &
check2==1, 1,NULL))
so in my data frame I already have the check1 variable, if the conditions
(check1==1 & check2==1) is respected, check has to have 1 as value,
2010 Sep 29
2
Adding two data.frames.
Hi
I have two data frames that contains the same sort of data and I want do add
them together to get one big data frame, anyone know how to do that?
ex:
data.frame1
A B C
1 2 3
4 5 6
7 8 9
and
data.frame2
A B C
9 8 7
6 5 4
3 2 1
Would then become one big set:
data.frame3
A B C
1 2 3
4 5 6
7 8 9
9 8 7
6 5 4
3 2 1
Thx for your help
//Joel
--
View this message in context:
2010 Sep 16
2
How to combine matrix and vector
Dear fellows,
I am a novice in R. I would like to combine a matrix and a vector. Assume
that we have the matrix a and the vector b with same length of column.
a<-matrix(seq(1:10),nrow=2,ncol=5,byrow=TRUE)
a=
1 2 3 4 5
6 7 8 9 10
b<-t(c(11,12,13,14,15))
b=
11 12 13 14 15
Then, I want to combine a and b as follows.
c=
1 2 3 4 5
6 7 8 9
2010 Sep 06
2
dataframe row names from list
Hi,
I have a list which looks like this...
> str(y)
List of 10
$ : chr [1:4] "ABCD" "5" "0" "1"
$ : chr [1:4] "DEF" "15" "1" "16"
$ : chr [1:4] "AAA" "2" "17" "8"
$ : chr [1:4] "SSS" "15" "25" "1"
$ : chr [1:4] "III"
2010 Sep 22
2
defining set of variables in a formula
Dear fellow R users,
I am trying to conduct a regression analysis. I have thousands of
variables. The names are V1, V2,........V2000
Is there an easy way to include these variables in the regression?
my model is something like that:
model<- lm(y~V1+V2+.....+V2000, data=data)
Thanks so much in advance,
Ozlem
2011 Aug 15
3
how can I read a xlsx file
Hello,
How can I read a xlsx file using xlsx package?
Thanks
Albert
[[alternative HTML version deleted]]
2010 Aug 09
1
(no subject)
Hi there,
I have been trying to use the "pvclust" package but have been having
some difficulties. This is the first time I have used R so I am sure the
mistake I am making is a basic one. The data I have is a distance matrix
and I have been using the command; fit <- pvclust(cluster, nboot=1000,
method.dist="euclidean") to try and perform hierarchical clustering with
2011 May 04
1
Str info. Thanks for helping
It looks from str(SA) that Response IPS1 is a data.frame of class "anova", which probably cannot be coerced to vector.
Maybe you can use unlist() instead of as.vector()
Or something like
SA[["Response IPS1"]]["as.factor(WSD)",] ## to select the first row only, even maybe with unlist()
Without a better REPRODUCIBLE example, I cannot tell more (maybe some others