[R] problems with geom_vline, histograms, scale=free and facets in ggplot

2011-06-10 Thread Julian Burgos
Dear list, I´m having a little trouble with adding vertical lines to a histogram. I need to draw a matrix of histograms (using facets), and in each histogram add a vertical line indicating the mean value of the data in each facet. According to the last example in the geom_hline help, to display

Re: [R] R-/Text-editor for Windows?

2011-01-31 Thread Julian Burgos
> I've tried Emacs Speaks Statistics and found it just confusing, to say > the least (by the way, I'm puzzled by why so many people adhere to > this one. Maybe it's a matter of getting used to it...?) You are right... it is confusing, and it takes some time to get used to, and it is not for everyo

[R] post-hoc comparisons in GAMs (mgcv) with parametric terms

2011-01-25 Thread Julian Burgos
Dear list, I´m wondering if there is something analogous to the TukeyHSD function that could be used for parametric terms in a GAM. I´m using the mgcv package to fit models that have some continuous predictors (modeled as smooth terms) and a single categorical predictor. I would like to do post

Re: [R] help me understand how things work.

2010-09-16 Thread Julian Burgos
Hi Alex, What is happening is that the ´dist´function calculates a distance matrix, and returns an object of the ´dist´ class. > temp <- rbind (c(10,1),c(99,98)) > x=dist(temp) > x 1 2 131.6435 > class(x) [1] "dist" You can see a description of the ´dist´class at the end of the function

Re: [R] Strange behaviour when using diff with POSIXt and POSIXlt objects

2010-05-21 Thread Julian Burgos
Hi Brian, This is really odd. I keep getting the NA secs answer, only by running these three lines of code in a new session. > time3=strptime("2009 06 01 00 47 00",format="%Y %m %d %H %M") > time4=strptime("2009 06 01 00 57 00",format="%Y %m %d %H %M") > diff(c(time3,time4)) Time difference of

Re: [R] Strange behaviour when using diff with POSIXt and POSIXlt objects

2010-05-20 Thread Julian Burgos
me4=strptime("2009 06 01 00 57 00",format="%Y %m %d %H %M") > > > > diff(c(time3,time4)) > Time difference of 10 mins > > > > I have version 2.10.1 > > On Thu, May 20, 2010 at 12:36 PM, Julian Burgos wrote: > > Dear list, > > > >

[R] Strange behaviour when using diff with POSIXt and POSIXlt objects

2010-05-20 Thread Julian Burgos
Dear list, I´m calculating time differences between series of time stamps and I noticed something odd: If I do this... > time1=strptime("2009 05 31 22 57 00",format="%Y %m %d %H %M") > time2=strptime("2009 05 31 23 07 00",format="%Y %m %d %H %M") > > diff(c(time1,time2),units="mins") Time differ

[R] GAM for non-integer proportions

2010-02-14 Thread Julian Burgos
Dear list, I´m using the mgcv package to model the proportion by weight of certain prey on the stomach content of a predator. This proportion is the ratio of two weights (prey weight over stomach weight), and ranges between 0 and 1. The variance is low when proportion is close to 0 and 1, and hi

[R] linear models with variance in dependent and independent variables

2010-01-31 Thread Julian Burgos
Dear list, I need to fit a multiple regression in which individual data point in the independent and the dependent variables have an associated variance or standard deviation. To make things clear, instead of having just a table of dependent (X) and independent (Y1, Y2) variable values like this:

Re: [R] SOM library - where do I find it

2009-11-18 Thread Julian Burgos
You have to download it from CRAN and install it. From the GUI, do Packages->Install package(s). Pretty basic stuff...you should check the documentation before posting. Julian > > > R version 2.9.2 (2009-08-24) - for windows > >> library(SOM) > Error in library(SOM) : there is no package calle

Re: [R] compute differences

2009-09-21 Thread Julian Burgos
Here is an approach...probably there are more elegant ways mydata=data.frame(ID=c("A","B","C","D","E"),val=c(.3,1.2,3.4,2.2,2.0)) index=expand.grid(1:nrow(mydata),1:nrow(mydata)) dif=data.frame(difference=mydata$val[index$Var2]-mydata$val[index$Var1]) rownames(dif)=paste(mydata$ID[index$Var2],"-

[R] ggplot2 legend text....a basic question

2009-09-14 Thread Julian Burgos
Hello fellow R's, I´ve been learning to use the ggplot2 library, and after a full day of work I still have a couple of basic questions. Here is an example: mydata=data.frame(x=runif(20),y=runif(20),n=runif(20)) mydata2=data.frame(x=c(0.4,0.6,0.5),y=c(0.4,0.4,0.6)) ggplot(mydata, aes(x, y)) +

Re: [R] Out of memory issue

2009-04-24 Thread Julian Burgos
"PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code." Otherwise...the only other possible suggestion is to use a smaller file. Julian Neotropical bat risk assessments wrote: Hi all, I am trying to run

Re: [R] Forcing the extrapolation of loess through the origin

2009-04-14 Thread Julian Burgos
Hi Torsten, If you are fitting a line, why are you using "loess"? Why not simply use "lm" to fit a regression line that goes through the origin? (i.e. with no intercept). Julian jimm-pa...@gmx.de wrote: Hi all, I'm fitting a line to my dataset. Later I want to predict missing values that

Re: [R] coalesce columns within a data frame

2008-10-22 Thread Julian Burgos
You could do something like this: > Name.x=c('nx1','nx2',NA,NA) > Name.y=c('ny1','NA','ny3',NA) > Name=Name.x > Name[is.na(Name.x)]=Name.y[is.na(Name.x)] > Name [1] "nx1" "nx2" "ny3" NA Julian Ivan Alves wrote: Dear all, I searched the mail archives and the R site and found no guidance (t

Re: [R] 3 curves / 1 plot

2008-10-06 Thread Julian Burgos
You can use the points() and lines() functions to add points and lines to an existing plot. Julian Michel PETITJEAN wrote: I am a new user of R. Please does somebody knows how to plot 3 datasets (x1,a1),...,(xn,an), (x1,b1),...,(xn,bn), and (x1,c1),...,(xn,cn) on a single x,y plot, each of the

Re: [R] Inverting data frame...row wise

2008-09-25 Thread Julian Burgos
How about something like my.data=my.data[,4:1] Julian milicic.marko wrote: Hi, I have the data.frame with 4 columns. I simply want to invert dataset so that last row becomes first... I tried with rev(my_data-frame) but I got my columns inverted... not my rows Thanks __

Re: [R] Question about col.names in write.csv

2008-09-05 Thread Julian Burgos
Hi Luz, No entiendo bien tu pregunta. Querés grabar una tabla con nombres en las columnas y tambien en la primera fila? Si es asi, tenés que asignarle los nombres a la tabla antes de grabar. Por ejemplo: mi.tabla=matrix(runif(30),ncol=3) colnames(mi.tabla)=c("A","B","C") rownames(mi.tabla)

Re: [R] Mclust - which cluster is each observation in?

2008-07-21 Thread Julian Burgos
Well, you are dealing with probability based clustering, so for each bird you will get a probability of belonging to each cluster. If your clusters are well defined, then each bird should have a very high probability of belonging to one of the clusters. You can get this probability matrix fro

Re: [R] using which to identify a range of values

2008-07-18 Thread Julian Burgos
Do simply which(a<100 & a>=200) Julian sj wrote: Hello, I am trying to identify values that fall within a certain range. I thought that I might be able to use the which function to do this but I have been unable to figure out a way to do it. Perhaps a little code will illustrate what i am try

Re: [R] more columns that column names

2008-06-02 Thread Julian Burgos
Hi Paul, The easiest thing to to is to open the file using a text editor (Notepad will do) and examine the first few lines. You can add add a column name if needed. Julian Paul Adams wrote: Hello to everyone, I have gotten my file to print to screen but when I use read.table I am getting

Re: [R] Problemas usando jri0.4-1 y R 2.7.0

2008-06-02 Thread Julian Burgos
Hola Borja, Creo que vas a tener muy pocas respuestas a menos que escribas a la lista en inglés. Lamentablemente yo conozco poco de Java y no puedo responder tu pregunta. Saludos, Julian Borja Soto Varela wrote: Hola, es la primera vez que mando un correo a cualquiera de las listas de cor

Re: [R] Excluding/removing row and column names on text output files

2008-05-30 Thread Julian Burgos
Hi Steve, You can use write.table: write.table(x, file="/Users/Desktop/Data.txt", sep="",row.names=F,col.names=F) Cheers, Julian Stropharia wrote: Dear R users, I've had no joy finding a solution to this online or in any of my R books. Many thanks in advance for any help you can give. I

Re: [R] Plot colors

2008-05-30 Thread Julian Burgos
You could do something like this: mydata=c(1,2,1,1,6,7,-1,-1,5,-1) color= as.numeric(mydata== -1) +1 plot(mydata,col=color) This will give you a plot where the -1's are in red (color = 2) and the other numbers in black (color=1). Julian uv wrote: Hi. I am plotting graphs for values ranging

Re: [R] Binning groups

2008-05-28 Thread Julian Burgos
see ?findIntervals francogrex wrote: Hi, this is probably quite simple but I can't seem to do it correctly. I have a data frame of counts of infections in different ages; something like: count=c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 7, 8, 8, 9, 9, 10, 11, 15, 17, 17, 17, 17, 19, 19, 19,

Re: [R] Help on nested FOR loops

2008-05-19 Thread Julian Burgos
Hey Philip, I'm not sure if I understand what your "x11", "x12", etc. are. You can combine the values of your two vectors using the expand.grid function. There is no need to do nester FOR loops: > i=c(1,2,3,4,5) > j=c(1,2,3) > x=expand.grid(i,j) > print (x) Var1 Var2 1 11 2 2

Re: [R] Can R handle large dataset?

2008-05-14 Thread Julian Burgos
Depends on the RAM in your machine. And in your definition of 'handle'. You may be able to load a very large dataset into R, but won't be able to use some functions that require additional memory. A vague answer to a vague question... :) Julian Mingjun Huang wrote: Hello, I am new to

Re: [R] A very simple question

2008-05-14 Thread Julian Burgos
Try this: k=c(1,1,1,2,2,1,1,1) > k[(k!=1)] [1] 2 2 > k[(k!=2)] [1] 1 1 1 1 1 1 > k[(k!=3)] [1] 1 1 1 2 2 1 1 1 Julian Shubha Vishwanath Karanth wrote: Hi R, Suppose l=c(1,1,1,2,2,1,1,1) k[-which(k==1)] [1] 2 2 k[-which(k==2)] [1] 1 1 1 1 1 1 But, k[-which(k==3)]

Re: [R] wavlet analysis

2008-05-14 Thread Julian Burgos
Hi Stephen, Your link doesn't work. In any case, check out the wavCWT function in the wmtsa package. Julian stephen sefick wrote: http://ion.researchsystems.com/cgi-bin/ion-p I would like a continuous wavelet transform. I have downloaded wavethresh, Rwave, and waveslim. I would like an ou

Re: [R] use list elements to subtract values from the dataframe

2008-05-07 Thread Julian Burgos
Try get(paste("wf$",fl[[1]],sep="")) See ?get Julian Dirkheld wrote: Hi, I have a dataframe wf existing of a header with different labels and beneath the values of those labels : wf: label1 label2 ... 0,450,21 0,100,45 I have a list fl <- c("label2","label3",..)

Re: [R] How to count the overlapped in two vectors

2008-05-01 Thread Julian Burgos
See ?match ss wrote: Dear list, If I have two vector, t1 and t2, of different lengths. Is there an easy way to count the number of the overlapped in two vectors and show the result in the graph? Thanks much, Alex [[alternative HTML version deleted]]

Re: [R] How do you test for "consecutivity"?

2008-04-29 Thread Julian Burgos
rop=prop/length(x) return(prop)} This function first identifies which numbers in your original vector are part of a sequence of consecutive numbers. Julian Julian Burgos wrote: Hey Anthony, There must be many ways to do this. This is one of them: #First, define a function to calculate

Re: [R] How do you test for "consecutivity"?

2008-04-29 Thread Julian Burgos
Hey Anthony, There must be many ways to do this. This is one of them: #First, define a function to calculate the proportion of consecutive numbers in a vector. prop.diff=function(x){ d=diff(sort(x)) prop=(sum(d==1)+1)/length(x) return(prop)} #Note that I am counting both numbers in a consecu

Re: [R] means and variances of several groups in the matrix

2008-04-24 Thread Julian Burgos
Hy Katie, There are many ways to do this. A simple one is to create a vector of the same length than your 'x' vector, containing a group label. > group=rep(c(1,2,3),times=nr[1,]) Then you can use tapply to apply a function (in this case mean and variance) of the values of x within each group

Re: [R] cumsum list..

2008-03-13 Thread Julian Burgos
In this case you can simply do cumsum(a[x,]+a[y,]) Julian yoo wrote: > Hi all, i have the following.. > > a <- data.frame(data = seq(1,10)) > > i have indices: > x <- c(1, 5, 3, 9) > y <- c(2, 7, 4, 10) > > I want the cumsum of a[1:2], a[5:7], a[3:4]... > > is there an elegant way to

Re: [R] I need to buy a book in R

2008-03-03 Thread Julian Burgos
Hello Kayj, There are very good tutorials at the R website. See here: http://cran.r-project.org/other-docs.html Julian kayj wrote: > Hi All, > > I am a new user in R and I would like to buy a book that teaches me how to > use R. In addition, I may nees to do some advanced statistical analysi

Re: [R] using an element of an array as a new object

2008-01-16 Thread Julian Burgos
See ?assign. ppaarrkk wrote: > I have an array called filesBox. I want to take each element of the first > column and assign a dataset to it. > > For example : > > filesBox[4,1] returns > > [1] "fileR" > > Then I want to assign "fileR" which exists as a text file to the R object > "fileR" lik

Re: [R] bootstrap sampling

2008-01-15 Thread Julian Burgos
See rnorm(). If you are sampling from a continuous normal distribution, it makes no sense to define a sample with replacement, because the probability of sampling twice the same number is zero. Julian sigalit mangut-leiba wrote: > Hello, > How do I sample observations with replacement from a n

Re: [R] how to go to a line in R

2008-01-15 Thread Julian Burgos
Tinn-R also has this option. I suspect most editors will also do. Julian -Halcyon- wrote: > RWinEdt has line indication. You might want to try that. > > > Uwe Ligges-3 wrote: >> This depends on the editor you use for writing R code rather than on R. >> >> Uwe Ligges >> >> Jack Luo wrote: >>>

Re: [R] Great looking plot - but what does it mean?

2008-01-07 Thread Julian Burgos
Hi Mika03, It would be useful to know what function you used to create your plot. Assuming you used boxplot, do this: ?boxplot ?boxplot.stats Julian mika03 wrote: > > http://www.nabble.com/file/p14668788/paragraphs.png > > Hi, > > R is is world full of wonders... I created the attached p

Re: [R] Calculate remainer

2007-12-20 Thread Julian Burgos
Hi Livia, There are several ways to do this. Try: a=50/12 floor(a) will give you the entire portion, and a-floor(a) will give you the remainder. Julian livia wrote: > Hello everyone, > > I have got a question about a simple calculation. If I would like to > calculate 50/12 and return the re

Re: [R] detailed calculation of two way anova with unbalanced design

2007-12-14 Thread Julian Burgos
Hi Jack, Any intro stats book should have them. See for example chapter 11 in Sokal and Rohlf (2nd ed., 1981). Julian Jack Luo wrote: > Dear list, > > Could someone show me where can I find the detailed formula on how to > calculate the two way anova with unbalanced design? Say, if I have 2*2

Re: [R] [OT] vernacular names for circular diagrams

2007-12-13 Thread Julian Burgos
I should say that the name of this chart varies even among Spanish-speaking countries. In Argentina is "diagrama de torta" which is something like "cake-chart". Julian ahimsa campos-arceiz wrote: > Two non-eatable examples from Spain and Japan: > > in Spanish we call them "diagrama de sector

Re: [R] Importing Large Dataset into Excel

2007-12-12 Thread Julian Burgos
Hi Wayne, I'm assuming that you file is really a comma-separated file (*.csv) and not an Excel workbook (*.xls) saved with a .csv extension, right? That (in my experience) is a common mistake. You should open your file with a simple text editor (notepad will do if the file is not too large) an

Re: [R] combine variables to matrix

2007-12-12 Thread Julian Burgos
Hi Andre, I don't quite understand what you are trying to do. Why you are using cbind to join columns of a dataset that it is already in table form? It is true that read.table will give you a data.frame instead of a matrix, but if for some reason you need a matrix you can do simply data.matr

Re: [R] matrix graph

2007-12-12 Thread Julian Burgos
The basic functions you need are image() contour() although I like better the plot.surface() function in the 'fields' package. Julian threshold wrote: > Hi All, simple question: > do you know how to graph the following object/matrix in a 'surface manner': > > [,1] [,2] [,3]

Re: [R] Help rewriting looping structure?

2007-12-10 Thread Julian Burgos
Hi TLowe, I'm not quite sure if I understand what you are trying to do. If you are trying to get the cumulative sum of your data frame along each column you can simply do rcumsum=function(x){cumsum(x)/sum(x)} apply(tdat,2,rcumsum) Yet that is not what your code is doing. With a bit of clarif

Re: [R] if/else for plot/lines?

2007-12-07 Thread Julian Burgos
The simplest way would be to have a flag, an indicator variable that stores a value that indicates if a plot has been done before. Something like this plot (do my first plot here...) is.plot=T later in the code... if (is.plot) {plot (do new plot here)} else {lines(add lines to the previ

Re: [R] image() plot with z not in matrix format

2007-11-29 Thread Julian Burgos
Hello Marc, Well, image() requires data values in a regular grid. So you need to interpolate your data to a regular grid before you do your plot. There are many interpolation methods, but a good place to start is to do linear interpolation. You should first use expand.grid() to create the r

Re: [R] Filling in a Zero Matrix

2007-11-26 Thread Julian Burgos
clearly what you are trying to achieve, we can help you to simplify your code. Julian Julian Burgos wrote: > Hi Amy, > Many (perhaps most) of the people on the list do not receive emails with > html...so we can't see colored text. Also it would be helpfully to have > a bit of you

Re: [R] Filling in a Zero Matrix

2007-11-26 Thread Julian Burgos
Hi Amy, Many (perhaps most) of the people on the list do not receive emails with html...so we can't see colored text. Also it would be helpfully to have a bit of your data, so we can run your code (see the posting guide in this regard,http://www.R-project.org/posting-guide.html). Please explai

Re: [R] Reconstruct array dataset

2007-11-21 Thread Julian Burgos
Hey Marc, You can use the function scan() directly to read your file as a single vector. Then, as Rob suggested, use the matrix function to give it the dimensions you want. Other option (perhaps less elegant) is to do something like this. x=read.table (myfile,...etc.etc.) x=as.vector(as.matri

Re: [R] better curve

2007-11-21 Thread Julian Burgos
Hello Mysimbaa, If you want to fit a smooth line to your data, there are many ways to do it. One option is to use splines. See the smooth.spline() function. If you only want to add a line to highlight the trend in your data, that should be enough. But if you want to do more serious analytica

Re: [R] Logarithmic axis

2007-11-20 Thread Julian Burgos
Like always, there is much to be learned from the R-help list! Another message had a much simpler approach. plot(xy.coords(reizstaerke, kennlinie1, log="x"), log="x") Julian Julian Burgos wrote: > Hey John, > > You can do simply > > plot(reizstaerke, k

Re: [R] Logarithmic axis

2007-11-20 Thread Julian Burgos
Hey John, You can do simply plot(reizstaerke, kennlinie1, ylim=c(0, max(kennlinie1, kennlinie2)),log="x") but if you want to fine tune where the tick marks are, you can do it "by hand". kennlinie1 <- c(8.0746909, 3.9916973, 9.9789444, 19.962869); kennlinie2 <- c(6.0994206, 8.9661081, 19.924

Re: [R] Trying to get around R

2007-11-20 Thread Julian Burgos
ponse as from Ben Bolker to my last infraction which > was "You might have better luck with this on the Bioconductor mailing list > ..." > > Rather than to the universe... > "Using the wrong list: this is for R-sig-mac, and the topic occcurred > there recently." >

Re: [R] delete a row in a matrix

2007-11-19 Thread Julian Burgos
Something like this? > a=matrix(1:9, ncol=3) > print(a) [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 > a=a[-2,] > print(a) [,1] [,2] [,3] [1,]147 [2,]369 You can use negative numbers to reference rows and/or columns, and you'l

Re: [R] Trying to get around R

2007-11-19 Thread Julian Burgos
Hello Epselon (if that is your name), This sounds like homework questions. From the R-help posting guide: "Basic statistics and classroom homework: R-help is not intended for these." If you have a specific question on R coding, do ask it (and provide reproducible code). But you should not e

Re: [R] About print a label in plot

2007-11-16 Thread Julian Burgos
Hey Allen, Again, if you don't tell us what kind of object 'Disease.FL' is, it will be difficult for us to help you. As I told you, plot() is a generic function and its behaviour will depend on the type of object you pass to it. For example, if 'Disease.FL' is an object of class lm (i.e. the

Re: [R] About print a label in plot

2007-11-16 Thread Julian Burgos
affy snp wrote: > Dear list, > > Hello! I have a question about how to print a label in the plot. > I am using the following code: > > width=5);plot(Disease.FL, index=i, type="Single",main="Plot of > Labels");dev.off(); > > But "Plot of Labels" has not been printed. Any suggestions? > > Thanks a

Re: [R] Plot problem

2007-11-15 Thread Julian Burgos
Hi Allen, Its difficult to know what is the problem without knowing what type of object is 'Disease.FL'. plot() is a generic function and it will act differently depending on the type of object you are passing to it. As always, you should provide 'provide commented, minimal, self-contained,

Re: [R] a repetition of simulation

2007-11-15 Thread Julian Burgos
x27;n find it. > Thank you, > Sigalit. > > > On 11/13/07, Julian Burgos <[EMAIL PROTECTED]> wrote: >> Well, the obvious (but perhaps not the most elegant) solution is put >> everything in a loop and run it 600 times. >> >> coefficients=matrix(N

Re: [R] Log random number

2007-11-14 Thread Julian Burgos
Hi Tobias, You'll have to explain what you mean with "log transformed values". If your question is if it is possible to generate random numbers from a normal distribution (using rnorm()) and then getting their logarithm, then you can do that with the obvious caveat that the logarithm is not d

Re: [R] How to get row numbers of a subset of rows

2007-11-14 Thread Julian Burgos
One way to do this is range(which(B[,2]==1)) Julian affy snp wrote: > Hello list, > > I read in a txt file using > > > by specifying the row.names=NULL so that the rows are numbered. > Below is an example after how the table looks like using > > > SNPChromosome Phys

Re: [R] TRUNCATED error with data frame

2007-11-13 Thread Julian Burgos
Hi Amit, Please read carefully the Mailing List Posting Guide (available at http://www.r-project.org/posting-guide.html). In particular, this section: "For new subjects, compose a new message and include the '[EMAIL PROTECTED]' (or '[EMAIL PROTECTED]') address specifically. (Replying to an ex

Re: [R] a repetition of simulation

2007-11-13 Thread Julian Burgos
run in each row. Julian sigalit mangut-leiba wrote: > I want to repeat the simulation 600 times and to get a vector of 600 > coefficients for every covariate: aps and tiss. > Sigalit. > > > On 11/13/07, Julian Burgos <[EMAIL PROTECTED]> wrote: >> And what

Re: [R] a repetition of simulation

2007-11-13 Thread Julian Burgos
And what is your question? Julian sigalit mangut-leiba wrote: > Hello, > I have a simple (?) simulation problem. > I'm doing a simulation with logistic model and I want to reapet it 600 > times. > The simulation looks like this: > > z <- 0 > x <- 0 > y <- 0 > aps <- 0 > tiss <- 0 > for (i in 1:5

Re: [R] factors levels ?

2007-11-13 Thread Julian Burgos
What you are looking for is the findInterval() function. Julian W Eryk Wolski wrote: > Hi, > > It's just some example code.. The application is uninteresting. I am > searching for some functionality. > > X <- rnorm(100) //my data > > Y <- seq(-3,3,by=0.1) // bin boundaries. > > Now I would li

Re: [R] How to subset a portion of columns from a matrix

2007-11-09 Thread Julian Burgos
No problem. Actually, I missed a comma. You should do A[,seq(1,dim(A)[2],2)] Julian affy snp wrote: > Hi Julian, > > Thanks for the help! > > Best, > Allen > > > > On Nov 9, 2007 11:08 PM, Julian Burgos <[EMAIL PROTECTED]> wrote: > >>

Re: [R] How to subset a portion of columns from a matrix

2007-11-09 Thread Julian Burgos
There are many ways. For example, you can do something like A[seq(1,dim(A)[2],2)] Julian Julian M. Burgos Fisheries Acoustics Research Lab School of Aquatic and Fishery Science University of Washington 1122 NE Boat Street Seattle, WA 98105 Phone: 206-221-6864 affy snp wrote: > Dear List

Re: [R] Extract correlations from a matrix

2007-11-08 Thread Julian Burgos
Hey Christoph, It is not clear what do you want to "extract". w[w>0.6] does give you the correlation values above 0.6. What is your question? Julian Christoph Scherber wrote: > Dear R users, > > suppose I have a matrix of observations for which I calculate all > pair-wise correlations: > >

Re: [R] please help me

2007-11-08 Thread Julian Burgos
Hi Azadeh, As the warning message is telling you, it seems that your initial parameters for the covariance functions are not very good. Something that you can do is to use the eyefit() function (package geoR) to fit your variogram "by eye" and get a first approximation for your covariance par

Re: [R] Can I replace NA by 0 (if yes, how) ?

2007-11-07 Thread Julian Burgos
Do this: pfit$coefficients[is.na(pfit$coefficients)]=0 Julian Ptit_Bleu wrote: > Hello, > > I'm trying to fit some points with a 8-degrees polynom (result of lm is > stored in pfit). > In most of the case, it is ok but for some others, some coefficients are > "NA". > I don't really understand t

Re: [R] partially sum variable of a dataframe

2007-11-07 Thread Julian Burgos
I'm assuming that you want to add b if 33 & a<5.25]) This is very simple R coding. I recommend you spend some time learning the basics. There are very good tutorials at the R website. Julian [EMAIL PROTECTED] wrote: > Hello, > > A stupid question: > > I have an array with two columns, the f

Re: [R] Some problem in opening connection with" .dat" extention file in matrix(scan) function of R 2.5

2007-11-01 Thread Julian Burgos
The error message is telling you that R cannot find your file. Is your 'motives_pc.dat' file in your R working directory? If not, you have to give a complete path to the scan() function. Julian [EMAIL PROTECTED] wrote: > Dear helpers please provide me some helpful answer to my problem while

Re: [R] loops & sampling

2007-11-01 Thread Julian Burgos
Hi Garth, Your code is really confusing! You should start by reading the help file on the for() function and understanding what it does: ?"for" Your line for(i in 1:nboot){ } is simply starting a loop around the variable 'i', which will change values following the sequence 1:nboot. It seems

Re: [R] data format

2007-10-30 Thread Julian Burgos
There are many ways. A simple one is to use split() to divide your 'Value' column using your 'Label' column as index. For example, # Create dataset mydata=data.frame(Label=c('Good','Bad','Good','Good','Good','Bad','Bad'), Value=c(10,12,15,18,12,15,10)) # Split the data mydata=split(mydata$Valu

Re: [R] How to switch off accepting the shortcut of column names

2007-10-30 Thread Julian Burgos
You cannot call a column on a dataframe using the first letter (or first few letters) if the letters match more than one name. Extraction methods for data frames allow partially matching row names, but if the result is undefined you get NULL in return. Try this. >first_item <- seq(1,10) >

Re: [R] Converting a string

2007-10-29 Thread Julian Burgos
I'm not sure what you mean. You should provide an example (i.e. some code). Julian Gang Chen wrote: > This must be very simple, but I'm stuck. I have a command line in R > defined as a variable of a string of characters. How can I convert > the variable so that I can execute it in R? > > Re

Re: [R] Adding pagebreaks on files???

2007-10-29 Thread Julian Burgos
I do this all the time. Simply, a) Open your pdf file using the pdf function. b) Do a bunch of plots. Because now the pdf file is your active device, every time you call a new plot you should get a new page. You can also use par(mfrow=...) to split the page (the same way you do it on a window),

Re: [R] gam for longitudinal data?

2007-10-29 Thread Julian Burgos
You can use the gamm function (in the mgcv package) to fit generalized additive mixed models and specify your covariance structure. Julian gallon li wrote: > I used gam for data analysis a lot. Is it possible to use gam to analyze > longitudinal data? I mean, besides the working independence ass

Re: [R] data frame usage

2007-10-25 Thread Julian Burgos
Check out the tapply function. ?tapply Julian Bernd Jagla wrote: > Hi, > I am new to R and couldn't find any information on how to handle my table > data that I just read in the way I want to use it.. > > I read in a table from a file: > x <- read.delim("filenam", header=TRUE) > > one column (

Re: [R] jEdit for R

2007-10-24 Thread Julian Burgos
Hi Rob, I used jEdit, but I'm not sure if there is a 'ctrl-R' option available. I eventually switched to Tinn-R, which is an editor customized for R (although I can be used for other languages) and does provide the connection to R you are looking for. Also (I think) loads faster and it is mo

Re: [R] Looped t.test results according to a subset variable

2007-10-22 Thread Julian Burgos
ng the following: > > by(percent, quiz, function(percent) {t.test(percent~group, > data=marks.long)}) > > But the results it gave me weren't t.tests of percent by group according > to quiz number. > > > Julian Burgos wrote: >> See by() >> >> M

Re: [R] Looped t.test results according to a subset variable

2007-10-22 Thread Julian Burgos
See by() Matthew Dubins wrote: > Hi all, > > I wrote a simple function that gives me multiple t.test results > according to a subset variable and am wondering whether or not I > reinvented the wheel. Observe: > > t.test.sub <- function (formula, data, sub, ...) > { > for(i in 1:ma

Re: [R] Matrix manipulation

2007-10-22 Thread Julian Burgos
Matrices are not made of paper! :) If you index a matrix with negative numbers, you'll get back that matrix minus that column or row. A quick example: >a<-matrix(c(1:9),ncol=3) # Create a sample matrix >a# Display it [,1] [,2] [,3] [1,]147 [2,]2

Re: [R] Spatial autocorrelation

2007-10-22 Thread Julian Burgos
Hi Geertje, You should look into linear mixed-effects models. In these you can incorporate spatial correlation explicitly. The basic function to use is lme(), but you should do some reading about this type of models before jumping into it. An excellent resource is the book "Mixed Effects Mo

Re: [R] variance explained by each term in a GAM

2007-10-12 Thread Julian Burgos
duction in deviance. For example: >> >> m1=gam(y~s(x1) + s(x2)) # Full model >> m2=gam(y~s(x2)) >> m3=gam(y~s(x1)) >> >> ddev1=deviance(m1)-deviance(m2) >> ddev2=deviance(m1)-deviance(m3) >> >> Here, ddev1 would measure the relative propor

Re: [R] simple function with if -> lapply to dataframe

2007-10-10 Thread Julian Burgos
Hi Georg, The answer is in the warning message In if (x < 0) a <- -1 else a <- 1 : the condition has length > 1 and only the first element will be used Basically you are passing a vector of length>1 to a control flow expression (if() in this case) that requires only a vector of length one. See

Re: [R] disperse variable

2007-10-10 Thread Julian Burgos
Hi Stefo, You can use strsplit(), something like this: strsplit(x,split="_") You'll get a list with the three vectors. Julian Stefo Ratino wrote: > Hello all, > > I read the following variable > > x > x > 1 1_A1_ML1_a.DLL > 2 11_B1_ML2_a.DLL > 3 4_A1_ML3_a.DLL > 4 5

Re: [R] variance explained by each term in a GAM

2007-10-09 Thread Julian Burgos
ach term, and >> calculate the reduction in deviance. For example: >> >> m1=gam(y~s(x1) + s(x2)) # Full model >> m2=gam(y~s(x2)) >> m3=gam(y~s(x1)) >> >> ddev1=deviance(m1)-deviance(m2) >> ddev2=deviance(m1)-deviance(m3) >> >> Here, ddev1

Re: [R] combining vectors on unequal length

2007-10-04 Thread Julian Burgos
Well, if you bind two vectors you form an array with dimensions 2 x length of the longest vector. So you need to decide how to fill up the 'empty' spacies corresponding to the shorter vector. Recycling the shorter vector is the default action. If you just want to save the data, you could crea

Re: [R] Estimate correlation with bootstrap

2007-09-21 Thread Julian Burgos
Hi Andreas, Simply use one call to the sample function. Try this: a <- c(1,2,3,4,5,6,7,8,9,10) b <- c(1,1,56,3,6,6,6,7,2,10) boot.cor.a.b <- numeric(1000) for (i in 1:1000){ x=sample(10,replace=T) boot.cor.a.b[i]=cor(a[x],b[x]) } Note that in R you don't need to initialize the variables like

Re: [R] Percentiles in R

2007-09-11 Thread Julian Burgos
Hola Jose Luis, Sure, you can use quantile(). Use the probs argument. For example, to get the median do quantile(X,probs=0.5). Do ?quantile to learn about the different type of quantiles calculated by the funcion. Saludos, Julian Jose Luis Aznarte M. wrote: > Hi there! Still struggling t