[R] Using subset to filter data table

2011-01-18 Thread Ben Harrison
I am having difficulty understanding how I would constrain a data set by filtering out 'records' based on certain criteria. Using SQL I could query using 'select * from my.data where LithClass in ('sand', 'clay')' or some such. Using subset, there seem to be ghosts left behind (that is, all of the

Re: [R] lme-post hoc

2011-01-18 Thread Dieter Menne
plsc wrote: > > > I analysed my data with lme and after that I spent a lot of time for > mean separation of treatments (post hoc). But still I couldn’t make > through it. This is my data set and R scripts I tried. > > > > 3 level3 var4361261 > > modela<-lme(height~varie

Re: [R] lme-post hoc

2011-01-18 Thread Dieter Menne
plsc wrote: > > > I analysed my data with lme and after that I spent a lot of time for > mean separation of treatments (post hoc). But still I couldn’t make > through it. This is my data set and R scripts I tried. > > > > 3 level3 var4361261 > > modela<-lme(height~varie

Re: [R] lme-post hoc

2011-01-18 Thread Dieter Menne
-- View this message in context: http://r.789695.n4.nabble.com/lme-post-hoc-tp3224436p3224652.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do re

Re: [R] Printing "pretty' vectors in Sweave

2011-01-18 Thread Joshua Wiley
Hi Robin, Have you looked at the 'collapse' argument to paste? something like: myvec <- paste(1:4, collapse = ", ") Might do what you want. Also maybe ?bquote or the like to get rid of quotes possibly (I'm not in a position to try presently). Side note, it is really probably best not to use '

[R] Printing "pretty' vectors in Sweave

2011-01-18 Thread Robin Jeffries
I am trying to print a nice looking vector in Sweave. c <- 1:4 I want to see (1, 2, 3, 4) in TeX. . If I use paste(c, ",", sep="") I get "1," "2," "3," "4," If use cat(c, sep=",") I can't seem to assign it to an object, 1,2,3,4> myvec <- cat(c, sep=",") 1,2,3,4> myvec NULL and if I bypass the

[R] Fwd: question about result of loglinear analysis

2011-01-18 Thread Lao Meng
-- Forwarded message -- From: Lao Meng Date: 2011/1/19 Subject: Re: [R] question about result of loglinear analysis To: David Winsemius My command and result are : > result_sat<-summary(glm_sat) > result_coe<-result_sat$coefficients > result_coe Estimate St

Re: [R] Pearson correlation with randomization

2011-01-18 Thread David Winsemius
On Jan 18, 2011, at 11:23 PM, Brahmachary, Manisha wrote: Hello, I will be very obliged if someone can help me with this statistical R problem: I am trying to do a Pearson correlation on my datasets X, Y with randomization test. My X and Y datasets are pairs. 1. I want to randomize (re

[R] Pearson correlation with randomization

2011-01-18 Thread Brahmachary, Manisha
Hello, I will be very obliged if someone can help me with this statistical R problem: I am trying to do a Pearson correlation on my datasets X, Y with randomization test. My X and Y datasets are pairs. 1. I want to randomize (rearrange) only my X dataset per row ,while keeping the my Y da

Re: [R] Reshape

2011-01-18 Thread jim holtman
This gets you close; just edit the row names: > x <- read.table(textConnection("X1,Y1,hr1,hr2,hr3 + X1,Y2,hr1,hr2,hr3 + X1,Y3,hr1,hr2,hr3 + X2,Y1,hr1,hr2,hr3 + X2,Y2,hr1,hr2,hr3 + X2,Y3,hr1,hr2,hr3"), sep = ',', as.is = TRUE) > closeAllConnections() > require(reshape2) > x.m <- melt(x, id = c('V1'

Re: [R] Semi-Regular Time Series with Missing Values

2011-01-18 Thread Gabor Grothendieck
On Tue, Jan 18, 2011 at 6:33 PM, Adam Oliner wrote: > Hi, > > I'm trying to make a ts object that has both NA values and a frequency other > than 1 (so I can use stl). I've tried all permutations I can think of, but > cannot get the desired (expected?) results. > > The values live in x and the cor

Re: [R] Log difference in a dataframe column

2011-01-18 Thread Bill.Venables
lag and as.ts are separate operations (which in fact commute) > lag(as.ts(1:10), 1) Time Series: Start = 0 End = 9 Frequency = 1 [1] 1 2 3 4 5 6 7 8 9 10 > as.ts(lag(1:10, 1)) Time Series: Start = 0 End = 9 Frequency = 1 [1] 1 2 3 4 5 6 7 8 9 10 > You do NOT need to ca

[R] Reshape

2011-01-18 Thread pwilliam
Hi - I'm up against a complicated reshape problem. I have data of the form X1,Y1,hr1,hr2,hr3 X1,Y2,hr1,hr2,hr3 X1,Y3,hr1,hr2,hr3 X2,Y1,hr1,hr2,hr3 X2,Y2,hr1,hr2,hr3 X2,Y3,hr1,hr2,hr3 where X and Y are factors and the hr(1,2,3) are values. I need it as ,X1, X2 Y1,hr1,hr1 Y1,hr2,hr2 Y1,hr3,h

Re: [R] Log difference in a dataframe column

2011-01-18 Thread eric
Just learning so excuse me if I'm being too basic here. But I'm wondering how should I know that as.ts would be needed for lag ? Is there a thought process or way to inspect that I should have gone through to know that log would work on y[,5] but lag would not work on [,5] ? Is the general rule

Re: [R] Parameters/data that live globally

2011-01-18 Thread Charles C. Berry
On Tue, 18 Jan 2011, analys...@hotmail.com wrote: I am coming to R from Fortran and I used to use fixed size arrays in named common. common /name1/array(100) The contents of array can be accessed/modified if and only if this line occurs in the function. Very helpful if different functions need

[R] lme-post hoc

2011-01-18 Thread Prabhath Pushpakumara
Hi all, I analysed my data with lme and after that I spent a lot of time for mean separation of treatments (post hoc). But still I couldn’t make through it. This is my data set and R scripts I tried. replication fertilizer variety plotheight 1 level1 var1150452 1

Re: [R] tips for looping over a category for beginner

2011-01-18 Thread David Winsemius
On Jan 18, 2011, at 7:32 PM, Ben Harrison wrote: On 18 January 2011 22:52, Peter Ehlers wrote: Since you don't provide data, let's borrow from the help(droplevels) page: As an aside, is it normal practice then to attach data files to questions on this mailing list? I might do that in f

[R] Semi-Regular Time Series with Missing Values

2011-01-18 Thread Adam Oliner
Hi, I'm trying to make a ts object that has both NA values and a frequency other than 1 (so I can use stl). I've tried all permutations I can think of, but cannot get the desired (expected?) results. The values live in x and the corresponding semi-regular time stamps are in t: > library('zoo') >

Re: [R] error message

2011-01-18 Thread David Winsemius
On Jan 18, 2011, at 6:09 PM, wangwallace wrote: Peter, I found it. There is a missing value under column SubID. I filled it out with an ID number, and the error message never occur again. Although I found the problem, I have no idea why would this be associated with such an error messa

Re: [R] Time and xts

2011-01-18 Thread Hugo Mildenberger
Nicos, there are certainly better / faster methods to compare a time range which I simply don't know of, but the condensed code below should do it. Your main problem was that you can't compare time(x) to 7:55, since the latter expression denotes a sequence from 7 to 55 in R. Consequently, such

Re: [R] tips for looping over a category for beginner

2011-01-18 Thread Ben Harrison
On 18 January 2011 22:52, Peter Ehlers wrote: > Since you don't provide data, let's borrow from the > help(droplevels) page: > As an aside, is it normal practice then to attach data files to questions on this mailing list? I might do that in future if it's possible and acceptable. Ben.

Re: [R] tips for looping over a category for beginner

2011-01-18 Thread Ben Harrison
Dennis, thank you for the response! Sorry for lack of clarity, I'll explain a little more below... > plot(Depth[LithClass=='sand'], Conductivity[LithClass=='sand']) >> (ad nauseum... how can I loop through them all?) >> > I have several lithology classes - sand, clay, limestone, etc... I wish to p

Re: [R] error message

2011-01-18 Thread wangwallace
Peter, I found it. There is a missing value under column SubID. I filled it out with an ID number, and the error message never occur again. Although I found the problem, I have no idea why would this be associated with such an error message. If anybody else have some input, I would really appreci

[R] Parameters/data that live globally

2011-01-18 Thread analys...@hotmail.com
I am coming to R from Fortran and I used to use fixed size arrays in named common. common /name1/array(100) The contents of array can be accessed/modified if and only if this line occurs in the function. Very helpful if different functions need different global data (can have name2, name3 etc. fo

Re: [R] tips for looping over a category for beginner

2011-01-18 Thread Ben Harrison
Thanks for the reply Peter. On 18 January 2011 22:52, Peter Ehlers wrote: > Since you don't provide data, let's borrow from the > help(droplevels) page: > I had no joy with my R install finding droplevels exactly, but found this instead: > ??droplevels gdata::drop.levels Drop unused factor

Re: [R] question about result of loglinear analysis

2011-01-18 Thread David Winsemius
On Jan 18, 2011, at 8:45 PM, Lao Meng wrote: Hi all: Here's a question about result of loglinear analysis. There're 2 factors:area and nation.The raw data is in the attachment. I fit the saturated model of loglinear with the command: glm_sat<-glm(fre~area*nation, family=poisson, data=data_Anal

[R] question about result of loglinear analysis

2011-01-18 Thread Lao Meng
Hi all: Here's a question about result of loglinear analysis. There're 2 factors:area and nation.The raw data is in the attachment. I fit the saturated model of loglinear with the command: glm_sat<-glm(fre~area*nation, family=poisson, data=data_Analysis) After that,I extract the coefficients: res

Re: [R] dataframe: string operations on columns

2011-01-18 Thread Waclaw Kusnierczyk
On 01/18/2011 07:05 PM, Henrique Dallazuanna wrote: > Or: > > read.table(textConnection(as.matrix(df)), sep = " ") no, that's too simple: you can't use regular expressions. (well, i guess it's enough for the original problem.) vQ > > > On Tue, Jan 18, 2011 at 11:02 PM, Waclaw Kusnierczyk

Re: [R] dataframe: string operations on columns

2011-01-18 Thread Henrique Dallazuanna
Or: read.table(textConnection(as.matrix(df)), sep = " ") On Tue, Jan 18, 2011 at 11:02 PM, Waclaw Kusnierczyk wrote: > Assuming every row is split into exactly two values by whatever string you > choose as split, one fancy exercise in R data structures is > >dfsplit = function(df, split) >

Re: [R] dataframe: string operations on columns

2011-01-18 Thread Waclaw Kusnierczyk
Assuming every row is split into exactly two values by whatever string you choose as split, one fancy exercise in R data structures is dfsplit = function(df, split) as.data.frame( t( structure(dim=c(2, nrow(df)), unlist(

Re: [R] dataframe: string operations on columns

2011-01-18 Thread Niels Richard Hansen
On 2011-01-18 08:14, Ivan Calandra wrote: Hi, I guess it's not the nicest way to do it, but it should work for you: #create some sample data df<- data.frame(a=c("A B", "C D", "A C", "A D", "B D"), stringsAsFactors=FALSE) #split the column by space df_split<- strsplit(df$a, split=" ") #place th

Re: [R] $ operator is invalid for atomic vectors

2011-01-18 Thread Pete Brecknock
Amy It would have been helpful if you had sent your R code of how you constructed the sab object. If you have a data.frame, the subset command you are having trouble with should work fine. See below. # Working Example sab = data.frame(group=c('Group A', 'Group A', 'Group C', 'Group B', 'Group

Re: [R] dataframe: string operations on columns

2011-01-18 Thread Peter Ehlers
On 2011-01-18 08:14, Ivan Calandra wrote: Hi, I guess it's not the nicest way to do it, but it should work for you: #create some sample data df<- data.frame(a=c("A B", "C D", "A C", "A D", "B D"), stringsAsFactors=FALSE) #split the column by space df_split<- strsplit(df$a, split=" ") #place th

Re: [R] count id by id

2011-01-18 Thread David Winsemius
On Jan 18, 2011, at 5:03 PM, Denis Kazakiewicz wrote: Hi Trying to work out that: Each person can take from 1 to 9 drugs. And data frame looks like id drug 1 d 2 g 2 d 2 r 3 e 3 a ... Q: How many drugs one person takes on average? Somethin

Re: [R] substituting level for NA in factor column

2011-01-18 Thread David Winsemius
On Jan 18, 2011, at 5:25 PM, kurt_h...@nps.gov wrote: Greetings I have a bunch of NAs in a column of categorical variables designating the size classes (e.g., smallest to largest: 1,2,3,4) of cave crickets. I'd like to substitute "U" (for unknown) for the NAs. Can anyone give me an

Re: [R] error message

2011-01-18 Thread Peter Ehlers
On 2011-01-18 13:06, wangwallace wrote: I tried it several times. it still gives me the same error. I also used traceback() here is what I got: traceback() 3: `[.data.frame`(df, -s1$SubID, ) 2: df[-s1$SubID, ] 1: crossed1(agr) But I don't think there is anything wrong with it.. I thi

Re: [R] count id by id

2011-01-18 Thread Bert Gunter
Homework exercise ?? -- Bert On Tue, Jan 18, 2011 at 2:03 PM, Denis Kazakiewicz wrote: > > Hi > > Trying to work out that: > Each person can take from 1 to 9 drugs. And data frame looks like > > > id      drug > 1       d > 2       g > 2       d > 2       r > 3       e > 3       a > ...

Re: [R] substituting level for NA in factor column

2011-01-18 Thread Bert Gunter
Well, (have you read "An Intro to R," which I think might have enabled you to figure this out for yourself?) Convert the factor to character, use is.na() to substitute, convert back to factor. e.g. > z <- factor (c(1,2,3,NA)) > z<- as.character(z) > z[is.na(z)] <- "U" > factor(z) [1] 1 2 3 U

[R] substituting level for NA in factor column

2011-01-18 Thread Kurt_Helf
Greetings I have a bunch of NAs in a column of categorical variables designating the size classes (e.g., smallest to largest: 1,2,3,4) of cave crickets. I'd like to substitute "U" (for unknown) for the NAs. Can anyone give me an idea how to do this? Thanks in advance. Cheers Kurt **

Re: [R] error message

2011-01-18 Thread wangwallace
I tried it several times. it still gives me the same error. I also used traceback() here is what I got: > traceback() 3: `[.data.frame`(df, -s1$SubID, ) 2: df[-s1$SubID, ] 1: crossed1(agr) But I don't think there is anything wrong with it.. -- View this message in context: http://r.78969

Re: [R] Time and xts

2011-01-18 Thread rnick
Hi all, Gabor came up with a very nice of code for my request: Lines <- "DateTimeOpenHighLow Close 1/2/200517:05 1.3546 1.3553 1.3546 1.35495 1/2/200517:10 1.3553 1.3556 1.3549 1.35525 1/2/200517:15 1.3556 1.35565 1.35515 1.3553 1/2/2005

Re: [R] Odp: Relative frequency on a character vector

2011-01-18 Thread ADias
I have done like this to get the result I need more directly A<-c("Tell me how many different letter this vector has?") prop.table(table(strsplit(A,""))) ?acdefhilmnors t 0.16 0.02 0.04 0.02 0.02 0.14 0.04 0.06 0.04 0.06 0.04 0.04 0

Re: [R] Odp: Relative frequency on a character vector

2011-01-18 Thread ADias
> BTW. There are help pages coming with R installation. Do you have them > corrupted? There is strsplit in see also section of nchar help page. > yes I do. But I have many dificulties in finding what I need. And on top of that R has a very specific way of working that is quite diferent from w

[R] count id by id

2011-01-18 Thread Denis Kazakiewicz
Hi Trying to work out that: Each person can take from 1 to 9 drugs. And data frame looks like id drug 1 d 2 g 2 d 2 r 3 e 3 a ... Q: How many drugs one person takes on average? Thank you __ R-help@r

Re: [R] Relative frequency on a character vector

2011-01-18 Thread Peter Ehlers
On 2011-01-18 04:51, ADias wrote: Hi, I have this character vector: A<-c("Tell me how many different letter this vector has?") Is there a way with R that it can let me know how many different letters I have on this vector? If I use nchar(A) que gives me the number 50. With this function he i

Re: [R] Baseline terms for lrm

2011-01-18 Thread David Winsemius
On Jan 18, 2011, at 2:51 PM, Rob James wrote: Dear R-help and Prof. Harrell: My question concerns the baseline state for continuous variable in lrm() within the RMS package. I have a model which can be reduced to: lrm(FT ~ rcs(V1, c(0, 1,5)) The model makes perfect sense if the baseline

Re: [R] Baseline terms for lrm

2011-01-18 Thread Rob James
I should rephrase my question. When using the notation rcs(V1, N) within the lrm function in the rms package, the associated model reports out N-1 values for the associated variable. Fine. The rcs-constructed temporary variables are denoted V1, V1', V1'' when one looks at the model output,

Re: [R] error message

2011-01-18 Thread Adrienne Wootten
It's not immediately evident to me just looking at this, but I do have one suggestion. Run this again and see if you get the same error and if you do, use this command to help you find where - traceback() traceback is extremely helpful when you are debugging these things, it will go through your

Re: [R] Statistical formulas

2011-01-18 Thread Sascha Vieweg
On 11-01-18 16:42, Toby Marthews wrote: Hi Ilya, If you're looking for general information about statistical tests, etc., you'll probably need to buy yourself a textbook. There are online pages (http://homes.msi.ucsb.edu/~byrnes/rtutorial.html is a good one), but a good textbook is probably b

Re: [R] Reorganizing Data Frame

2011-01-18 Thread Henrique Dallazuanna
Try this: xtabs(quantity ~ food + transaction, DF) On Tue, Jan 18, 2011 at 5:50 PM, chris99 wrote: > > Hi I need some help trying to restructure a data frame: > > I have: > foodtransaction quantity > pizza BUY 5 > pizza SELL 3 > apple BU

[R] Baseline terms for lrm

2011-01-18 Thread Rob James
Dear R-help and Prof. Harrell: My question concerns the baseline state for continuous variable in lrm() within the RMS package. I have a model which can be reduced to: lrm(FT ~ rcs(V1, c(0, 1,5)) The model makes perfect sense if the baseline state is where V1>=5 but the model makes no sense

[R] Reorganizing Data Frame

2011-01-18 Thread chris99
Hi I need some help trying to restructure a data frame: I have: foodtransaction quantity pizza BUY 5 pizza SELL 3 apple BUY 2 orange SELL 1 pizza BUY 2 And the data frame I want to ma

Re: [R] Truetype and Opentype font in pdf device

2011-01-18 Thread Kohske Takahashi
Thanks for the reply. I got that there is no general way to generate PDF with ttf or otf fonts. Thanks, it's enough. Also, cario_pdf is useful (I'm using OSX). But I found it cannot correctly(?) work with CJK. I will play with them some more. Thanks again. -- Kohske Takahashi Research Center

Re: [R] lm() portion of data

2011-01-18 Thread Duncan Murdoch
On 11-01-18 12:49 PM, Karen Aanensen wrote: Hello, I have a set of data for which I am making linear model. I would like to restrict this model for a subset of the data. I have 100 independent variables labeled x1-x100. I would like to only like an lm() that is only accounts for x1-x20. I ha

[R] help with read.table.ffdf parameters

2011-01-18 Thread Marck Vaisman
Hello fellow R users, I am trying to read a 6.9 million row text file with 26 columns separated by spaces into R using ff. When I specify a small number for first.rows, next.rows and nrows it is read with no issue. However, when I try to specify larger next.rows values and no nrows parameter to re

Re: [R] Truetype and Opentype font in pdf device

2011-01-18 Thread Prof Brian Ripley
On Wed, 19 Jan 2011, Kohske Takahashi wrote: Thanks for the reply. I got that there is no general way to generate PDF with ttf or otf fonts. Thanks, it's enough. Also, cario_pdf is useful (I'm using OSX). But I found it cannot correctly(?) work with CJK. The Mac OS X (why do Mac users not kn

[R] lm() portion of data

2011-01-18 Thread Karen Aanensen
Hello, I have a set of data for which I am making linear model. I would like to restrict this model for a subset of the data. I have 100 independent variables labeled x1-x100. I would like to only like an lm() that is only accounts for x1-x20. I have tried restricting my plot: plot(Date.Code,c

Re: [R] Statistical formulas

2011-01-18 Thread Mike Marchywka
> From: toby.marth...@ouce.ox.ac.uk > To: flya...@gmail.com; r-help@r-project.org > Date: Tue, 18 Jan 2011 16:42:51 + > Subject: Re: [R] Statistical formulas > > Hi Ilya, > If you're looking for general information about statistical tests, etc

Re: [R] matrix manipulations

2011-01-18 Thread Petr Savicky
On Mon, Jan 17, 2011 at 10:37:42PM +, Monica Pisica wrote: > > Hi, > > I've got 2 very good solutions, thank you very much. One, from Henrique > Dallazuanna using the library reshape and one line of code - although it will > take me quite some time to understand it. Here it is what he sent:

Re: [R] Retrieve "raw scores" in factor analysis

2011-01-18 Thread Roni Kobrosly
In case anyone is interested in this issue, I found a solution. The "psych" package has a function named "score.items" which will calculate raw scores. You need to know the survey item loadings and the raw responses to each item, but it will do it. See Grice's 2001 paper on factor scores for more i

[R] Barplot and line x-axis positions

2011-01-18 Thread Andy Aldersley
Hello all, Hoping that there is a fairly simple solution to my query... I'm trying to overlay a line plot of some data onto a barplot of different data. The y-axes are different for each set of data but the x-axes are the same (1:12, corresponding with 12 months of observations). The problem

Re: [R] Circular variables within a GLM, GLM-GEE or GAM

2011-01-18 Thread Simon Wood
Is the variable to be used as a predictor? If so mgcv::gam has a couple of circular smoother built in... s(x,bs="cc") or s(x,bs="cp") (if the range of x is less than the full [0, 360] then you can supply a `knots' argument to gam to force the x range to go from 0 to 360, otherwise s(min(x)

Re: [R] Statistical formulas

2011-01-18 Thread Toby Marthews
Hi Ilya, If you're looking for general information about statistical tests, etc., you'll probably need to buy yourself a textbook. There are online pages (http://homes.msi.ucsb.edu/~byrnes/rtutorial.html is a good one), but a good textbook is probably better. It's a bit old, but I still recommen

Re: [R] Statistical formulas

2011-01-18 Thread Daróczi Gergely
Hi, use the help files (e.g. ?wilcox.test) to see references. There you can see articles and book parts where you can find the original formula (and background theory). Also, analyzing the source code of a function may help. Regards, Gergely On Tue, Jan 18, 2011 at 5:23 PM, ilya wrote: > Hello

Re: [R] dataframe: string operations on columns

2011-01-18 Thread Hadley Wickham
> how can I perform a string operation like strsplit(x," ")  on a column of a > dataframe, and put the first or the second item of the split into a new > dataframe column? > (so that on each row it is consistent) Have a look at str_split_fixed in the stringr package. Hadley -- Assistant Profes

[R] error message

2011-01-18 Thread wangwallace
I was running a sampling syntax based on a data frame (ago) of 160 rows and 25 columns. Below are the column names: > names(ago) [1] "SubID" "AGR1" "AGR2" "AGR3" "AGR4" "AGR5" "AGR6" "AGR7" "AGR8" [10] "AGR9" "AGR10" "WAGR1" "WAGR2" "WAGR3" "WAGR4" "WAGR5" "WAGR6" "WAGR

[R] Statistical formulas

2011-01-18 Thread ilya
Hello! I hope, i'm doing right, writing here. I have a question about the R statistical formulas: were can I look, what are they? E. g. I'd like to know which exactly mathematical formula is used in Wilcoxon test, and others. Is there somewhere on the Internet information about that? Thanks a lo

Re: [R] Using anova() with glmmPQL()

2011-01-18 Thread Ben Bolker
Toby Marthews ouce.ox.ac.uk> writes: > > Dear R HELP, > > ABOUT glmmPQL and the anova command. Here is an example of a > repeated-measures ANOVA focussing on the way > starling masses vary according to (i) roost situation and > (ii) time (two time points only). [snip] > lmeres=lme(fixed=stm

Re: [R] dataframe: string operations on columns

2011-01-18 Thread Ivan Calandra
Hi, I guess it's not the nicest way to do it, but it should work for you: #create some sample data df <- data.frame(a=c("A B", "C D", "A C", "A D", "B D"), stringsAsFactors=FALSE) #split the column by space df_split <- strsplit(df$a, split=" ") #place the first element into column a1 and the

[R] dataframe: string operations on columns

2011-01-18 Thread boris pezzatti
Dear all, how can I perform a string operation like strsplit(x," ") on a column of a dataframe, and put the first or the second item of the split into a new dataframe column? (so that on each row it is consistent) Thanks Boris __ R-help@r-project.

Re: [R] to append a column to a data frame, has I use loop/if in my case?

2011-01-18 Thread jim holtman
Here is how you should be creating your dataframe so that each element has the proper mode: > days=Sys.Date()-1:70 > price=abs(rnorm(70)) > regular=rep(c(0,0,0,0,1,0,1,0,0,1),c(7,7,7,7,7,7,7,7,7,7)) > y=data.frame(cbind(days,price,regular)) > str(y) 'data.frame': 70 obs. of 3 variables: $ days

Re: [R] to append a column to a data frame, has I use loop/if in my case?

2011-01-18 Thread Joshua Ulrich
Please do not cross post: http://stackoverflow.com/q/4720076/271616 At the minimum, it would be polite to respond here with the answer you accepted on Stack Overflow. -- Joshua Ulrich  |  FOSS Trading: www.fosstrading.com On Mon, Jan 17, 2011 at 8:59 AM, Daniel Wu wrote: > days=Sys.Date()-1:70

[R] gamlss for censored and truncated distributions

2011-01-18 Thread Simon Frost
Dear R Help, I'd like to be able to use gamlss to generate distributions that are both truncated and have censoring. It doesn't look as though it is possible to do this at the moment: > gen.trun(par=c(0),family="NO",name="tr",type="left") A truncated family of distributions from NO has been gener

Re: [R] Choosing statistical test - Fisher's Exact Test?

2011-01-18 Thread Debbie Naudi
Hi Vito Thank you so much for your help I really appreciate it! I have a 4x4 table for one task and a 4x3 Table for the second task. Thanks Debbie On Tue, Jan 18, 2011 at 2:18 PM, Vito Muggeo (UniPa) wrote: > It appears that you have a 2x2 table coming from paired binary data.. > > If this is

[R] Odp: to append a column to a data frame, has I use loop/if in my case?

2011-01-18 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 17.01.2011 15:59:37: > days=Sys.Date()-1:70 > price=abs(rnorm(70)) > regular=rep(c(0,0,0,0,1,0,1,0,0,1),c(7,7,7,7,7,7,7,7,7,7)) > y=data.frame(cbind(days,price,regular)) > > > y is like > days price regular > 1 14990 0.16149463 0 > 2 1

Re: [R] Choosing statistical test - Fisher's Exact Test?

2011-01-18 Thread Vito Muggeo (UniPa)
It appears that you have a 2x2 table coming from paired binary data.. If this is the case the McNemar test is appropriate. See ?mcnemar.test or even better the package exact2x2, function mcnemar.exact() for an "exact" approach, vito Il 18/01/2011 14.40, debz ha scritto: Hi I was wonderi

Re: [R] ggplot2, geom_hline and facet_grid

2011-01-18 Thread Small Sandy (NHS Greater Glasgow & Clyde)
Thanks Dennis Yes the plot you sent was what I was expecting. Unfortunately I do not get the same thing using the same commands whn I try it. I notice that I am using a slightly earlier version of R than you. Given that it worked on the Diamonds data I doubt that this the problem but I will upgr

[R] Choosing statistical test - Fisher's Exact Test?

2011-01-18 Thread debz
Hi I was wondering whether anyone can help me with this problemit's been driving me nuts, I've been trying to figure it out for months and months without success!! Basically I have a group of participants who attended 2 experimental sessions a few months apart. I took measures of the way they

Re: [R] R scheduling request

2011-01-18 Thread Alessandro Oggioni
Many thanks Greg! I try to use tcltk2 and tclTaskSchedule function but in argument expr is possible to insert a R script? Have you an example? Alessandro Il 17 gennaio 2011 22.02.51 UTC+1, Greg Snow ha scritto: > You could write a batch file and then have your OS schedule to run R on the > batch

[R] Odp: Relative frequency on a character vector

2011-01-18 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 18.01.2011 13:51:05: > > Hi, > > I have this character vector: > > A<-c("Tell me how many different letter this vector has?") > > Is there a way with R that it can let me know how many different letters I > have on this vector? A<-c("Tell me how ma

Re: [R] Relative frequency on a character vector

2011-01-18 Thread Henrique Dallazuanna
Try this: table(strsplit(A, "?")[[1]]) On Tue, Jan 18, 2011 at 10:51 AM, ADias wrote: > > Hi, > > I have this character vector: > > A<-c("Tell me how many different letter this vector has?") > > Is there a way with R that it can let me know how many different letters I > have on this vector? >

Re: [R] Counting dates in arbitrary ranges

2011-01-18 Thread Mike Marchywka
> From: simonjk...@yahoo.ca > Date: Tue, 18 Jan 2011 02:16:37 -0500 > To: r-help@r-project.org > Subject: [R] Counting dates in arbitrary ranges > > Dear Colleagues, > I have a data set that looks as below. I'd like to count the number of dates > in a

[R] Plotting dendrogram upside-down/mirrored

2011-01-18 Thread Nathan S. Watson-Haigh
I understand that plot.dendrogram() plots a dendrogram vertically, so the root is to the left and leaves to the right. I also understand that the horiz=TRUE option plots it horizontally so the root it at the top and the leaves at the bottom. My question is can these be plotted so the root is on

[R] Relative frequency on a character vector

2011-01-18 Thread ADias
Hi, I have this character vector: A<-c("Tell me how many different letter this vector has?") Is there a way with R that it can let me know how many different letters I have on this vector? If I use nchar(A) que gives me the number 50. With this function he is counting all the letters present a

Re: [R] Help for R plot

2011-01-18 Thread Fabrice Tourre
Hi Thanks for you suggestion. I used histograme in lattice packages. If it is possible lattice can do it, it will be better. On Mon, Jan 17, 2011 at 3:28 PM, Peter Ehlers wrote: > On 2011-01-17 02:26, Fabrice Tourre wrote: >> >> Hi all, >> How to plot as the coordinate  as in my attachment? I wan

Re: [R] Counting dates in arbitrary ranges

2011-01-18 Thread Mauricio Zambrano
if you only want to count the number of days in an arbitrary time period, you may try: > install.packages("hydroTSM", dependencies=TRUE) > library(hydroTSM) > dip(from="2007-05-01", to="2009-09-10", out.type="nmbr") I hope this helps. Kinds, Mauricio -- === Linu

Re: [R] Dates when transferred from RExcel to R.

2011-01-18 Thread jim holtman
I think it is called "time zones". Is "IST" India standard time, if so that accounts for the half hour. What is your time zone and what is the time zone of the data coming from Excel? Exactly how are you importing it? On Tue, Jan 18, 2011 at 5:35 AM, Shubha Vishwanath Karanth wrote: > Hi R, >

Re: [R] Convert a matrix's columns to list

2011-01-18 Thread Vito Muggeo (UniPa)
hi feng, a possible solution is b1<-apply(a,2,list) and possibly lapply(b1,unlist) if you want exactly the output equal to "list(a[, 1], a[, 2])" best, vito Il 18/01/2011 13.53, Feng Li ha scritto: Dear R, Is there an efficient way to make a list that each element is from the corresponding

Re: [R] Convert a matrix's columns to list

2011-01-18 Thread Henrique Dallazuanna
Try this: c(unname(as.data.frame(a))) On Tue, Jan 18, 2011 at 10:53 AM, Feng Li wrote: > Dear R, > > Is there an efficient way to make a list that each element is from the > corresponding column of a matrix. For example, if I have a matrix "a" > > > a <- matrix(1:10, 5, 2) > > a > [,1] [,2

[R] Convert a matrix's columns to list

2011-01-18 Thread Feng Li
Dear R, Is there an efficient way to make a list that each element is from the corresponding column of a matrix. For example, if I have a matrix "a" > a <- matrix(1:10, 5, 2) > a [,1] [,2] [1,]16 [2,]27 [3,]38 [4,]49 [5,]5 10 I would like to have a list

[R] Circular variables within a GLM, GLM-GEE or GAM

2011-01-18 Thread Clare Embling
Hi, I have a variable (current speed direction) which is circular (0=360 degrees), and I'd like my GLM to include the variable as a circular variable. Can I do this? And what is the code? I'm actually doing a GLM-GEE using the 'geepack' package, so want to use it in that, but also interested

[R] Need help in a simulation study

2011-01-18 Thread carpan
Dear R community,and especially Giovanni Millo, For my master's thesis i need to simulate a panel data with the fixed effects correlated with the predicor, so i run the the following code: set.seed(1970) ###Panel data simulation with alphai correlated with xi##

Re: [R] tips for looping over a category for beginner

2011-01-18 Thread Peter Ehlers
On 2011-01-17 22:48, Ben Harrison wrote: hello, I am very new to R. My current data set is a mix of values and categories. It is a geoscience data set, with values per rock sample. Case in point, each sample belongs to a lithology class, and each sample has several physical property measurements

Re: [R] Finding NAs in DF

2011-01-18 Thread Johannes Graumann
Thank you very much got something running now based on this. Joh jim holtman wrote: > building on the previous responses, does this give you what you want: > >> x >A B > 1 1 1 > 2 2 NA > 3 NA NA > 4 NA 4 >> # determine where the NAs are >> row.na <- apply(x, 1, is.na) >> # now convert

Re: [R] tips for looping over a category for beginner

2011-01-18 Thread Dennis Murphy
Hi: Your intention isn't crystal clear to me, but I'll give it a shot... On Mon, Jan 17, 2011 at 10:48 PM, Ben Harrison < b.harris...@pgrad.unimelb.edu.au> wrote: > hello, I am very new to R. > My current data set is a mix of values and categories. It is a geoscience > data set, with values per

[R] Dates when transferred from RExcel to R.

2011-01-18 Thread Shubha Vishwanath Karanth
Hi R, The dates when exported from Excel to R by "Put R Var", gives one less day. For example, 1.Let 1/1/2011 be the cell A1 in date format. 2.Right click and select "Put R Var" and give a name to it say, "StartDate" (R in foreground process) 3.In the R console see the value

[R] Odp: Sampling question

2011-01-18 Thread Petr PIKAL
Hi It is rather unclear how do you want sample your data. It seems to me that you can sample row numbers and choose sampled rows from data frame. I probably direct output to a list ("mylist") and use result <- lapply("mylist", GFD) Regards Petr r-help-boun...@r-project.org napsal dne 17.01

Re: [R] rootogram for normal distributions

2011-01-18 Thread Deepayan Sarkar
On Mon, Jan 17, 2011 at 8:24 PM, S Ellison wrote: > I was distracted enough by the possibility of hijacking hist() for this > to give it a go. > > The following code implements a basic hanging rootogram based on a > normal density with hist() breaks used as bins and bin midpoints used as > the han

[R] multinomial choice modeling with mlogit

2011-01-18 Thread Muster, Holger, VF-DE
Hi all, Does anyone knows how to handle ordered preferences applying the R package mlogit (multinomial logit model)? My data set provides for each customer preferences (given as percentages) for 6 different brands. I would like to use for model calibration not just that brand with maximum stated

[R] ggplot2, geom_hline and facet_grid

2011-01-18 Thread Small Sandy (NHS Greater Glasgow & Clyde)
Hi I have a long data set on which I want to do Bland-Altman style plots for each rhythm type Using ggplot2, when I use geom_hline with facet_grid I get an extra set of empty panels. I can't get it to do it with the "Diamonds" data supplied with the package so here is a (much abbreviated) examp

  1   2   >