Re: [R] cross validation for species distribution

2010-01-01 Thread elaine kuo
Dear, Thanks for the warmful help on New Year's EVE. Cross-validation is used to validate the predictive quality of the training data with testing data. As for the amount, the cross-validation (cv) is supposed to be based on k-fold cross-validation, k-1 for the training and 1 for the testing.

[R] changing a list element's name during execution in lapply - possible?

2010-01-01 Thread Mark Heckmann
Happy New Year, all! I want to do calculations on each element of a list l, but i want the returned list element to be named differently after the calculation. Is it possible to do the renaming somehow within the lapply call? l - list(a=NA, b=NA) lapply(l, function(x)

Re: [R] changing a list element's name during execution in lapply - possible?

2010-01-01 Thread David Winsemius
On Jan 1, 2010, at 8:21 AM, Mark Heckmann wrote: Happy New Year, all! I want to do calculations on each element of a list l, but i want the returned list element to be named differently after the calculation. Is it possible to do the renaming somehow within the lapply call? l -

Re: [R] XML and RCurl: problem with encoding (htmlTreeParse)

2010-01-01 Thread Lauri Nikkinen
Thanks. Interestingly, your code works on my Mac 10.6.1 but not on my Win XP. See sessionInfo from below. Mac R: sessionInfo() R version 2.9.2 (2009-08-24) i386-apple-darwin8.11.1 locale: fi_FI.UTF-8/fi_FI.UTF-8/C/C/fi_FI.UTF-8/fi_FI.UTF-8 attached base packages: [1] stats graphics

Re: [R] changing a list element's name during execution in lapply - possible?

2010-01-01 Thread Mark Heckmann
Hi David, thanks for the answer, though I am not sure what you mean. My aim is the following out: input to lapply l $a [1] NA $b [1] NA output from lapply: l $new_b [1] NA $new_b [1] NA Mark Am 01.01.2010 um 14:58 schrieb David Winsemius: On Jan 1, 2010, at 8:21 AM, Mark Heckmann

Re: [R] changing a list element's name during execution in lapply - possible?

2010-01-01 Thread jim holtman
Is this what you want: l - list(a=NA, b=NA) names(l) - paste(new_, names(l), sep='') l $new_a [1] NA $new_b [1] NA On Fri, Jan 1, 2010 at 9:48 AM, Mark Heckmann mark.heckm...@gmx.de wrote: Hi David, thanks for the answer, though I am not sure what you mean. My aim is the following

Re: [R] changing a list element's name during execution in lapply - possible?

2010-01-01 Thread Gabor Grothendieck
Try this: # same args as lapply. FUN must return named components. lapplyWithRename - function(...) { x - lapply(...) names(x) - sapply(x, names) lapply(x, function(x) { names(x) - NULL; x }) } # test function - if x is A then f returns c(Name A = A) f - function(x)

Re: [R] changing a list element's name during execution in lapply - possible?

2010-01-01 Thread Mark Heckmann
Thanks Gabor, this is what I was looking for. Mark Am 01.01.2010 um 16:05 schrieb Gabor Grothendieck: Try this: # same args as lapply. FUN must return named components. lapplyWithRename - function(...) { x - lapply(...) names(x) - sapply(x, names) lapply(x, function(x)

[R] need more help.... Re: iterating over a data frame the R way?

2010-01-01 Thread donahchoo
Okay, I don't know if I'm blocking because of my other programming language experience of if I'm just being dense. I have a data.frame with high,open,low,last,day, and start_time time columns. What I want to do is get all the rows with the same day and process each of those columns. If I

Re: [R] need more help.... Re: iterating over a data frame the R way?

2010-01-01 Thread donahchoo
Hum. data.frame was left off. Trying again... On Jan 1, 2010, at 10:20 AM, donahc...@me.com wrote: Okay, I don't know if I'm blocking because of my other programming language experience of if I'm just being dense. I have a data.frame with high,open,low,last,day, and start_time time

Re: [R] need more help.... Re: iterating over a data frame the R way?

2010-01-01 Thread Gabor Grothendieck
Reinstall R but this time choose the Mac version that includes tcl. You shouldn't have to separately install it. On Fri, Jan 1, 2010 at 11:20 AM, donahc...@me.com wrote: Okay, I don't know if I'm blocking because of my other programming language experience of if I'm just being dense. I have

[R] Questions bout SVM

2010-01-01 Thread Nancy Adam
Hi everyone, Can someone please help me in these questions?: 1)if I use crossvalidation with svm, do I have to use this equation to calculate RMSE?: mymodel - svm(myformula,data=mydata,cross=10) sqrt(mean(mymodel$MSE)) But if I don’t use crossvalidation, I have to use the

[R] Chainging monthly data to daily data

2010-01-01 Thread Megh
Hi, I have a zoo object with monthly frequency : library(zoo) dat - zooreg(rnorm(50), as.yearmon(2000-01-01), frequency=12) Now I want to make a zoo object with daily frequency from dat wherein value for a each day for a particular month will be value of dat at that particular month. Is there

Re: [R] cross validation for species distribution

2010-01-01 Thread Max Kuhn
Elaine, That's a fair answer, but completely not what I meant. I was hoping that you would elaborate on the species data of species distribution models. What types of inputs and output for this particular modeling application etc. Is it the same with the function inside caret, ipred, and e1071 

[R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Peng Yu
read.table terminates the program if the input file is empty. Is there way to let the program continue and return me a NULL instead of terminating the program? $ Rscript read_empty.R read.table(empty_data.txt) Error in read.table(empty_data.txt) : no lines available in input Execution halted $

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Henrik Bengtsson
Please give reproducible example, more information on your troubleshooting and sessionInfo(). Cannot reproduce: pathname - empty.txt cat(file=pathname) print(file.info(pathname)) size isdir mode mtime ctime empty.txt0 FALSE 666 2010-01-01 12:50:55

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Dylan Beaudette
?try On Fri, Jan 1, 2010 at 12:41 PM, Peng Yu pengyu...@gmail.com wrote: read.table terminates the program if the input file is empty. Is there way to let the program continue and return me a NULL instead of terminating the program? $ Rscript read_empty.R read.table(empty_data.txt) Error

Re: [R] How to not to terminate read.table if the input file is

2010-01-01 Thread Ted Harding
On 01-Jan-10 20:41:52, Peng Yu wrote: read.table terminates the program if the input file is empty. Is there way to let the program continue and return me a NULL instead of terminating the program? $ Rscript read_empty.R read.table(empty_data.txt) Error in read.table(empty_data.txt) : no

Re: [R] How to not to terminate read.table if the input file is

2010-01-01 Thread jim holtman
?try df - try(read.table(...)) if (inherits(df, 'try-error')){ what to do if file empty } On Fri, Jan 1, 2010 at 3:55 PM, Ted Harding ted.hard...@manchester.ac.ukwrote: On 01-Jan-10 20:41:52, Peng Yu wrote: read.table terminates the program if the input file is empty. Is there way to let

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Peng Yu
Please reread my original post. You run it in a shell. I run it in a script. On Fri, Jan 1, 2010 at 2:53 PM, Henrik Bengtsson h...@stat.berkeley.edu wrote: Please give reproducible example, more information on your troubleshooting and sessionInfo().  Cannot reproduce: pathname - empty.txt

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Peng Yu
On Fri, Jan 1, 2010 at 2:54 PM, Dylan Beaudette dylan.beaude...@gmail.com wrote: ?try This works. Thank you! f=try(read.table(empty_data.txt)) Error in read.table(empty_data.txt) : no lines available in input if(class(f)=='try-error') { + f=NULL + } print(f) NULL

Re: [R] How to not to terminate read.table if the input file is

2010-01-01 Thread Peng Yu
On Fri, Jan 1, 2010 at 3:03 PM, jim holtman jholt...@gmail.com wrote: ?try df - try(read.table(...)) if (inherits(df, 'try-error')){  what to do if file empty } For the case of using try, it is better to use inherits() rather than class(), or it doesn't matter? On Fri, Jan 1, 2010 at 3:55

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread Peng Yu
On Fri, Jan 1, 2010 at 3:19 PM, Peng Yu pengyu...@gmail.com wrote: On Fri, Jan 1, 2010 at 2:54 PM, Dylan Beaudette dylan.beaude...@gmail.com wrote: ?try This works. Thank you! f=try(read.table(empty_data.txt)) Error in read.table(empty_data.txt) : no lines available in input One more

[R] How to use read.table with Hebrew column names ?

2010-01-01 Thread Tal Galili
Hello dear R help group, I am trying to read a .txt file, with Hebrew column names, while keeping the column names looking well in R - but without success. I uploaded an example file to: http://www.talgalili.com/files/aa.txt And am trying the command:

Re: [R] Chainging monthly data to daily data

2010-01-01 Thread Megh
In the mean time, I have done some research and found following link here : https://stat.ethz.ch/pipermail/r-sig-finance/2009q3/004677.html Although this is close to my problem, I am not interested in any sort of interpolation, rather fill the NA positions with corresponding month's price. Any

Re: [R] need more help.... Re: iterating over a data frame the R way?

2010-01-01 Thread David Winsemius
On Jan 1, 2010, at 11:20 AM, donahc...@me.com wrote: Okay, I don't know if I'm blocking because of my other programming language experience of if I'm just being dense. I have a data.frame with high,open,low,last,day, and start_time time columns. What I want to do is get all the rows with

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread David Winsemius
On Jan 1, 2010, at 4:42 PM, Peng Yu wrote: On Fri, Jan 1, 2010 at 3:19 PM, Peng Yu pengyu...@gmail.com wrote: On Fri, Jan 1, 2010 at 2:54 PM, Dylan Beaudette dylan.beaude...@gmail.com wrote: ?try This works. Thank you! f=try(read.table(empty_data.txt)) Error in

Re: [R] How to use read.table with Hebrew column names ?

2010-01-01 Thread milton ruser
Hi Tal, You want the colnames in hebrew? Case not, may be you can use colnames() to attrib new colnames. bests milton On Fri, Jan 1, 2010 at 4:47 PM, Tal Galili tal.gal...@gmail.com wrote: Hello dear R help group, I am trying to read a .txt file, with Hebrew column names, while keeping

Re: [R] How to not to terminate read.table if the input file is empty?

2010-01-01 Thread milton ruser
?try() On Fri, Jan 1, 2010 at 3:41 PM, Peng Yu pengyu...@gmail.com wrote: read.table terminates the program if the input file is empty. Is there way to let the program continue and return me a NULL instead of terminating the program? $ Rscript read_empty.R read.table(empty_data.txt)

Re: [R] How to use read.table with Hebrew column names ?

2010-01-01 Thread Tal Galili
Thanks Milton, But your solution would work for a one time problem, but in case I'd have a variable with Hebrew in it, or many files to process then your solution wouldn't scale up. Thanks anyway :) Tal Contact Details:---

Re: [R] How to use read.table with Hebrew column names ?

2010-01-01 Thread Tal Galili
Hi Jorge, Thank you for the answer, it is a lead. Though I am unsure as to what to do next with it :) Here is my session info: sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United

Re: [R] Chainging monthly data to daily data

2010-01-01 Thread Gabor Grothendieck
Repeat the code you found but use na.locf in place of na.spline. On Fri, Jan 1, 2010 at 4:57 PM, Megh megh700...@yahoo.com wrote: In the mean time, I have done some research and found following link here : https://stat.ethz.ch/pipermail/r-sig-finance/2009q3/004677.html Although this is close

Re: [R] How to use read.table with Hebrew column names ?

2010-01-01 Thread David Winsemius
On Jan 1, 2010, at 4:47 PM, Tal Galili wrote: Hello dear R help group, I am trying to read a .txt file, with Hebrew column names, while keeping the column names looking well in R - but without success. I uploaded an example file to: http://www.talgalili.com/files/aa.txt And am trying the

Re: [R] How to use read.table with Hebrew column names ?

2010-01-01 Thread David Winsemius
You might try: read.table(http://www.talgalili.com/files/aa.txt;, header = T, fileEncoding = UTF-8, sep = \t) -- David. On Jan 1, 2010, at 5:37 PM, Tal Galili wrote: Hi Jorge, Thank you for the answer, it is a lead. Though I am unsure as to what to do next with it :) Here is my session

[R] How to calculate density function of Bivariate binomial distribution

2010-01-01 Thread nykee
Am trying to do some study on bivariate binomial distribution. Anyone knows if there is package in R that I can use to calculate the density function of bivariate binomial distribution and to generate random samples of it. Thanks, -- View this message in context:

[R] ifelse and piecewise function

2010-01-01 Thread roger king
I am a novice user of R and I'm learning with R version 2.8.1, using WinEdt_1.8.1, under Widows Vista Home Version. ## The test function below, from a vector input, returns vector values: # and it contains an ifelsestatement TEST- function(x) { low- -x^2 up- x^4 ifelse(x=0,up,low )

Re: [R] How to calculate density function of Bivariate binomial distribution

2010-01-01 Thread milton ruser
Hi Nykee, I checked out ??bivariate on my R installed libraries, and found about a hundred of occurrences of bivariate. If nobody reply you with a streigth answer, give a look at: VGAM; splancs; sm; prada; geoR; fUtilities; fBasics; akima; adehabitat; vegan; ade4 and spatstat packages. bests

[R] help with for loop

2010-01-01 Thread Rafael Moral
Dear useRs, I want to write a function that generates all the possible combinations of diff(). Example: If my vector has length 5, I need the diff() until lag=4 - c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3), diff(my.vec, lag=4)) If it has length 4, I need until lag=3 -

Re: [R] ifelse and piecewise function

2010-01-01 Thread jim holtman
Look at what 'loww' is in your function. You are passing in a vector of length 5 and that is what is being passed into integrate for 'lower' which is expecting an object of length 1. So determine what you want to pass in for lower (e.g., min(loww)). On Fri, Jan 1, 2010 at 7:44 PM, roger king

Re: [R] help with for loop

2010-01-01 Thread jim holtman
Look at your function; it is returning exactly what you are asking for: x.dif - c(diff(my.vec), diff(my.vec, lag=i)) # the first and last values You probably want something like this: dif - function(my.vec) { x.diff - diff(my.vec) for(i in 2:(length(my.vec)-1)) { x.dif - c(x.diff, diff(my.vec,

Re: [R] ifelse and piecewise function

2010-01-01 Thread David Winsemius
On Jan 1, 2010, at 7:44 PM, roger king wrote: I am a novice user of R and I'm learning with R version 2.8.1, using WinEdt_1.8.1, under Widows Vista Home Version. ## The test function below, from a vector input, returns vector values: # and it contains an ifelsestatement TEST-

Re: [R] help with for loop

2010-01-01 Thread Gabor Grothendieck
diff.zoo in the zoo package can take a vector of lags: library(zoo) z - zoo(seq(10)^2) diff(z, 1:4) There are three vignettes (pdf documents) that come with zoo that have more info on the package. On Fri, Jan 1, 2010 at 8:16 PM, Rafael Moral rafa_moral2...@yahoo.com.br wrote: Dear useRs, I

[R] Boxplot- change y axis partition

2010-01-01 Thread elaine kuo
Hello, I am a newbie to R. Now I am learning to draw boxplot using graphics(). I want to change the default setting of y asix. from 0, 0.1, 0.2,0.8 to 0, 0.4, 0.8. Please kindly share the command and thank you. Elaine [[alternative HTML version deleted]]

[R] Boxplot- change the vertical line from dash to solid

2010-01-01 Thread elaine kuo
Dear, I am a newbie to R. Now I am learning to draw boxplot using graphics(). I want to change the vertical line penetrating the box from dashed line to solid line Please kindly share the command and thank you. Elaine [[alternative HTML version deleted]]

[R] Boxplot- input the median point and the median value

2010-01-01 Thread elaine kuo
Dear, I am a newbie to R. Now I am learning to draw boxplot using graphics(). I want to highlight the median position with a round point and the value left (or on the top of)to the point. Please kindly share the command and thank you. Elaine [[alternative HTML version deleted]]

[R] to discriminate AUC of different models

2010-01-01 Thread elaine kuo
Dear, Regarding the methodology comparing the power of AUC generated by differernt models, please kindly suggest any R code available for the function. (similar to DeLong, DeLong, and Clarke-Pearson (1988) ) Thank you very much. Elaine [[alternative HTML version deleted]]

[R] Help with tryCatch

2010-01-01 Thread John Sorkin
Windows XP R 2.8.1 Colleagues, I am trying to run a function testone() and if the function completes without error do one set of instructions, and if the function generates either a warning or an error run another set of instructions. I have read try, and tryCatch help screens at least 20

[R] Help needed on applying a function across different data sets and aggregating the results into a single data set

2010-01-01 Thread Girish A.R.
Hi folks, Wish y'all a Happy New Year 2010! I need some help with the following: Say I have lots of data sets, on which I have to apply a certain function on the same set of columns in each of the data set. Let's take, for ex, the typical data set is: df1 -

[R] Please help me!!!! Error in `[.data.frame`(x, , retained, drop = FALSE) : undefined columns selected

2010-01-01 Thread bbslover
I am learning the package caret, after I do the rfe function, I get the error ,as follows: Error in `[.data.frame`(x, , retained, drop = FALSE) : undefined columns selected In addition: Warning message: In predict.lm(object, x) : prediction from a rank-deficient fit may be misleading I

Re: [R] Help needed on applying a function across different data sets and aggregating the results into a single data set

2010-01-01 Thread jim holtman
try this (and happy new year): DF - cbind(df1,df2,...,df100) result - lapply(DF, function(.name){ lsfit(get(.name)$A, get(.name)$B) }) do.call(rbind, result) # put into matrix On Fri, Jan 1, 2010 at 10:34 PM, Girish A.R. garam...@gmail.com wrote: Hi folks, Wish y'all a Happy New Year

[R] using optim

2010-01-01 Thread Erin Hodgess
Dear R People: I know that you can use optim for a function with several parameters. Is there an equivalent for 2 functions, please? Or should I put together a finite difference type of matrix, etc., please? Thanks, Happy New Year, Erin -- Erin Hodgess Associate Professor Department of

Re: [R] Help with tryCatch

2010-01-01 Thread David Winsemius
Dr Sorkin; You are a smart person. Why are you unable to create a working example that would allow testing of the code structure? On Jan 1, 2010, at 10:27 PM, John Sorkin wrote: coeffs - matrix(nrow=10, ncol=3) dimnames(coeffs) -list(NULL,c(BMI,BMIsq,min)) # set row counter n-0 #

[R] caculate the frequencies of the Amino Acids

2010-01-01 Thread che
may some one please help me to sort this out, i am trying to writ a R code for calculating the frequencies of the amino acids in 9 different sequences, i want the code to read the sequence from external text file, i used the following code to do so: x-read.table(sequence.txt,header=FALSE) then i

Re: [R] Help needed on applying a function across different data sets and aggregating the results into a single data set

2010-01-01 Thread David Winsemius
On Jan 1, 2010, at 10:34 PM, Girish A.R. wrote: Hi folks, Wish y'all a Happy New Year 2010! I need some help with the following: Say I have lots of data sets, on which I have to apply a certain function on the same set of columns in each of the data set. Let's take, for ex, the

Re: [R] caculate the frequencies of the Amino Acids

2010-01-01 Thread David Winsemius
On Jan 1, 2010, at 11:59 PM, che wrote: may some one please help me to sort this out, i am trying to writ a R code for calculating the frequencies of the amino acids in 9 different sequences, i want the code to read the sequence from external text file, i used the following code to do

Re: [R] Identifying outliers in non-normally distributed data

2010-01-01 Thread S Ellison
If you're interested in handling outliers in analytical proficiency testing read current and past IUPAC guidance on PT (see http://www.iupac.org/objID/Article/pac7801x0145) and particularly references 1, 4, 5, and 11 therein, for starters. Although one might reasonably ask whether outliers are

Re: [R] caculate the frequencies of the Amino Acids

2010-01-01 Thread David Winsemius
On Jan 2, 2010, at 12:26 AM, David Winsemius wrote: On Jan 1, 2010, at 11:59 PM, che wrote: may some one please help me to sort this out, i am trying to writ a R code for calculating the frequencies of the amino acids in 9 different sequences, i want the code to read the sequence from

Re: [R] caculate the frequencies of the Amino Acids

2010-01-01 Thread che
i know it would be better to ask R to make the data, but i need to sequence this particular file, because it is data for some Amino Acids and i cant play with, so i need to ask R to go through the sequence one by one, and then give me the numbers of each letters of each sequence, i am quite

Re: [R] Help needed on applying a function across different data sets and aggregating the results into a single data set

2010-01-01 Thread Girish A.R.
Thanks for the replies, Jim, David, and Dennis (who replied to me directly)! To summarize, here's what worked for me: === dflist - list(df1, df2, df3) lsfun - function(df) with(df, lsfit(A, B)$coef) res - lapply(dflist, lsfun) do.call(rbind, res) === cheers, -Girish Girish

Re: [R] caculate the frequencies of the Amino Acids

2010-01-01 Thread David Winsemius
On Jan 2, 2010, at 12:55 AM, che wrote: i know it would be better to ask R to make the data, but i need to sequence this particular file, because it is data for some Amino Acids and i cant play with, so i need to ask R to go through the sequence one by one, and then give me the numbers

Re: [R] Boxplot- input the median point and the median value

2010-01-01 Thread milton ruser
Dear Elaine, The posting guide is http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html bests milton On Fri, Jan 1, 2010 at 8:53 PM, elaine kuo elaine.kuo...@gmail.com wrote: Dear, I am a newbie to R. Now I am learning to draw boxplot using graphics().

[R] suppress output for meta in package tm

2010-01-01 Thread Amber Jaycocks
Hello, I am using the tm package and wish to suppress the output for meta. I am defining another variable for one of the tags and don't want the value printed on the screen. Any help would be appreciated. Thanks. here is the commnad: n_corp_file - meta(corpa[[n]], URI) -Amber