Re: [R] Order variables automatically

2013-01-01 Thread Anthony Damico
# create an example data frame yourdata - data.frame( cat1 = c( 1 , 0 , 1 ) , cont1 = c( 0 , 1 , 0 ) , cat2 = c( 0 , 0 , 1 ) ) # if this doesn't work for you, # please ?dput some example data in the future :) # figure out which variables contain the word 'cat'

Re: [R] cut ()

2013-01-01 Thread Neal H. Walfield
At Tue, 1 Jan 2013 02:00:14 +, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: Although David's solution (putting the right parenthesis, which I had missed) has resolved the issue, I would like to try yours as well. Could you please clarify the six elements: c(-1e-8, 0, 0, 0, 0, 1e8)? It's a

Re: [R] Order variables automatically

2013-01-01 Thread Debs Majumdar
Sorry for not being clear.  I forgot to mention that the variable labels don't really say which are categorical/continuous. They are just I1, I2,, I459. Out of these 459 variables, most are continuous and others are categorical. So, the grep command won't work here. Thanks, Debs

Re: [R] Order variables automatically

2013-01-01 Thread Rui Barradas
Hello, You must have a way of telling whether the variables are categorical. If they are factors, just not ordered factors, instead of grep the following might work. vars.to.order - sapply(yourdata, is.factor) And the rest should be the same. Hope this helps, Rui Barradas Em 01-01-2013

Re: [R] Question on creating Date variable

2013-01-01 Thread Rui Barradas
Hello, The format AM/PM should be for display purposes only, when you use format() you get a variable of class character, not of classes POSIXct POSIXt . Produce a variable y with as.POSIXct (without AM/PM) for arithmetics and another formated for display. Hope this helps, Rui Barradas Em

Re: [R] Order variables automatically

2013-01-01 Thread Debs Majumdar
Yes. That's true. All the variables are read in as numeric/integers.What I am looking for at this moment is if any variable has less than equals to 10 unique values (categories) then it is a factor.  Can that be incorporated? Thanks, Debs From: Rui Barradas

Re: [R] Order variables automatically

2013-01-01 Thread Debs Majumdar
Thanks to both of you for your help. I think I have got what I wanted. vars.to.order - sapply(d, FUN = function(x){length(unique(x))=10}) ## check no. of unique values for each variable #d[ , vars.to.order ] - lapply( d[ , vars.to.order==TRUE ], factor) ## I didn't need this line. Is this step

Re: [R] Order variables automatically

2013-01-01 Thread Rui Barradas
Hello, Just one more thing, you don't need an explicit test to TRUE, the two lines below are equivalent. d[ , vars.to.order==TRUE ] d[ , vars.to.order ] Rui Barradas Em 01-01-2013 12:44, Debs Majumdar escreveu: Thanks to both of you for your help. I think I have got what I wanted.

Re: [R] Question on creating Date variable

2013-01-01 Thread David Winsemius
On Dec 31, 2012, at 9:40 PM, Christofer Bogaso wrote: On 01 January 2013 03:00:18, David Winsemius wrote: On Dec 31, 2012, at 11:57 AM, David Winsemius wrote: On Dec 31, 2012, at 11:54 AM, Christofer Bogaso wrote: On 01 January 2013 01:29:53, David Winsemius wrote: On Dec 31, 2012, at

Re: [R] Question on creating Date variable

2013-01-01 Thread arun
HI, Just by taking David's solution:  y - as.POSIXct(paste( floor(x), round(60*(x-floor(x))) ), format=%H %M)  y1-data.frame(y,AM_PM=format(y,format=%p))  y1[3,1]-y1[4,1] #Time difference of -40 mins  y1[5,1]-y1[3,1] #Time difference of -13 mins  head(y1,2) #    y AM_PM #1

Re: [R] Question on creating Date variable

2013-01-01 Thread jim holtman
# can use sprintf to convert to a number with 2 digit fractions x - c(10.30, 11, 11.01, 11.09, 11.15, 11.59, 12, 13) as.POSIXct(sprintf(%.2f, x), format = %H.%M) [1] 2013-01-01 10:30:00 EST 2013-01-01 11:00:00 EST 2013-01-01 11:01:00 EST [4] 2013-01-01 11:09:00 EST 2013-01-01 11:15:00 EST

[R] R version 3.0.0

2013-01-01 Thread Peter Dalgaard
This is no secret to those who read the NEWS file of the development version regularly, as the following has been in place since December 12th: \section{\Rlogo CHANGES IN R-devel}{ \subsection{SIGNIFICANT USER-VISIBLE CHANGES}{ \itemize{ \item It is intended that this version will be

Re: [R] Question on creating Date variable

2013-01-01 Thread David Winsemius
On Jan 1, 2013, at 9:02 AM, jim holtman wrote: # can use sprintf to convert to a number with 2 digit fractions Useful procedure to prevent loss of trailing .00's, ... but just to clarify, sprintf never returns a numeric class object, but rather returns a character representation of one.

[R] R and SSH / exchange R objects between client and server

2013-01-01 Thread Martin Batholdy
Hi, I have a laptop (Mac OS) and a remote PC (Ubuntu) and would like to do the heavy work on the remote machine but control it via the laptop. I managed to install ssh server and can now remotely connect to my PC via ssh and can start an R session in the terminal. However, I still don't quite

[R] translate grouped data to their centroid

2013-01-01 Thread Michael Friendly
Given a data set with a group factor, I want to translate the numeric variables to their centroid, by subtracting out the group means (adding back the grand means). The following gives what I want, but there must be an easier way using sweep or apply or some such. iris2 - iris[,c(1,2,5)]

Re: [R] R and SSH / exchange R objects between client and server

2013-01-01 Thread Duncan Murdoch
On 13-01-01 2:42 PM, Martin Batholdy wrote: Hi, I have a laptop (Mac OS) and a remote PC (Ubuntu) and would like to do the heavy work on the remote machine but control it via the laptop. I managed to install ssh server and can now remotely connect to my PC via ssh and can start an R session

Re: [R] translate grouped data to their centroid

2013-01-01 Thread Prof Brian Ripley
On 01/01/2013 19:50, Michael Friendly wrote: Given a data set with a group factor, I want to translate the numeric variables to their centroid, by subtracting out the group means (adding back the grand means). The following gives what I want, but there must be an easier way using sweep or apply

Re: [R] translate grouped data to their centroid

2013-01-01 Thread Prof Brian Ripley
On 01/01/2013 20:43, Prof Brian Ripley wrote: On 01/01/2013 19:50, Michael Friendly wrote: Given a data set with a group factor, I want to translate the numeric variables to their centroid, by subtracting out the group means (adding back the grand means). The following gives what I want, but

[R] correlation coefficient spatially lagged scatterplot

2013-01-01 Thread Florian Sackl
Dear list! I found a 7 year old message with a question very similar to mine: I am using 'sgeostat' package by Albrecht Gebhardt and I am trying to put a correlation coefficient of some kind on the lagplots. Is there a possiblity to do so? and i did not find an answer to this question. It would

[R] Rd problems

2013-01-01 Thread Daniel Marcelino
Dear users, I'm struggling with encoding issues for documenting some functions. The Rd format is incradible simple, however, because I'm dealing with diacritic strings, I seted up encoding in several Rd files as latin1. Under R, using the checks available in the package 'tools it performs

Re: [R] R and SSH / exchange R objects between client and server

2013-01-01 Thread Prof Brian Ripley
On 01/01/2013 20:39, Duncan Murdoch wrote: On 13-01-01 2:42 PM, Martin Batholdy wrote: Hi, I have a laptop (Mac OS) and a remote PC (Ubuntu) and would like to do the heavy work on the remote machine but control it via the laptop. I managed to install ssh server and can now remotely connect to

Re: [R] Rd problems

2013-01-01 Thread Duncan Murdoch
On 13-01-01 2:48 PM, Daniel Marcelino wrote: Dear users, I'm struggling with encoding issues for documenting some functions. The Rd format is incradible simple, however, because I'm dealing with diacritic strings, I seted up encoding in several Rd files as latin1. Under R, using the checks

Re: [R] R and SSH / exchange R objects between client and server

2013-01-01 Thread Frans Marcelissen
Hi Martin, In addition to what Duncan writes: I think winscp does exactly what you want. You can copy objects from/to linux, but also edit files from linux on the winduts machine without explicitly copying (of course you do copy the file, but is done automatically). Bye Frans ---

Re: [R] R and SSH / exchange R objects between client and server

2013-01-01 Thread Martin Renner
I have the same setup and do this: - rsync all data and R scripts - run analysis on remote server via ssh - rsync plots and results back Martin On Jan 1, 2013, at 12:39, Frans Marcelissen frans.marcelis...@digipsy.nl wrote: Hi Martin, In addition to what Duncan writes: I think winscp