Displaying 20 results from an estimated 10000 matches similar to: "function to compare numbers"
2010 Aug 16
5
how to test if a vector contain a value?
Hi all,
How to convert following simple python script to R
if x in a_list:
print x
OR
simply, how to test if a vector contain a value?
Thank you in advance,
Hyunchul
[[alternative HTML version deleted]]
2010 Aug 30
2
listing files recursively
Hi, all
how to get all filenames in a directory and its all subdirectories?
something like
filenames <- c(Sys.glob('/path/to/directory/*'),
Sys.glob('/path/to/directory/*/*'), Sys.glob('/path/to/directory/*/*/*'),
...)
Thanks in advance,
Hyunchul
[[alternative HTML version deleted]]
2010 Aug 29
2
take component names of a list
Hi, all
I want to take a vector of component names of a list.
list.a <- list('x'=1, 'y'=2)
how to get a c('x','y') from list.a?
Thanks in advance,
Hyunchul
[[alternative HTML version deleted]]
2010 Sep 19
2
get time as a number
Hi, all,
How to get a time as a number?
While script is running, I want to print the elapsed time
something like TIME_AS_SECOND() in the following script
inittime <- TIME_AS_SECOND()
for (i in 1:100){
do_something(i)
curtime <- TIME_AS_SECOND()
elapsedtime <- curtime-inittime
print(paste(i, elapsedtime))
}
Thanks in advance,
Hyunchul
[[alternative HTML version
2010 Aug 29
1
how to take a os.path.basename
Hi, all
I made a simple R script to take the basename of a file without directory
names.
path.splitted <- strsplit('/path/to/a_basename', '/')
path.length <- length(path.splitted[[1]])
basename <- path.splitted[[1]][path.length] # basename <- 'a_basename'
Is there a simple function for this?
something like os.path.basename(a_filename) of python?
Thanks in
2010 Sep 04
1
how to free memory? (gc() doesn't work for me)
Hi, all
I have a huge object that use almost all of available memory.
R> rm(a_huge_object)
R> gc()
doesn't free memory and ?gc doesn't show anything.
Are there any suggestion?
Thanks in advance,
Regards,
Hyunchul
[[alternative HTML version deleted]]
2010 May 19
3
save in for loop
Dear users,
My problem concerns save() within a for loop.
Here is my code:
for (i in 1:4) {
temp <- data.frame(a=(i+1):(i+10), b=LETTERS[(i+1):(i+10)])
filename <- paste("file", i, sep="")
assign(filename, temp)
save(filename, file=paste(filename, ".rda", sep=""))
}
As you can see, save() doesn't work as I would like: (1) the object
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 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 Sep 21
2
labels in (box)plot
Dear users,
I would like all the ticks on a boxplot (x and y) to be labeled
I have checked all the par() arguments but couldn't find what I'm
looking for
Here is an example to show it:
df <- structure(list(SPECSHOR = structure(c(1L, 1L, 1L, 3L, 3L, 3L, 3L,
3L, 4L, 4L), .Label = c("cotau", "dibic", "eqgre", "gicam"), class =
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)
2008 May 01
3
elseif syntax
Hi, all
How to use elseif ?
For example, like following short python examples.
*********
x = 1
if x == 1:
print 'same'
*elif* x > 1:
print 'bigger'
else:
print 'smaller'
*********
Thanks in advance,
Hyunchul Kim
[[alternative HTML version deleted]]
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