Re: [R] apply (or similar preferred) for multiple columns

2011-07-12 Thread Daniel Malter
Probably not the most elegant, but a workable solution. Assume you have a matrix x of dimensions 10 x 10. Assume further you want to calculate the mean for each successive block of two columns. One way to do this is to create a matrix that indicates the column numbers from/to which to apply the

Re: [R] Summation resulting in a list?

2011-07-11 Thread Daniel Malter
Use the tapply() function as in tapply(b,m,sum) HTH, Daniel mousy0815 wrote: ... I wanted to get the sum of the probability at all the values of b (ie. Probability(10, 0.1, 1, 1, 4, 5) + Probability(10, 0.1, 1, 2, 4, 5)... + Probability(10, 0.1, 1, 9, 4, 5). For that I can just use

Re: [R] computing functions with Euler's number (e^n)

2011-07-08 Thread Daniel Malter
The problem arises in the computation of U where (-dummy+1) turns negative (the eighth and higher index values of dummy). You raise a negative number to a non-integer power, for example, (-pi)^exp(1), which fails because you would not be able to tell, which sign the resulting number should have.

Re: [R] Repeating a function in R

2011-07-05 Thread Daniel Malter
Thanks, Uwe, for sending me this the second time. I send my responses through nabble. So #1 does not seem to be an option; #2 I sometimes forget. Regards, Daniel Uwe Ligges-3 wrote: On 02.07.2011 20:51, Daniel Malter wrote: You can just tell the function to create 1000 random numbers. See

Re: [R] For help in R coding

2011-07-03 Thread Daniel Malter
Say you have the string x in a matrix x-c('a,..gGGtTaac!T','caaGGTT,,.!!@CC') x-matrix(x) remove all punctuation: x1-gsub('[[:punct:]]','',x) x1 convert all letter to lowercase x2-gsub('(\\w*)','\\L\\1',x1,perl=T) x2 now for each row split the string and table it. apply over all rows in the

Re: [R] Repeating a function in R

2011-07-02 Thread Daniel Malter
You can just tell the function to create 1000 random numbers. See ?runif for the specifics. The arguments are n, min, and max. 'n' is the one you are looking for. Da. -- View this message in context: http://r.789695.n4.nabble.com/Repeating-a-function-in-R-tp3640508p3640966.html Sent from the R

Re: [R] Repeating a function in R

2011-07-02 Thread Daniel Malter
If you want to repeat an entire function, use replicate as in replicate(15,sapply(1,function(x) runif(x))) Here, sapply(1,function(x) runif(x)) draws on uniformly distributed variable. replicate(15,...) is the wrapper function that tells to do this 15 times. The benefit here is that you can

[R] create a factor variable from two numeric variables when order is irrelevant

2011-06-28 Thread Daniel Malter
Hi all, I have two numeric variables that form combinations in a matched sample. Let's say I have five levels of x and y. What I am seeking to create is a factor variable that ignores the order of x and y, i.e., the factor should indicate x=1, y=5, as the same factor as x=5, y=1. Obviously, this

Re: [R] a Weighted Least Square Model for a Binary Outcome

2011-06-28 Thread Daniel Malter
You can specify the weights=... argument in the lm() function as vector of weights, one for each observation. Should that not do what your are trying to do? HTH, Daniel -- View this message in context:

Re: [R] Help interpreting ANCOVA results

2011-06-22 Thread Daniel Malter
I think you should write out your model formula and then go over it term by term to see which term adds what to your understanding of the data. If necessary, pick up a text about the interpretation of coefficients. For example, you will find that Reduction is not just the slope for the condition

Re: [R] Linking 2 columns in 2 databases and applying a function

2011-06-22 Thread Daniel Malter
For example, you can merge the two data frames and do a direct comparison: df-merge(x,y,all.x=T,all.y=F) df df$Qdf$Threshold_Q HTH, Daniel Ryan Utz-2 wrote: Hi all, I have two datasets, one that represents a long-term time series and one that represents summary data for the time

Re: [R] lme convergence failure within a loop

2011-06-22 Thread Daniel Malter
I am not an expert in this. But try try() :) hth, Daniel Sam Nicol wrote: Hi R-users, I'm attempting to fit a number of mixed models, all with the same structure, across a spatial grid with data points collected at various time points within each grid cell. I'm trying to use a 'for'

Re: [R] interaction between categorical variables

2011-06-21 Thread Daniel Malter
The reason you get NAs is the rank deficiency. It even says that five coefficients are not defined because of singularities. It is likely the case that certain categories do not exist in the data. Note that in the example below y is ALWAYS zero when x is zero. This makes an interaction inestimable

Re: [R] (no subject)

2011-06-21 Thread Daniel Malter
Let us work backward. The pic_onscr() fails because lda_result does not exist. lda_result does not exist because your lda() fails. Your lda() fails because Error in lda.default(x, grouping, ...) : variables 1 3 5 8 10 15 17 20 27 29 34 appear to be constant within groups This indicates that

Re: [R] Unreasonable syntax error

2011-06-21 Thread Daniel Malter
I find this sign in the code multiple times: ¨C; I replaced those with *; there is also a MS-Word flexible hyphenation sign in there somewhere, probably standing for a minus sign. Other than that, there are a couple of output calls within loops that do not do anything anyway, but which seem to be

Re: [R] for loop and linear models

2011-06-20 Thread Daniel Malter
Hi, can you put return(models) within the inner braces and report what it does. That might do the trick, since it should return the 'models' for every combination of i and j. HTH, Daniel hazzard wrote: Hi, I have two datasets, x and y. Simplified x and y denote: X Y A B C A B

Re: [R] for loop and linear models

2011-06-20 Thread Daniel Malter
To be more accurate and helpful, try this: fun- function(x,y){ for(i in 1:length(colnames(x))){ for(j in 1:length(colnames(y))){ if(colnames(x)[i]==colnames(y)[j]){ models=list(lm(ts(x[i])~ts(y[j]))) return(models)

Re: [R] searching through two different texts files to find a common variable

2011-06-20 Thread Daniel Malter
You probably want to use the merge() function. imaginary example for data frames named KS and US, where the common identifier variable is named ID merged.data-merge(KS,US,by.x=ID,by.y=ID,all.x=F,all.y=F) Note that this will retain only observations for which there is a common ID in both KS and

Re: [R] how to get the miminum value in the list

2011-06-19 Thread Daniel Malter
Hi, that depends on whether you want to get the minimum within each list element or the global minimum across all list elements. The first is achieved by using lapply(). The second can be achieved by unlisting the list (which assumes that all list elements are numeric) and looking for its minimum.

Re: [R] Bartlett's Test of Sphericity

2011-06-18 Thread Daniel Malter
I do not understand why that would be the case as the only input involving the relationship of the data is the determinant of the correlation matrix. For what you suggest to be true, the non-normality of the data would have to introduce correlation. If what you are saying is true, we would

Re: [R] Bartlett's Test of Sphericity

2011-06-18 Thread Daniel Malter
Thanks for the clarification. That makes sense. To summarize, bartlett.test() in the base distribution of R is not the sphericity test, and it relies on the higher moments of the normal distribution. The sphericity test can be computed with the formula provided or the one implemented in the psych

Re: [R] Scatter plot produces 'x' and 'y' lengths differ

2011-06-17 Thread Daniel Malter
It likely means that your x and y are differently long. That is, affect1 and adh1scr do not contain the same number of values in that instance. That precludes them from being plotted against each other. abline and lowess would fail for the same reason. x-c(1,2,3) y-c(2,4) plot(y~x)

Re: [R] Merging yields Error: unexpected input ...

2011-06-17 Thread Daniel Malter
Note what are supposed to be quotation marks around ID in your post are a circumflex instead. Maybe the problem is that the quotation marks that are supposed to be around ID are not recognized by your R version. May you do not use the proper font encoding. Use straight quotation marks or

Re: [R] NonParametric Anova

2011-06-17 Thread Daniel Malter
A function for non-parametric multivariate analysis of variance (should do univariate, too, I guess) allowing for interactions (as far as I can tell) is implemented in the anosim() function of the vegan package. See also: http://cc.oulu.fi/~jarioksa/opetus/metodi/vegantutor.pdf

Re: [R] Size argument in sample function

2011-06-17 Thread Daniel Malter
I am sure there is a more elegant version of doing this. But this works: x-rnorm(20) y-matrix(1:5) #number of points to sample f-function(z){sample(x,z)} apply(y,1,f) Just adjust y to your liking. HTH, Daniel alfredo wrote: Hi All, I'd like to randomly sample a vector N times, where

Re: [R] Conditional Correlation

2011-06-17 Thread Daniel Malter
This question was just answered yesterday in this post: http://r.789695.n4.nabble.com/Correlations-by-subgroups-td3599548.html#a3600553 One solution: x-c(1,1,1,1,1,2,2,2,2,2) y-rnorm(10) z-y+rnorm(10) by(data.frame(y,z),factor(x),cor) HTH, Daniel Mateus Rabello wrote: Hi, How can I

Re: [R] Bartlett's Test of Sphericity

2011-06-17 Thread Daniel Malter
The formula for the chi-square value is: -( (n-1) - (2*p-5)/6 )* log(det(R)) where n is the number of observations, p is the number of variables, and R is the correlation matrix. The chi square test is then performed on (p^2-p)/2 degrees of freedom. So you can compute it by hand. Or you can use

Re: [R] Do a corelational analysis in R

2011-06-16 Thread Daniel Malter
I am not sure what you actually want to accomplish. If you try to correlate numeric/rank data with text data, I have no clue how that could be achieved (other than with text length, or presence/absence of a comment). If you try to figure out how you prevent the cor() function to fail when it

Re: [R] Problems with nls

2011-06-16 Thread Daniel Malter
:234 Gabor Grothendieck wrote: On Wed, Jun 15, 2011 at 6:05 PM, Daniel Malter lt;dan...@umd.edugt; wrote: There may be two issues here. The first might be that, if I understand the Bass model correctly, the formula you are trying to estimate is the adoption in a given time period. What you

Re: [R] Standard deviation and Mean

2011-06-15 Thread Daniel Malter
in nabble, either private msg or for everyone to see, but not both. Da. Uwe Ligges-3 wrote: On 14.06.2011 22:29, Daniel Malter wrote: Hi, pick up any introductory manual of which there are many online. It so happens that the functions for mean and sd are called mean() and sd(). If you want

Re: [R] BIZARRE results from wilcox.test()

2011-06-15 Thread Daniel Malter
I did not intend to bully you but rather tried to speak narrowly to the core of the issue. In a sense the point was that the example you used to illustrate the problem created part of the problem and that in a sensical dataset you would not obtain nonsensical results. Secondly, my reply talked to

Re: [R] Correlations by subgroups

2011-06-15 Thread Daniel Malter
x-c(1,1,1,1,1,2,2,2,2,2) y-rnorm(10) z-y+rnorm(10) by(data.frame(y,z),factor(x),cor) hth, Daniel jfdawson wrote: I'm hoping there is a simple answer to this - it seems that there should be, but I can't figure it out. I have a matrix/data frame with three variables of interest - V1, V2,

Re: [R] R string functions

2011-06-15 Thread Daniel Malter
x-'GTTACTGGTACC' table(strsplit(x,'')) hth, Daniel karena wrote: Hi, I have a string GGCCCAATCGCAATTCCAATT What I want to do is to count the percentage of each letter in the string, what string functions can I use to count the number of each letter appearing in the string?

Re: [R] Problems with nls

2011-06-15 Thread Daniel Malter
There may be two issues here. The first might be that, if I understand the Bass model correctly, the formula you are trying to estimate is the adoption in a given time period. What you supply as data, however, is the cumulative adoption by that time period. The second issue might be that the

Re: [R] Standard deviation and Mean

2011-06-14 Thread Daniel Malter
Hi, pick up any introductory manual of which there are many online. It so happens that the functions for mean and sd are called mean() and sd(). If you want to know how to use them type ?mean or ?sd in the R-prompt and hit enter. Daniel -- View this message in context:

Re: [R] color specific(!) lines in different color with in parcoord plots

2011-06-14 Thread Daniel Malter
Hi, Why does the second example on ?parcoord help page not help you with that? ?parcoord ir - rbind(iris3[,,1], iris3[,,2], iris3[,,3]) parcoord(log(ir)[, c(3, 4, 2, 1)], col = 1 + (0:149)%/%50) If that does not do, feel free to get back. Daniel -- View this message in context:

Re: [R] BIZARRE results from wilcox.test()

2011-06-14 Thread Daniel Malter
I would argue that your Wilcoxon test is meaningless. For all four datasets, the first data column has no overlap whatsoever with the second data column. All Wilcoxon Ws are 0. The BIZARRE behavior may be that the test tries to interpolate what the p value for W of 0 would be given your sample

Re: [R] how to convert careers to social network description

2011-06-14 Thread Daniel Malter
Where are you stuck? A question without reproducible code or demonstrating own effort is much less likely to receive a response. Best, Daniel -- View this message in context: http://r.789695.n4.nabble.com/how-to-convert-careers-to-social-network-description-tp3597622p3598067.html Sent from the

Re: [R] Linear multivariate regression with Robust error

2011-06-10 Thread Daniel Malter
I am with Michael. It is almost impossible to figure out what you are trying. However, I assume, like Michael, that you regress y on x2 and find, say, a negative effect. But when you regress y on x1 and x2, then you find a positive effect of x2. The short answer to your question is that in this

Re: [R] Latent class analysis, selection of the number of classes

2011-05-26 Thread Daniel Malter
Thanks everybody. -- View this message in context: http://r.789695.n4.nabble.com/Latent-class-analysis-selection-of-the-number-of-classes-tp3545538p3554357.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing

[R] Latent class analysis, selection of the number of classes

2011-05-23 Thread Daniel Malter
Hi, I perform latent class analysis on a matrix of dichotomous variables to create an indicator of class/category membership for each observation. I would like to know whether there is a function that selects the best fit in terms of number of classes/categories. Currently, I am doing this with

Re: [R] Email out of R (code)

2011-05-19 Thread Daniel Malter
As I (thought I) understood from the sendmailR manual, the package does currently not support server authentication, or does it? Daniel -- View this message in context: http://r.789695.n4.nabble.com/Email-out-of-R-code-tp3530671p3536512.html Sent from the R help mailing list archive at

Re: [R] lmer with 2 random effects with only two levels

2011-05-19 Thread Daniel Malter
What you should and can do depends on the expectations you have regarding the correlation structure of the data and is limited by your degrees of freedom. For example, what is wrong about: reg-lmer(response~femaleset+treatment+(1|group)) ? This assumes that there are constant group effects on

Re: [R] Email out of R (code)

2011-05-18 Thread Daniel Malter
I do not know. I was not aware and could hardly find any information on create.post(). From what I have seen at first glance, it seems that create.post() either opens your standard email program or web browser, which the python code does not. Instead it needs the R-library interfacing Python. I

[R] Email out of R (code)

2011-05-17 Thread Daniel Malter
Hi all, I thought I would post code to send an email out of R. The code uses Grothendieck and Bellosta's interface package rJython for executing Python from R. The code itself provides basic email functionality for email servers requiring authentication. It should be easy to extend it (e.g., for

Re: [R] Help with basic loop

2011-04-10 Thread Daniel Malter
The loop is correct, you just need to make sure that your result is computed and stored as the n-th element that is returned by the loop. Pick up any manual of R, and looping will be explained there. Also, I would recommend that you draw a random number for every iteration of the loop. Defining

Re: [R] Avoiding a loop

2011-04-08 Thread Daniel Malter
Hi, this response uses the previous responses with an example: #Assume you have 100 observations n=100 #Simulate a time series of prices error=rnorm(n,0,3) raw.price=rpois(n,100) lag.price=c(rpois(1,100),raw.price[1:99]) price=lag.price+error #Say you want the moving average based on this #and

Re: [R] random sampling with levels and with replacement

2011-04-08 Thread Daniel Malter
If you want perfect equality, split the data in good and bad and sample from the two samples individually. On average, however, random sampling from the entire data will reproduce the proportion of good and bad in the data. hth, Daniel -- View this message in context:

[R] Precision of summary() when summarizing variables in a data frame

2011-04-05 Thread Daniel Malter
Hi, I summary() a variable with 409908 numeric observations. The variable is part of a data.frame. The problem is that the min and max returned by summary() do not equal the ones returned by min() and max(). Does anybody know why that is? min(data$vc) [1] 15452 max(data$vc) [1] 316148

Re: [R] Precision of summary() when summarizing variables in a data frame

2011-04-05 Thread Daniel Malter
Thanks all. No I wasn't aware of the fact that summary is rounding in this case. Da. -- View this message in context: http://r.789695.n4.nabble.com/Precision-of-summary-when-summarizing-variables-in-a-data-frame-tp3428570p3429022.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Plotting MDS (multidimensional scaling)

2011-04-03 Thread Daniel Malter
The header metric mds was actually a leftover because I initially used cmdscale and did not bother changing it for the example. Thanks, Daniel -- View this message in context: http://r.789695.n4.nabble.com/Plotting-MDS-multidimensional-scaling-tp3422670p3424135.html Sent from the R help mailing

[R] Avoiding loops in creating a coinvestment matrix

2011-04-03 Thread Daniel Malter
Hi, I am working on a dataset in which a number of venture capitalists invest in a number of firms. What I am creating is an asymmetric matrix M in which m(ij) is the volume (sum) of coinvestments of VC i with VC j (i.e., how much has VC i invested in companies that VC j also has investments in).

[R] Plotting MDS (multidimensional scaling)

2011-04-02 Thread Daniel Malter
Hi, I just encountered what I thought was strange behavior in MDS. However, it turned out that the mistake was mine. The lesson learned from my mistake is that one should plot on a square pane when plotting results of an MDS. Not doing so can be very misleading. Follow the example of an

Re: [R] I think I just broke R

2011-04-02 Thread Daniel Malter
Check whether x, y, or glm have been redefined. If not, restart R. D. -- View this message in context: http://r.789695.n4.nabble.com/I-think-I-just-broke-R-tp3422737p3422932.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Discretizing data rows into regular intervals

2011-04-02 Thread Daniel Malter
The ?cut function should work for that. Have you tried? D. -- View this message in context: http://r.789695.n4.nabble.com/Discretizing-data-rows-into-regular-intervals-tp3422921p3422933.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Discretizing data rows into regular intervals

2011-04-02 Thread Daniel Malter
Sorry, I did not get the question because I read it too sloppily. I hope this is not homework. You can proceed along this example: set.seed(32345) #Value of observation value=rpois(60,100) #Day of observation day=sample(1:1080,50,replace=F) day=sort(day) #Assume 3 years #Assume months have all

Re: [R] Counting things in a time series.

2010-11-21 Thread Daniel Malter
Hi, these are pretty basic questions. You might want to pick up an introductory manual. Lets assume you have a time stamp that already indicates the hours. Assume you have 300 observations, each of which falls in one of 24 hours of observation. You easily get the number of obs in each hour with

Re: [R] lme4 + R 2.11.0 + mac unavailable

2010-08-24 Thread Daniel Malter
Hi, has there been a solution to this issue? I am encountering the same problem on a Mac with OSX 10.6.4. The problem persists when I try to install lme4 from the source (see below), and my R version is up to date according to R's update check. Thanks for any help, Daniel --

[R] grep with search terms defined by a variable

2010-08-02 Thread Daniel Malter
Hi, I have a good grasp of grep() and gsub() for finding and extracting character strings. However, I cannot figure out how to use a search term that is stored in a variable when the search string is more complex. #Say I have a string, and want to know whether the last name Jannings is in the

Re: [R] grep with search terms defined by a variable

2010-08-02 Thread Daniel Malter
A beauty. Works a charm. Many many thanks. Daniel -- View this message in context: http://r.789695.n4.nabble.com/grep-with-search-terms-defined-by-a-variable-tp2311294p2311307.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] sampling one random frame from each unique trial?

2010-06-27 Thread Daniel Malter
Hi, take the following example and proceed accordingly. Name=c(Miller,Miller,Miller,Miller,Smith,Smith,Smith,Smith) X=rnorm(8) Year=rep(2000:2003,2) d=data.frame(Name,X,Year) #Row indices rows=1:dim(d)[1] #Which Name occupies which rows? #Name would be your file

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-26 Thread Daniel Malter
Atte, note the similarity between what Greg described and a bootstrap. The difference to a true bootstrap is that in Greg's version you subsample the population (or in other instances the data). This is known as subsampling bootstrap and discussed in Politis, Romano, and Wolf (1999). HTH, Daniel

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-25 Thread Daniel Malter
Atte, I would not wonder if you got lost and confused by the certainly interesting methodological discussion that has been going on in this thread. Since the helpers do not seem to converge/agree, I propose to you to use a different nonparametric approach: The bootstrap. The important thing

Re: [R] help in pael data analysis

2010-06-22 Thread Daniel Malter
Hi, the way it is asked you are not likely to receive an answer to your question. The reasons are: 1. Your question is way to unspecific. What kind of panel data analysis? How should we know? A package for linear panel data models and packages for random (mixed) effects models are implemented

Re: [R] Spatial: number of independent components?

2010-06-21 Thread Daniel Malter
as.spam.listw is an unknown function. Is it in a different package? Daniel other attached packages: [1] spdep_0.5-11coda_0.13-5 deldir_0.0-12 maptools_0.7-34 foreign_0.8-38 nlme_3.1-96 MASS_7.3-3 [8] Matrix_0.999375-31 lattice_0.17-26

Re: [R] Spatial: number of independent components?

2010-06-21 Thread Daniel Malter
I was missing the spam library. I did some testing with m x m matrices (see below). Computing 'a' is the villain. The computation time for 'a' is exponential in m. For a 100 by 100 matrix, the predicted time is about 20 seconds. Thus, 100,000 runs, would take about 23 days. library(igraph)

Re: [R] rbind with different columns

2010-06-21 Thread Daniel Malter
Works wonderfully. I am very happy that I eventually found this post :) Daniel. -- View this message in context: http://r.789695.n4.nabble.com/rbind-with-different-columns-tp907370p2263588.html Sent from the R help mailing list archive at Nabble.com.

[R] Spatial: number of independent components?

2010-06-20 Thread Daniel Malter
Hi all, I am sorry if this is a very basic quesion, but I have no experience with analyzing spatial data and could not find the right function/package quickly. Any hints would be much appreciated. I have a matrix of spatial point patterns like the one below and want to find the number of

Re: [R] Spatial: number of independent components?

2010-06-20 Thread Daniel Malter
Hi, thanks much. This works in principle. The corrected code is below: a - nb2mat(cell2nb(nrow(x),ncol(x),torus=T), style=B) g - delete.vertices(graph.adjacency(a), which(x!=1)-1) plot(g) clusters(g) the $no argument of the clusters(g) function is the sought after number. However, the function

Re: [R] summary stats on continuous data

2010-06-15 Thread Daniel Malter
Hi, you should be able to do most of your summaries using tapply() or aggregate(). for your example, tapply(d$Acc,list(d$Sample),table) Here tapply takes Acc, splits it by Sample, and then tables Acc (which returns how many 0s/1s were observed in variable Acc for each stratum of Sample).

Re: [R] Calculation of r squared from a linear regression

2010-06-15 Thread Daniel Malter
Hi, as pointed out previously, the problem is in using the canned routine (lm) without including an intercept term. Here is a working, generic example with commented code. #Simulate data x=rnorm(100) e=rnorm(100) y=x+e #Create X matrix with intercept X=cbind(1,x) #Projection matrix

Re: [R] summary stats on continuous data

2010-06-15 Thread Daniel Malter
You can define a function that does just that: sum the 1s in Acc and divide by the length of Acc. Then use tapply to apply the function for each subject. f=function(x){sum(as.numeric(as.character(x)))/length(x)} tapply(d$Acc,list(d$S),f) HTH, Daniel -- View this message in context:

Re: [R] Very OT: World Cup Statistics

2010-06-07 Thread Daniel Malter
these websites seem to have the data. though I have not checked for completeness. the rsssf in particular is seems to be concerned with collecting and archiving these kinds of football data: http://www.rsssf.com/tablesw/worldcup.html http://wapedia.mobi/en/1930_FIFA_World_Cup_Group_1 hope that

Re: [R] Generating all possible models from full model

2010-05-19 Thread Daniel Malter
Hi, one approach is document below. The function should work with any regression function that follows the syntax of lm (others will need adjustments). Note that you would have to create the interactions terms by hand (which is no big deal if there are just few). Note also that this approach can

Re: [R] How to draw a graphic using data with coordinates and production rate?

2010-05-14 Thread Daniel Malter
Oh, if plot does the thing, then you just want to specify the color argument accordingly, where the color argument is given by your production figure. x=seq(1:100) y=seq(1:100) x.coord=sample(x,100) y.coord=sample(y,100) production=sample(1:100, 100) plot(y.coord~x.coord) #now lets say we

Re: [R] Split data frame by conditional and column at the same time

2010-05-13 Thread Daniel Malter
Does anything speak against selecting only x where x$B20 and then splitting it by x$C? split(x[!x$B20,],x$C) HTH, Daniel -- View this message in context: http://r.789695.n4.nabble.com/Split-data-frame-by-conditional-and-column-at-the-same-time-tp2197908p2216072.html Sent from the R help

Re: [R] More complex historgram

2010-05-13 Thread Daniel Malter
Are you asking us to do your homework? This is not a homework list. For the t-test look in any introductory R manual. For the histograms, look in the lattice library. HTH Daniel -- View this message in context: http://r.789695.n4.nabble.com/More-complex-historgram-tp2197823p2216076.html Sent

Re: [R] How to draw a graphic using data with coordinates and production rate?

2010-05-13 Thread Daniel Malter
Hi, assuming your production figures are in a square matrix, where points with no production take zero and points with production take the production figure, you could use image() This is the most basic approach I would think. Daniel -- View this message in context:

Re: [R] function

2010-05-12 Thread Daniel Malter
There is too little information to answer your question definitively. However, an obvious reason is that you want to apply the function over columns of a data.frame, which is done with apply(), but you try to apply the function over elements of a list using lapply(). A list is not a data.frame

Re: [R] what the problem could be if i am suddenly unable to add abline to the scatter plot?

2010-05-12 Thread Daniel Malter
Xin, you plot the scatterplot wrongly. Note that the lm (your OLS regression) has a wiggle, whereas you plot command has a comma. The plot command also should have a wiggle so that you plot y against x and not x against y. See example below: x=rnorm(100);e=rnorm(100) y=2*x+e reg=lm(y~x)

Re: [R] what the problem could be if i am suddenly unable to add abline to the scatter plot?

2010-05-12 Thread Daniel Malter
Just a quick addendum: You actually plot the line. If it is not in the graph then just because it is outside the limits of the plotting region. But since it's the right line on the wrong plot, it does not matter anyway. You need to get the plot right first, which you do in the way I described

Re: [R] function

2010-05-12 Thread Daniel Malter
Fair enough, my mistake. However, I am quite fascinated how that focuses everybody else on picking on the intitial answer and diverts everybody away from anwering the actual question. All the more it points to the second paragraph of my reply, namely that all modular components of the function

Re: [R] Panel data with binary dependent variable

2010-05-11 Thread Daniel Malter
RE models are available in the lme4 and MASS packages in the glmer and glmmPQL functions, respectively. -- View this message in context: http://r.789695.n4.nabble.com/Panel-data-with-binary-dependent-variable-tp2156043p2184223.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Regressions with fixed-effect in R

2010-05-11 Thread Daniel Malter
if the plm function only puts out one r-squared, it should be the within r-squared, but I could be wrong. Stata, for example, gives you a within, a between, and an overall r-squared. Here is what they do. set.seed(1) x=rnorm(100) fe=rep(rnorm(10),each=10) id=rep(1:10,each=10) ti=rep(1:10,10)

Re: [R] Regressions with fixed-effect in R

2010-05-10 Thread Daniel Malter
There is the plm package for linear panel models. Further, since estimation of fixed effects models rests on the within-subject or -object variance, the R-squared of interest is typically the within R-squared, not the overall or between R-squared. Read up about it before you use it though.

Re: [R] Advice needed on awkward tables

2010-05-10 Thread Daniel Malter
Hi, even after rereading, I have little of a clue what it is exactly that you are trying to do. It'd help if you provided a more concise, step-by-step description and/or the smallest unambiguous example of the two tables AND of what should come out at the end. Also, unless for relatively trivial

Re: [R] multiple correlation coefficient R

2010-05-04 Thread Daniel Malter
Hi, type ?cor and hit ENTER. More generally, since you seem to be a newbie to R, I would suggest that you pick-up one of the many manuals to R that are available online and that you make yourself familiar with the posting guide for this list. Best, Daniel - cuncta

Re: [R] advice?

2010-05-03 Thread Daniel Malter
Hi, on the one hand, you write fairly large, on the other hand, you write should be readable by anything. The warnings indicate that you are plain out of memory at some point. Not too surprising, given that your dataset has about 45 rows and 720 columns. You may search the r-help files first

Re: [R] multiple paired t-tests without loops

2010-04-28 Thread Daniel Malter
Hi Matt, see the example below. It took me a while to figure it out. I suggest you carefully examine the example step by step. It computes t-values for dataset with 3 variables and 8 unique combinations of two binning variables. The code should extend easily to larger datasets. Also, it uses the

Re: [R] how to select the first observation only?

2010-04-21 Thread Daniel Malter
Gallon, your question looks very homeworky. People on this list are not likely to help you unless you can demonstrate own effort (even if it failed), and the list is not for homework questions in case it is one. Where exactly are you stuck? Daniel - cuncta stricte

Re: [R] Help: coxph() in {survival} package

2010-04-19 Thread Daniel Malter
Hi Xin, to answer your question: say you have your regression reg = coxph(... Then you can assess the log likelihood by reg$loglik This vector contains typically two values, the null log likelihood of the restricted model that excludes the fixed effects and the log likelihood of the

Re: [R] plotting pca of samples in different colors

2010-04-18 Thread Daniel Malter
Amit, how to color or label your pca plot has been answered before. Look at this post: http://n4.nabble.com/PCA-analysis-td861508.html#a861509 As for your problem, it's hard to say what went wrong without having the data. You write, there is nothing plotted in the graph. Does that mean you get a

Re: [R] histogram breaks

2010-04-16 Thread Daniel Malter
?hist shows you the options - cuncta stricte discussurus - -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of casperyc Sent: Friday, April 16, 2010 3:56 PM To: r-help@r-project.org

Re: [R] Regression using R

2010-04-15 Thread Daniel Malter
I think this requires you to just pick up a manual / introductory book on R/regression in R, of which there are many on the internet / in the bookstores, respectively. Every manual I have seen has at least examples for quadratics. And extensions to other functional forms are straightforward.

Re: [R] Problem using elements in a vector

2010-04-08 Thread Daniel Malter
This reads like homework. You should show some evidence where you are stuck or pick up an R book/manual/introduction after which you should be able to do this yourself quite easily. Daniel - cuncta stricte discussurus - -

Re: [R] finding weekly average...

2010-04-07 Thread Daniel Malter
Assume you have suitable week indicator and your data is stored in a data.frame named data. Then you get the weekly averages by #simulate data week - rep(1:52,each=7) x - week+rnorm(52*7,) y - rev(week)+rnorm(52*7) #create data frame data=data.frame(week,x,y) #get weekly averages in a list

Re: [R] Quartering a plot() ?

2010-04-06 Thread Daniel Malter
Hi, nothing customized is effortless. It typically requires a bit of coding unless you are lucky and somebody has implemented it in some package (you just have to find the package). But it's not that difficult to do it yourself. It just requires figuring out where the lines should be placed,

Re: [R] Matrix elements are vectors

2010-04-05 Thread Daniel Malter
I may be mistaken, but I don't think that's possible or even should be possible. A matrix is m x n, where m and n are (kind of fixed) integers. You cannot have a matrix where m(1) to m(n) (the row lengths) vary. If you want to do this, you have to use a list instead (I believe). As a poor

Re: [R] Coding of categorical variables for logistic regression?

2010-03-29 Thread Daniel Malter
This is about the covariates, not the dependent variable. So a polynomial logistic regression seems hardly appropriate. David is right with his latest statement, just because they are ordered does not assure that the effect is monotonic. If the low, medium, and high groups had even spacing

Re: [R] How to select a row from one dataframe that is close to a row in another dataframe

2010-03-20 Thread Daniel Malter
If the flight identifiers runway$Flight and oooi$Flight are unique (i.e. only one observation has the same identifier in each dataset), you could use merge() to bind together the dataset based on matching the two. See, ?merge Also, I see an OnDate variable in both dataset. So if Flight does not

<    1   2   3   4   5   >