[R] tips for looping over a category for beginner

2011-01-18 Thread Ben Harrison
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 (density, porosity...). I want to be able

[R] dotplot line types and strip question

2011-01-18 Thread Byerly, Mike M (DFG)
Hello, I have one question regarding dotplots and one question about the strip function in lattice. In the following function I wish to use two different line types in a dotplot. Specifying lty =c(1,2) does not work. No matter what line type is specified, solid lines are produced. The other

[R] Loading wordnet in R

2011-01-18 Thread fayazvf
I ve installed wordnet 2.1 and R 2.11.0 on windows 7. Whenver i try to load wordnet in R, i get an error initDict() FALSE cannot find wordnet 'dict' directory, Please set the WNHOME variable to its parent. I have tried setting WNHOME to C:\Program Files (x86)\WordNet\2.1\dict,C:\\Program Files

[R] Counting dates in arbitrary ranges

2011-01-18 Thread Simon Kiss
Dear Colleagues, I have a data set that looks as below. I'd like to count the number of dates in a series of arbitrary ranges (breaks) i.e. not pre-defined breaks such as months, quarters or years. table(format()) produces ideally formatted output, but table() does not appear to accept

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

2011-01-18 Thread Ivan Calandra
Hi, First a good tip when you ask on the R list is to provide data in a way that we can readily use it. I think the best way to do it is to copy the output of dput(tc) into the email you write. There might be better ways to do what you want, but here is what I would do: #first subset what

Re: [R] Importing multiple text files with lapply.

2011-01-18 Thread Ivan Calandra
Hi, The solution with lapply() should work; it seems that the problem was with the file name. mylist - lapply(a, read.table, header = TRUE, sep = '\n') What is a? Is it an object containing a path+file name? Maybe not. Second, I'm not sure sep should be \n. I think , would be better. Just a

Re: [R] Accessing MySQL Database in R

2011-01-18 Thread Joel
You could try useing '127.0.0.1' instead of 'localhost' and see if that works. -- View this message in context: http://r.789695.n4.nabble.com/Accessing-MySQL-Database-in-R-tp3221264p3221291.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] dotplot line types and strip question

2011-01-18 Thread Dennis Murphy
Hi: On Mon, Jan 17, 2011 at 10:10 PM, Byerly, Mike M (DFG) mike.bye...@alaska.gov wrote: Hello, I have one question regarding dotplots and one question about the strip function in lattice. In the following function I wish to use two different line types in a dotplot. Specifying lty

Re: [R] Difficult with round() function

2011-01-18 Thread Petr Savicky
On Mon, Jan 17, 2011 at 12:02:21PM -0800, Aaron Polhamus wrote: Dear list, I'm writing a function to re-grid a data set from finer to coarser resolutions in R as follows (I use this function with sapply/apply): gridResize - function(startVec = stop(What's your input vector), to =

Re: [R] Counting dates in arbitrary ranges

2011-01-18 Thread Dennis Murphy
Hi: Perhaps you were looking for something like this: table(cut(mydata[[1]], breaks=seq(from = as.Date(2008-06-26), to = as.Date(2009-06-26), by = 'month'))) 2008-06-26 2008-07-26 2008-08-26 2008-09-26 2008-10-26 2008-11-26 2008-12-26

Re: [R] median by geometric mean -- are we missing what's important?

2011-01-18 Thread Keith Jewell
Yes, of course. I think all the posts up to Bert's addressed the coding question as asked - how to calculate a particular version of the median (not the mean) rather than any underlying, unstated, statistical or scientific question. IIRC there hasn't been any indication that non-positive

[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)

[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

Re: [R] rootogram for normal distributions

2011-01-18 Thread Deepayan Sarkar
On Mon, Jan 17, 2011 at 8:24 PM, S Ellison s.elli...@lgc.co.uk 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

[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

[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

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 rock

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 to list of

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

[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

[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

[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 b

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 m...@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]

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] 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

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 ehl...@ucalgary.ca wrote: On 2011-01-17 02:26, Fabrice Tourre wrote: Hi all, How to plot as the coordinate  as in my

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 -- === Linux user

[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 and

[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

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 series

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 diasan...@gmail.com 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

[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 many different

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 greg.s...@imail.org ha scritto: You could write a batch file and then have your OS schedule to

[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] 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

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

[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 14989

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) vito.mug...@unipa.itwrote: It appears that you have a 2x2 table coming from paired binary

[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 generated

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 daniel_w...@163.com wrote:

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 :

[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 __

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 second into

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

2011-01-18 Thread Ben Bolker
Toby Marthews toby.marthews at 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]

[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

[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 WAGR7 [19] WAGR8 WAGR9 WAGR10 ocbi

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 Professor /

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

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

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),

[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

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

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] 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.

[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:

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

[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: [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

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

[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

[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

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 chea...@hotmail.com wrote: Hi I need some help trying to restructure a data frame: I have: foodtransaction quantity pizza BUY 5 pizza SELL 3

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

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

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] 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] 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 is

[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 __

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

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.04

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] 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:

[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] 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 Levels: 1

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 d.kazakiew...@gmail.com 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] 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

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] 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?

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 the first

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 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 the first

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 Henrique Dallazuanna
Or: read.table(textConnection(as.matrix(df)), sep = ) On Tue, Jan 18, 2011 at 11:02 PM, Waclaw Kusnierczyk w...@idi.ntnu.nowrote: 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 =

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

[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:

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,

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 ehl...@ucalgary.ca 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

[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.

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

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

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

2011-01-18 Thread Ben Harrison
On 18 January 2011 22:52, Peter Ehlers ehl...@ucalgary.ca 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

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,

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

[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] 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 ehl...@ucalgary.ca 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

[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

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

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

[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

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 call

  1   2   >