Re: [R] change library path (for dummies)

2010-10-21 Thread Erik Iverson
?.libPaths clee wrote: hi all, How can I change the library path in R? I don't have permission to write to the default R library on the computer I am running R on. I have searched the forum and have not found anything that I understand, so I apologize if this has been asked before. Thanks

Re: [R] Importing CSV File

2010-10-24 Thread Erik Iverson
On 10/24/2010 04:57 PM, Jason Kwok wrote: I'm trying to import a CSV file into R and when it gets imported, the entries get numbered down the left side. How do I get rid of that? When you imported the CSV file into R, an object of class data.frame was created, and since you did not assign it

[R] Question on passing the subset argument to an lm wrapper

2010-10-24 Thread Erik Iverson
Hello, How would you go about handling the following situation? This is on R 2.12.0 on Ubuntu 32-bit. I have a wrapper function to lm. I want to pass in a subset argument. First, I just thought I'd use ## make example reproducible set.seed(123) df1 - data.frame(age = rnorm(100, 50, 10),

Re: [R] help with help()

2010-10-28 Thread Erik Iverson
claudia tebaldi wrote: Hi all Just this morning I upgraded to R 2.12.0 (for Mac OS X 10.6.4). All went well until I needed to run a help() or help.search() in my session, which I'm running within Emacs (ESS 5.3.7). That's very old version of ESS, I have no problems with 2.12.0 with ESS

Re: [R] Error message when creating a dataframe

2010-11-01 Thread Erik Iverson
I suggest using the most recent version of R (2.12.0 I believe) and providing a reproducible example, showing us exactly how you are creating this data.frame (assuming it still exhibits the behavior). --Erik ANJAN PURKAYASTHA wrote: Hi, I'm creating a data frame of 24 columns and 45101 rows.

Re: [R] How to stop showing messages while loading package?

2010-11-01 Thread Erik Iverson
Simply read the ?library help page, where you'll find under Details: To suppress messages during the loading of packages use ‘suppressPackageStartupMessages’: this will suppress all messages from R itself but not necessarily all those from package authors. Christofer Bogaso

Re: [R] how to view the top 20 lines in a long dataset

2010-11-01 Thread Erik Iverson
?head or just df[1:20, ] Louis Plough wrote: Hi, I am simply looking for the function that will allow you to look at the top 20 lines of a long dataset? LP On Mon, Nov 1, 2010 at 10:46 AM, Louis Plough lplo...@usc.edu wrote: Hi, I am trying to generate all possible permutations (choose 2)

Re: [R] How to unquote string in R

2010-11-03 Thread Erik Iverson
lord12 wrote: s= Hey a = Hello table = rbind(s,a) write.table(table,paste(blah,.PROPERTIES,sep = ),row.names = FALSE,col.names = FALSE) In my table, how do I output only the words and not the words with the quotations? You read the help page for the function you're using :). From

Re: [R] programming questions

2010-11-03 Thread Erik Iverson
ivo welch wrote: quick programming questions. I want to turn on more errors. there are two traps I occasionally fall into. * I wonder why R thinks that a variable is always defined in a data frame. is.defined(d) [1] FALSE d= data.frame( x=1:5, y=1:5 ) is.defined(d$z)

Re: [R] programming questions

2010-11-03 Thread Erik Iverson
alas, should R not come with an is.defined() function? ?exists a variable may never have been created, and this is different from a variable existing but holding a NULL. this can be the case in the global environment or in a data frame. is.null(never.before.seen) Error: objected

Re: [R] deleteing all but some observations in data.frame

2010-11-03 Thread Erik Iverson
It depends on which 20 you want. If you have a data.frame called 'test.df', you can do: #first 20 test.df[20, ] -or- head(test.df, 20) #random 20 test.df[sample(nrow(test.df), 20), ] None of this was tested, but it should be a start. --Erik Matevž Pavlič wrote: Hi, I am sure that

Re: [R] deleteing all but some observations in data.frame

2010-11-03 Thread Erik Iverson
Note that these methods don't 'delete' observations. They all create brand new objects that are subsets of the test.df object. You can effectively 'delete' the observations by replacing the original data.frame with the returned object... so test.df - head(test.df, 20) Erik Iverson wrote

Re: [R] avoiding too many loops - reshaping data

2010-11-03 Thread Erik Iverson
Hadley's reshape package (google for it) can do this. There's a nice intro on the site. library(reshape) cast(melt(mydf, measure.vars = value), city ~ brand, fun.aggregate = sum) city x y z 1a 3 23 450 2b 12 42 231 Although the numbers differ slightly? I've heard of

Re: [R] biding rows while merging at the same time

2010-11-03 Thread Erik Iverson
Just merge(df1, df2, all = TRUE) does it, yes? Dimitri Liakhovitski wrote: Hello! I have 2 data frames like this (well, actually, I have 200 of them): df1-data.frame(location=c(loc 1,loc 2,loc 3),date=c(1/1/2010,1/1/2010,1/1/2010), a=1:3,b=11:13,c=111:113) df2-data.frame(location=c(loc

Re: [R] Problems with points in plots when importing from pdf to an SVG editor

2010-11-04 Thread Erik Iverson
Just read the help page :). This is under Note in the ?pdf. On some systems the default plotting character ‘pch = 1’ is displayed in some PDF viewers incorrectly as a ‘q’ character. (These seem to be viewers based on the ‘poppler’ PDF rendering library). This may be due to

Re: [R] Loop

2010-11-04 Thread Erik Iverson
Hello, The best way to get help from people on the list is for you to give us *reproducible* examples of exactly what is you want. Usually, you can come up with some sample data and code that corresponds to your situation, and that we can run directly by cutting and pasting from the email. You

Re: [R] Converting Strings to Variable names

2010-11-04 Thread Erik Iverson
Anand Bambhania wrote: Hi all, I am processing 24 samples data and combine them in single table called CombinedSamples using following: CombinedSamples-rbind(Sample1,Sample2,Sample3) Please use reproducible examples. Now variables Sample1, Sample2 and Sample3 have many different

Re: [R] creating vectors with three variables out of three datasets

2010-11-04 Thread Erik Iverson
DomDom wrote: Hi there, i´ve got a problem with how to create a vector with three variables out of three seperate ascii files. These three ascii files contain pixel information of the same image but different bands and i need a matrix of vectors, with each vector containing the

Re: [R] setting attributes (SOLVED)

2010-11-04 Thread Erik Iverson
The learning curve of R is rather steep at start. Yes, it can be. I think the general advice would be to get a good Intro to R book if you're just starting out. That's certainly my advice. Or, get a book on some methods you're interested in that uses R (the Springer useR! series is really

Re: [R] subsets, %in%

2010-11-05 Thread Erik Iverson
Well, %in% returns a logical vector... So subset(dat, ! ID %in% someID) Also, from ?subset: Note that ‘subset’ will be evaluated in the data frame, so columns can be referred to (by name) as variables in the expression Thus, you don't need 'dat$ID', bur just 'ID' in the subset

Re: [R] assignment operator saving factor level as number

2010-11-05 Thread Erik Iverson
Could you give a small reproducible example please? It is not clear to me what your looping structure is doing, or what your goal here is. There may be a much simpler method than introducing subscripts. --Erik Wade Wall wrote: Hi all, I have a dataframe (df1) that I am trying to select

Re: [R] compare and replace

2010-11-06 Thread Erik Iverson
On 11/06/2010 11:36 AM, Robert Ruser wrote: Hello R Users, I'm wondering if there exists any elegant and simple way to do the following: I have a data.frame X fills in numbers. I have a vector y with numbers as well. Every value in X that is equal to any values in y should be replaced by e.g. 1.

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread Erik Iverson
What class of object / structure do you exactly want in the end? A matrix, a data.frame, a vector? johannes rara wrote: Hi, How to rbind these vectors from a list?: l - list(a = c(1, 2), b = c(1, 2, 3)) l $a [1] 1 2 $b [1] 1 2 3 do.call(rbind, l) [,1] [,2] [,3] a121 b

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread Erik Iverson
So what do you want the matrix to look like, since the number of columns will be different between the two rows? johannes rara wrote: Thanks, data.frame or matrix. -J 2010/11/8 Erik Iverson er...@ccbr.umn.edu: What class of object / structure do you exactly want in the end? A matrix

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread Erik Iverson
Then one solution is to use rbind.fill from the plyr package. johannes rara wrote: This is the ideal result (data.frame): result names X1 X2 X3 1 a 1 2 NA 2 b 1 2 3 2010/11/8 Erik Iverson er...@ccbr.umn.edu: So what do you want the matrix to look like, since the number

Re: [R] Random Sample

2010-11-08 Thread Erik Iverson
?set.seed is what you're looking for Xiaoxi Gao wrote: Hello R users, Here is my question about generating random sample. How to set the random seed to recreate the same random numbers? For example, 10 random numbers is generated from N(0,1), then runif(10) is used.What if I want to get the

Re: [R] arrays of arrays

2010-11-09 Thread Erik Iverson
This type of object has the matrix class in R. So just use ?matrix to create it. matrix(1:25, ncol = 5) for example. On 11/09/2010 08:55 PM, sachinthaka.abeyward...@allianz.com.au wrote: Hi All, I want to have an array/ matrix that looks this x- 0 0 1 1 1

Re: [R] Performing a geometric seqeunce using iterators?

2010-11-09 Thread Erik Iverson
On 11/09/2010 09:16 PM, vicho wrote: I want to make a function for geometric seqeunce since testing=function(x){i=1;ans=1;while(true){ans=ans+(1/x)^i ; i=i+1} ;return(ans)} doesn't work... the program is freeze... What exactly are you trying to do? Where does true get set? Did you mean

Re: [R] randomForest can not handle categorical predictors with more than 32 categories

2010-11-10 Thread Erik Iverson
Well, the error message seems relatively straightforward. When you run str(x) (you did not provide the data) you should see 1 or more components are factors that have more than 32 levels. Apparently you can't include those predictors in a call to randomForest. You might find the following

Re: [R] Consistency of Logistic Regression

2010-11-11 Thread Erik Iverson
Is the algorithm converging? Is there separation (i.e., perfect predictor) in the model? Are you getting a warning about fitted probabilities of 0 or 1?, etc. We would need much more information (preferably a reproducible example) before we can help. Benjamin Godlove wrote: Dear R developers,

Re: [R] indexing lists

2010-11-15 Thread Erik Iverson
Chris, Well, the 'answer' could be: which(sapply(a, function(x) all(x == c(1,2 But I wonder how these elements of 'a' in your actual application are coming to be? If you're constructing them, you can give the elements of the list names, and then it doesn't matter what numerical index they

Re: [R] how to update my own function

2010-11-23 Thread Erik Iverson
Edwin - I think the usual way to do this would be to use a function like lapply or mapply to call your function multiple times with varying arguments. For example, with one varying argument: lapply(list(3,5), test, z = 4) With multiple varying arguments: mapply(test, y = list(3,5), z = list(4,

Re: [R] exercise in frustration: applying a function to subsamples

2010-07-12 Thread Erik Iverson
Your code is not reproducible. Can you come up with a small example showing the crux of your data structures/problem, that we can all run in our R sessions? You're likely get much higher quality responses this way. Ted Byers wrote: From the documentation I have found, it seems that one of

Re: [R] SAS Proc summary/means as a R function

2010-07-12 Thread Erik Iverson
On 07/12/2010 07:16 PM, Roger Deangelis wrote: Hi, I am new to R. I am trying to create an R function to do a SAS proc means/summary proc.means ( data=bsebal; class team year; var ab h; output out=BseBalAvg mean=;

Re: [R] Substring function?

2010-07-13 Thread Erik Iverson
The high-level concept you need is called Regular Expressions. R supports these through several functions, see ?regex . Ralf B wrote: Hi all, I would like to detect all strings in the vector 'content' that contain the strings from the vector 'search'. Here a code example: content -

Re: [R] Accessing files on password-protected FTP sites

2010-07-13 Thread Erik Iverson
Is it possible to download data from password-protected ftp sites? I saw another thread with instructions for uploading files using RCurl, but I could not find information for downloading them in the RCurl documentation. Did you try the ?getURL function in RCurl? See the `Test the

Re: [R] Wrap column headers caption

2010-07-13 Thread Erik Iverson
Using this dataframe with quite long column headers, how can I wrap the text so that the columns are narrower. I was trying to use strwrap without success. Thanks reportDF - structure(list(IDDate = c(3/12/2010, 3/13/2010, 3/14/2010, 3/15/2010), FirstRunoftheYear = c(33 (119 ? 119), n (0 ?

Re: [R] [R-pkgs] New package list for analyzing list surveyexperiments

2010-07-13 Thread Erik Iverson
Raubertas, Richard wrote: I agree that 'list' is a terrible package name, but only secondarily because it is a data type. The primary problem is that it is so generic as to be almost totally uninformative about what the package does. For some reason package writers seem to prefer

Re: [R] create variables with indexes

2010-07-13 Thread Erik Iverson
Suppose I want create variables with indexes in their names, e.g., X_1_1, X_1_2, X_1_3, ..., X_1_10, X_2_1, X_2_2, X_2_3, .. X_2_10,..., X_10_1, X_10_2, ... X_10_10. It looks like I need to use 2 indexes I and J so I is looped from 1 to 10, and J is looped from 1 to 10. But I don't know how to

Re: [R] POSIXlt error

2010-07-13 Thread Erik Iverson
Do you care to share your sessionInfo() , as the Posting Guide asks? I cannot reproduce on: R version 2.11.1 (2010-05-31) i486-pc-linux-gnu On 07/13/2010 09:07 PM, Ian Seow wrote: Hi, I'm encountering a strange error in POSIXlt... anyone got a clue on this? as.POSIXlt(1982-01-01) Error in

Re: [R] convert data.frame to matrix - NA factor problem

2010-07-14 Thread Erik Iverson
syrvn wrote: Thanks again for your quick reply. I understood your procedure but now it is even more strange why my conversion does not work. In your example, the NA values are in brackets NA and what your procedure does is to convert these NA values into NA and then it seems to be possible to

Re: [R] How to see inside of this function?

2010-07-14 Thread Erik Iverson
Bogaso Christofer wrote: Hi, there is a function Skewness() under fBasics package. If I type skewness, I get followings: Case matters in R, so please be precise. skewness function (x, ...) { UseMethod(skewness) } environment: namespace:timeDate Would be great if

Re: [R] Backslash \ in string

2010-07-15 Thread Erik Iverson
On 07/15/2010 08:02 AM, Jannis wrote: Dear R community, is there any way to include a backslash in a charakter string without meaning some escape sequence? E.g. i need a string like: a- '\hline' Error: '\h' is an unrecognized escape in character string starting \h to include some latex

Re: [R] Mathematica and R

2010-07-15 Thread Erik Iverson
David Bickel wrote: Sage and Marc, thank you for your helpful replies. Since RLink enables R calls from Mathematica, I wonder if it would make the Mathematica Front End useful for organizing R work even if no Mathematica functions are needed. It would be nice R had something like the Front

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Erik Iverson
btc1 wrote: Hello, I have a vector, dates, as a series of 3 digit elements, i.e. date [1] 528 528 528 528 528 528 528 528 528 528 528 528 708 708 708 708 708 708 [19] 708 708 708 708 529 529 529 529 529 529 529 529 529 529 529 529 529 529 [37] 529 624 I need to convert them into julian,

Re: [R] calling functions

2010-07-15 Thread Erik Iverson
louisey wrote: Hello everyone!! I have written a function in R and need to call it more than once say M times then take an average of my output. How would I tell R to automatically call my function many times instead of just the once? The natural way will depend on what you're trying to

Re: [R] How to delete a date frame from a data frame

2010-07-15 Thread Erik Iverson
It's high time for a small, reproducible example. Don't say, for example, *give* us an example in R. That being said, something like combined[!names(combined) %in% names(miceSample)] might be a start... Addi Wei wrote: But miceSample has multiple columns... For example if nvars=4, I have

Re: [R] Proper use of grep

2010-07-15 Thread Erik Iverson
Doran, Harold wrote: I just need to confirm something with pattern matching folks. I have a factor with the following levels in a very large data set: levels(all$Classical.Statistic) [1] AB;ABD CollapsedSteps CR_PCR_Prop;CR_P;AB [6] NMK

Re: [R] Proper use of grep

2010-07-15 Thread Erik Iverson
Doran, Harold wrote: Thanks. Yes, I did that on a toy data set and with my real data. It *seems* to have worked. I just work with grep so rarely that I didn't want to miss something. Yes, I see no reason why it won't work. You can do another check 'manually'. You know how many of each you

Re: [R] Can I set default parameters for the default graphics device?

2010-07-15 Thread Erik Iverson
On 07/15/2010 07:10 PM, James wrote: I'm completely new to R, and I'd like to do something like this: x=c(1,2,3) plot(x,x) At this point, R creates a file Rplots.pdf, since the default device is PDF and the default filename is Rplots.pdf. Since you're completely new to R, I

Re: [R] Can I set default parameters for the default graphics device?

2010-07-15 Thread Erik Iverson
snip So instead of: mypng() x=c(1,2,3) plot(x,x) I can just do: x=c(1,2,3) plot(x,x) Isn't that what you can do after you define mypng and set options(device = mypng) ? __ R-help@r-project.org mailing list

Re: [R] Creating functions of many arguments

2010-07-15 Thread Erik Iverson
On 07/15/2010 08:32 PM, Axel Urbiz wrote: Dear users, My apologies for the simple question. I'd like to create a function where the number of arguments is as big as the size of my data set. Supose I have n observations in my data, how can I write a function like fun- function (x1,x2,,xn)

Re: [R] save plot

2010-07-16 Thread Erik Iverson
We need to know how you're doing this, with a minimal example that we can run. Most graphics devices accept a file or filename argument, so that's one way. If you're using the pdf device, multiple plots will create multiple pages in the final output.. linda.s wrote: I made a plot, but

Re: [R] Simple question regarding name of column headers

2010-07-16 Thread Erik Iverson
Anyway, I have often wished that something like new.mt.sample - miceTrainSample[, -pID50] would return miceTrainSample without the pID50 column. Here are three alternative ways to do it. # Method 1: Assign NULL to the column new.mt.sample - miceTrainsSample new.mt.sample$pID50 - NULL # Method

Re: [R] Help with Sink Function

2010-07-16 Thread Erik Iverson
This is not reproducible, and does not look minimal. You'll get better answers, and probably solve many issues on your own, if you construct small examples that illustrate the same problem you're having with your real data. Addi Wei wrote: iterations - 100 nvars - 4 combined -

Re: [R] invalid factor level, NAs generated

2010-07-16 Thread Erik Iverson
snip I think I have identified the problem such that when I identify the structure of some of the files that I am reading in, columns are labeled as Factors. In other files, the same columns are labeled as numeric values. Is there a way to assign the data structure to these columns in the

Re: [R] how to comment off sections

2010-07-16 Thread Erik Iverson
On 07/16/2010 06:59 PM, Joshua Wiley wrote: Hello, Is there an way to easy comment of sections of code? I was thinking something along the lines of \dontrun{ codeline 1 codeline k } but that could be used in regular script files. When I am still working on a script, I often want to

Re: [R] how to comment off sections

2010-07-17 Thread Erik Iverson
On 07/17/2010 01:05 AM, Joshua Wiley wrote: I use XEmacs + ESS, and looking for ways to add text to a region of code, I see it is quite easy with C-x r t. Thanks for your great advice. I use GNU Emacs. With a region of code actve, M-; will add the comment line (or remove it if it's already

Re: [R] specifying column names in a vector of characters and the use?

2010-07-18 Thread Erik Iverson
Hello, What I would like to do is have a data.frame with column names and have these column names stored as strings in another vector. Then I would like to be able to access the data.fram columns via referencing the vector of names. The code below shows the last few executions that failed to

Re: [R] invalid type error

2010-07-19 Thread Erik Iverson
jd6688 wrote: myDF = data.frame(id=c(A10,A20),d1=c(.3,.3),d2=c(.4,.4),d3=c(-.2,.5),d4=c(-.3,.6),d5=c(.5,-.2),d6=c(.6,-.4),d7=c(-.9,-.5),d8=c(-.8,-.6)) doit=function(x)c(x[1],sum_LK_positive=sum(x[-1][x[-1]0]),sum_LK_negative=sum(x[-1][x[-1]0])) myDF id d1 d2 d3 d4 d5 d6

Re: [R] concatenating column names in a loop

2010-07-19 Thread Erik Iverson
Josh B wrote: Hi all, I am trying to concatenate words together to create new column names, using a loop. Please consider the following toy example: x - matrix(nrow = 1, ncol = 3) colnames(x) - c(a, b, c) x[1,1] - 1 x[1,2] - 2 x[1,3] - 3 I would like to create a new matrix with column

Re: [R] conditonal if

2010-07-30 Thread Erik Iverson
On 07/30/2010 06:04 PM, putri wikie wrote: Hi, I have problem with my R program. Actually, it just a simple program, but I do not know the error is. Here is part of my program: if (tau2ca==0) {MVvc- 0.01} else {MVvc- tau2ca} ri_vc- si2/MVvc vi_vc- ri_vc + 1 Y_bar_vc-

Re: [R] Why do the results of paste() depend on how the argument (data.frame) is constructed?

2010-08-01 Thread Erik Iverson
On 08/01/2010 08:48 PM, thmsfuller...@gmail.com wrote: Hi, The following two 'df's should be the same, although their constructions are different. But they aren't the same. df1 - data.frame(X=c(1, 2, 3), Y=c(4, 5, 6)) df2 - data.frame(X=1:3, Y=4:6) identical(df1, df2) yields FALSE See

Re: [R] Why do the results of paste() depend on how the argument

2010-08-02 Thread Erik Iverson
Michael Lachmann wrote: On 08/01/2010 08:48 PM, thmsfuller...@gmail.com wrote: Hi, The following two 'df's should be the same, although their constructions are different. But they aren't the same. df1 - data.frame(X=c(1, 2, 3), Y=c(4, 5, 6)) df2 - data.frame(X=1:3, Y=4:6) identical(df1,

Re: [R] Apply function to two variables

2010-08-02 Thread Erik Iverson
I would like to apply a function to two vectors For example, A-c(NA,1,2,3,NA) B-6:10 I would like C to be equal to A but if any A element is NA that corresponding c element is equal to B, i.e. C = c(6,1,2,3,10) #untested... C - ifelse(is.na(A), B, A)

Re: [R] Using apply for logical conditions

2010-08-02 Thread Erik Iverson
Alastair wrote: Hi, I've got some boolean data in a data.frame in the form: XYZA B C [1] T TFT F F [2] F TTF F F . . . What I want to do is create a new column which is the logical disjunction of several of the columns. Just like:

Re: [R] lm length

2010-08-02 Thread Erik Iverson
Trying To learn again wrote: Hi all, I wanto to run a plot about the levels of a variable parting on an ols regression. The regression in done on the rate of return of the variable. Imagine R_{t}=a+b*R_{t-1} So If P, the estimated price would be P_{t}=P_{t-1}*R_{t} Imagine that I obtain

Re: [R] REmove level with zero observations

2010-08-03 Thread Erik Iverson
GL wrote: If I have a column with 2 levels, but one level has no remaining observations. Can I remove the level? What is a 'column'? An element of a data.frame? Does the following help? f1 - factor(L1, levels = c(L1, L2)) levels(f1) f1 - factor(f1) levels(f1) In absence of a

Re: [R] concatenate values in the vector

2010-08-03 Thread Erik Iverson
Cristian Montes wrote: Even shorter is x-c(a,b,c,d) paste(x, sep=+) x-c(a,b,c,d) paste(x, sep=+) [1] a b c d __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] releveling a numeric by factor interaction

2010-08-03 Thread Erik Iverson
Christy Denckla wrote: Can anyone help me with the necessary code to relevel a numeric*factor interaction term in a linear model? I would like to report the estimate, std. error and t-value for the reference factor. First, I estimated a linear model with dummy variables and was able to

Re: [R] how to read/save .zip compressed files from R?

2010-08-03 Thread Erik Iverson
j.delashe...@ed.ac.uk wrote: Quoting Prof Brian Ripley rip...@stats.ox.ac.uk: See also Omegahat package Rcompression (a copy of which for Windows is on CRANextras). Thank you, I will look into that. But I would do this via unzip, modify, zip once or even 10 times, yes. After that it

Re: [R] concatenate values in the vector

2010-08-03 Thread Erik Iverson
Cristian Montes wrote: Ok, sorry, I misinterpreted the question! Here is the right solution x - c(a, b, c, d, e) z - x[1] for (i in 2:length(x)) { z- paste(z, x[i], sep = +) } print(z) [1] a+b+c+d+e Or paste(x, collapse = '+') which was the solution that was in the

Re: [R] applying strsplit to a whole column

2010-08-04 Thread Erik Iverson
Dimitri Liakhovitski wrote: I am sorry, I'd like to split my column (names) such that all the beginning of a string (X..) is gone and only the rest of the text is left. x-data.frame(names=c(X..aba,X..abb,X..abc,X..abd)) x$names-as.character(x$names) (x) str(x) Can't figure out how to apply

Re: [R] Passing the name of a variable to a function

2010-08-04 Thread Erik Iverson
Hello, I have a problem which has bitten me occasionally. I often need to prepare graphs for many variables in a data set, but seldom for all. or for any large number of sequential or sequentially named variables. Often I need several graphs for different subsets of the dataset for a given

Re: [R] regression analysis with interactions

2010-08-04 Thread Erik Iverson
Jennifer Hou wrote: Hello, I have got a linear model that looks like this: lm(criterion ~ variable.A*variable.a + variable.B*variable.b + variable.C *variable.c) The output computed with stdCoeff() seems to be all right, but it does not show the coefficients of the interaction of the first

Re: [R] UNIX Server

2010-08-04 Thread Erik Iverson
What OS are you specifically referring to? Even the most basic web search surely would have turned up the R Installation and Administration Manual http://cran.r-project.org/doc/manuals/R-admin.html#Installing-R-under-Unix_002dalikes There may be pre-built packages available for your

Re: [R] For Loop

2010-08-05 Thread Erik Iverson
Hello, Please read the posting guide found at the bottom of every post to this list. We need to be able to see a small, reproducible example of code that illustrates your question. It sounds like you might be looking for ?replicate. On 08/05/2010 03:47 AM, Turn Fall wrote: I have some code

Re: [R] linear model with similar response predictor

2010-08-05 Thread Erik Iverson
On 08/05/2010 05:50 AM, Giuseppe Amatulli wrote: Hi, can somebody tell me why R is not able to calculate a linear model written in this way? lm (seq(1:100)~seq(1:100)) Call: lm(formula = seq(1:100) ~ seq(1:100)) Coefficients: (Intercept) 50.5 Warning messages: 1: In

Re: [R] A %nin% operator?

2010-08-05 Thread Erik Iverson
Just FYI, the Hmisc package has had an implementation of %nin% for some time now. Ken Williams wrote: Sometimes I write code like this: qf.a - subset(qf, pubid %in% c(104, 106, 107, 108)) qf.b - subset(qf, !pubid %in% c(104, 106, 107, 108)) and I get a little worried that maybe I've

Re: [R] regression analysis with interactions

2010-08-05 Thread Erik Iverson
Jennifer Hou wrote: Thank you very much for your kind reply, I have found that the error was in the stdCoeff function and not in the linear model. summary() works pretty well on my model, I will simply use another function to compute my coefficients. Best regards, Jennifer See ?coef ,

Re: [R] data.frame: return all rows where at least one...

2010-08-06 Thread Erik Iverson
On 08/06/2010 08:03 AM, Werner W. wrote: Hi, I know ways to do this but they all seem awkward and I somehow believe that there is a convenient shortcut. Since you don't show us what you tried, I don't know what you consider 'awkward'. If I have a data.frame with many columns, how can I

Re: [R] Computation Duration Time

2010-08-06 Thread Erik Iverson
?Rprof or ?system.time TGS wrote: Is there a way to find out what the computation duration time was to complete executing a code chunk? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

Re: [R] How to apply apply?!

2010-08-06 Thread Erik Iverson
Raghuraman Ramachandran wrote: guRus I have say a dataframe, d and I wish to do the following: 1) For each row, I want to take one particular value of the row and multiply it by 2. How do I do it. Say the data frame is as below: OPEN HIGH LOW CLOSE 1931.2 1931.2 1931.2 1931.2 0 0 0 999.05

Re: [R] How to start R

2010-08-07 Thread Erik Iverson
On 08/07/2010 10:29 AM, Stephen Liu wrote: Hi steve, After starting R which command shall I use to exit it rather than close the console. exit/quit did not work. Thanks What does did not work mean? help.search(quit) leads you to: ?quit quit() or q() should terminate the R session.

Re: [R] [Q] a dummy variable used with sapply

2010-08-07 Thread Erik Iverson
On 08/07/2010 01:00 PM, GMail (KU) wrote: Hello, While learning how to manipulate data with R, I found one example that I could not understand. In the following example, the function definition of maxcor has an argument named i and I don't understand why. Could someone explain why the maxcor

Re: [R] basic question about t-test with adjusted p value

2010-08-07 Thread Erik Iverson
On 08/07/2010 03:08 PM, josef.kar...@phila.gov wrote: I have read the R manual and help archives, sorry but I'm still stuck. How would I do a t-test with an adjusted p-value? Please be more specific about what you mean by 'adjusted p-value'. See below... Suppose that I use t.test ( ) ,

Re: [R] Need help on heatmap, K-means and hhierarchical clustering methods

2010-08-08 Thread Erik Iverson
On 08/08/2010 08:36 PM, meetsiddu1 wrote: Hi folks, I am new to the R software. I have been going through different materials to know more about R. I have the R software installed on my windows machine.I would like to know the R source code for the following problems on iris flower data set.

Re: [R] Invalid plot type '1'

2010-08-08 Thread Erik Iverson
On 08/08/2010 08:47 PM, Stephen Liu wrote: Hi folks, x [1] 1 2 3 4 5 y [1] 6 7 8 9 10 plot(x,y, type = 1 ) Error in plot.xy(xy, type, ...) : invalid plot type '1' I looked on man plot but unable to resolve. Please help. TIA You never say what you expect type = 1 (that's the

Re: [R] Invalid plot type '1'

2010-08-08 Thread Erik Iverson
On 08/08/2010 09:14 PM, Stephen Liu wrote: Hi Erik, I followed following video; Statistics with R (part 3: plot and history tutorial) http://www.youtube.com/watch?v=NfH5peM1RtIfeature=related It is type = 1. A graph was generated there. But I got an error msg No, it was type = l (the

Re: [R] Extract values from data frame in R

2010-08-09 Thread Erik Iverson
On 08/09/2010 01:16 AM, Alexander Eggel wrote: Using R, I would like to find out which Samples (S1, S2, S3, S4, S5) fulfill the following criteria:contain minimally one value (x, y or z) bigger than 4. Any ideas? Thanks, Alex. data Sample xy z 1S1 -0.35.3

Re: [R] Invalid plot type '1'

2010-08-09 Thread Erik Iverson
Stephen Liu wrote: The Introduction to R is rather terse, but a reasonable starting point. The other manuals listed on that page are special-purpose manuals for installation administration, development, etc.. You can try the manuals listed in the contributed documentation section too.

Re: [R] extracting information from an object

2010-08-10 Thread Erik Iverson
David, I was working on a project involving a linear model, and wanted to extract the standard error of a predictor. I am able to do so, but not in the way I would expect. I would have expected that if a created a model such as Model1 - lm(y~x,z,d), the object Model1 would contain that

Re: [R] Intersecting list vs rows in matrix

2010-08-10 Thread Erik Iverson
GL wrote: Know that if I have List_1 and List_2 that I can check to see if the intersect via the code below: List _1: a, b, c, d, e, f, g List_2: z, y, x, w, v, u, b length(intersect(List_1, List_2)) 0 return = true If instead I wanted to check a dataframe that is a list of lists, how

Re: [R] TRUE FALSE issue

2010-08-10 Thread Erik Iverson
On 08/10/2010 09:04 PM, Alexander Eggel wrote: How can I extract the samples (S1-S5) containing a TRUE value in their row? Solution should apply to a much bigger data frame. a Samples A B C D . . . 1 S1 FALSE FALSE FALSE FALSE 2 S2 FALSE FALSE NA TRUE 3 S3 FALSE FALSE FALSE FALSE 4 S4 FALSE

Re: [R] Arbitrary number of covariates in a formula

2010-08-11 Thread Erik Iverson
Are you for some reason against writing your function to accept a single argument, a formula, that you simply pass on to coxph? Mendolia, Franco wrote: Hello! I have something like this: test1 - data.frame(intx=c(4,3,1,1,2,2,3), status=c(1,1,1,0,1,1,0),

Re: [R] Using command line --file or -f

2010-08-11 Thread Erik Iverson
Gene Leynes wrote: *What I want to do: *Create a windows shortcut that will start the R gui **and** simultaneously source a file *What I have already tried: *This almost works, but it's not the interactive R GUI: R --no-save --sdi -file=C:\SomePath\example.R These open the R GUI, but

Re: [R] Data manipulation search

2010-08-11 Thread Erik Iverson
?match, look at the %in% operator. Mestat wrote: Hi listers, I made some search, but i didn`t find in the forum. I have a data set. I would like to make a search (conditon) on my data set. x-c(1,2,3,4,5,6,7,8,9,10) count-0 if (CONDITON){count-1}else{count-0} My CONDITION would be: is there

Re: [R] rpart package

2010-08-12 Thread Erik Iverson
Olga Shaganova wrote: Hi, I am a brand new user and may be my question is too simple. I have R on our (not Unix) server. I am trying to build a decision tree and the error message says couldn't find function rpart. Does it mean I have to ask our server guy to install an additional package?

Re: [R] Error in rowSums

2010-08-12 Thread Erik Iverson
Amit Patel wrote: Hi I am trying to calculate the row sums of a matrix i have created The matrix ( FeaturePresenceMatrix) has been created by 1) Read csv 2) Removing unnecesarry data using [-1:4,] command 3) replacing all the NA values with as.numeric(0) and all others with as.numeric (1)

Re: [R] factor failure

2010-08-12 Thread Erik Iverson
On 08/12/2010 08:00 PM, elaine kuo wrote: Dear list, factor function was tried but failed. Pls kindly help and thank you. E. code rm(list=ls()) library(faraway) data (pima) pima$test - factor (pima$test) [1] NA NA NA NA NA NA The unreported warning message should have given you a

  1   2   3   4   5   6   7   8   >