Re: [R] Issue replacing dataset values from read data

2016-05-06 Thread Jim Lemon
Hi Emily, I haven't tested this exhaustively, but it seems to work: df<-data.frame(id=2001:3300,yrssmoke=sample(1:40,1300,TRUE), cigsdaytotal=sample(1:60,1300,TRUE),yrsquit=sample(1:20,1300,TRUE)) dfNA<-sapply(df$id,"%in%",c(2165,2534,2553,2611,2983,3233)) # create your NA values df[dfNA,c("yrsqu

Re: [R] month and output

2016-05-06 Thread David Winsemius
> On May 6, 2016, at 5:15 PM, Ashta wrote: > > Thank you very much David. > > So there is no general formal that works year all round. > > The first one work only Jan to Nov > today <- Sys.Date() > nextmo<- paste0( month.abb[ as.numeric(format(today, format="%m"))+1] , > format

Re: [R] replacing values of rows with identical row names in two dataframes

2016-05-06 Thread Jeff Newmiller
Please use reply-all to keep the mailing list in the loop, and use plain text rather than HTML to make sure the your message gets through uncorrupted. ?merge ?lapply # untested # align rows by date df1a <- merge( df1, df2, by="date", all.x=TRUE ) # like-named columns have .x or .y appended df1

[R] Issue replacing dataset values from read data

2016-05-06 Thread Chang, Emily
Dear all, I am reading a modest dataset (2297 x 644) with specific values I want to change. The code is inelegant but looks like this: df <- read.csv("mydata.csv", header = TRUE, stringsAsFactors = FALSE) # yrsquit, packyrs missing for following IDs. Manually change. for(myid in c(2165, 2534, 2

Re: [R] month and output

2016-05-06 Thread William Dunlap via R-help
You could install and load the 'lubridate' package, which has month() and month<-() functions so you can do the following: > z <- as.Date(c("2015-01-29", "2016-01-29", "2016-05-07", "2016-12-25")) > z [1] "2015-01-29" "2016-01-29" "2016-05-07" "2016-12-25" > month(z) <- month(z) + 1 > z [1] NA

Re: [R] month and output

2016-05-06 Thread Ashta
Thank you very much David. So there is no general formal that works year all round. The first one work only Jan to Nov today <- Sys.Date() nextmo<- paste0( month.abb[ as.numeric(format(today, format="%m"))+1] , format(today,"%Y") ) [1] "Jun2016" The second one works only for th

Re: [R] month and output

2016-05-06 Thread Bert Gunter
To add to what David said, maybe you want ?sink or ?capture.output . If you're really looking to combine your own text and R output, than knitr is probably what you want. The RStudio ide integrates this stuff, so you may want to look at that, too. Cheers, Bert Bert Gunter "The trouble with hav

Re: [R] month and output

2016-05-06 Thread David Winsemius
> On May 6, 2016, at 4:30 PM, David Winsemius wrote: > > >> On May 6, 2016, at 4:11 PM, Ashta wrote: >> >> Hi all, >> >> I am trying to ge get the next month of the year. >> >> today <- Sys.Date() >> xx<- format(today, format="%B%Y") >> >> I got "May2016", but I want Jun2016. How do I d

[R] Fwd: tcltk: click and return table cell index

2016-05-06 Thread Dalthorp, Daniel
Thanks, John. The trouble with that solution is that it gives the index for where the cursor was before clicking rather than the cell that was clicked. The solution is that the binding gives the x, y pixel coordinates of the click to the callback, and those just need to be translated to cell inde

Re: [R] month and output

2016-05-06 Thread David Winsemius
> On May 6, 2016, at 4:11 PM, Ashta wrote: > > Hi all, > > I am trying to ge get the next month of the year. > > today <- Sys.Date() > xx<- format(today, format="%B%Y") > > I got "May2016", but I want Jun2016. How do I do that? today <- Sys.Date() nextmo<- paste0( month.abb[ as.numeric(fo

Re: [R] replacing values of rows with identical row names in two dataframes

2016-05-06 Thread Jeff Newmiller
Why would you want to use a for loop? Is this homework? -- Sent from my phone. Please excuse my brevity. On May 6, 2016 4:15:09 PM PDT, Saba Sehrish via R-help wrote: > > >Hi > >I have two dataframes(df1, df2) with equal number of columns (1566) but >lesser rows in df2 (2772 in df1 and 40 in

[R] replacing values of rows with identical row names in two dataframes

2016-05-06 Thread Saba Sehrish via R-help
Hi I have two dataframes(df1, df2) with equal number of columns (1566) but lesser rows in df2 (2772 in df1 and 40 in df2). Row names are identical in both dataframes (date). I want to replace NAs of df1 with the values of df2 for all those rows having identical row names (date) but without

[R] month and output

2016-05-06 Thread Ashta
Hi all, I am trying to ge get the next month of the year. today <- Sys.Date() xx<- format(today, format="%B%Y") I got "May2016", but I want Jun2016. How do I do that? My other question is that, I read a data and do some analysis and I want to send all the results of the analysis to a pdf f

Re: [R] with vs. attach

2016-05-06 Thread Hadley Wickham
You may want to read http://rpubs.com/hadley/157957, which captures my latest thinking (and tooling) around this problem. Feedback is much appreciated. Hadley On Fri, May 6, 2016 at 2:14 PM, David Winsemius wrote: > >> On May 6, 2016, at 5:47 AM, Spencer Graves >> wrote: >> >> >> >> On 5/6/201

Re: [R] Help needed with successfully downloading and opening Agricolae package

2016-05-06 Thread Phillips,Douglas A
Thanks Sarah, downloaded the sp package separately and that resolved the error. > On May 6, 2016, at 5:43 PM, David Winsemius wrote: > > >> On May 6, 2016, at 1:41 PM, Sarah Goslee wrote: >> >> On Fri, May 6, 2016 at 4:33 PM, Jeff Newmiller >> wrote: >>> I am puzzled why the original insta

Re: [R] Help needed with successfully downloading and opening Agricolae package

2016-05-06 Thread David Winsemius
> On May 6, 2016, at 1:41 PM, Sarah Goslee wrote: > > On Fri, May 6, 2016 at 4:33 PM, Jeff Newmiller > wrote: >> I am puzzled why the original install.packages call did not also download >> the sp package, since the default argument dependencies = NA should have >> triggered installation of im

Re: [R] find high correlated variables in a big matrix

2016-05-06 Thread David Winsemius
> On May 6, 2016, at 2:12 PM, Lida Zeighami wrote: > > Hi there, > > Is there any way to find out high correlated variables among a big matrix? > for example I have a matrix called data= 2000*5000 and I need to find the > high correlated variables between the variables in the columns! (Need 100

Re: [R] find high correlated variables in a big matrix

2016-05-06 Thread Clint Bowman
Are you rying to find clusters of variables according to some distance metric? Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600

[R] find high correlated variables in a big matrix

2016-05-06 Thread Lida Zeighami
Hi there, Is there any way to find out high correlated variables among a big matrix? for example I have a matrix called data= 2000*5000 and I need to find the high correlated variables between the variables in the columns! (Need 100 high correlated variables from 5000 variables in column) I could

Re: [R] Help needed with successfully downloading and opening Agricolae package

2016-05-06 Thread Sarah Goslee
On Fri, May 6, 2016 at 4:33 PM, Jeff Newmiller wrote: > I am puzzled why the original install.packages call did not also download > the sp package, since the default argument dependencies = NA should have > triggered installation of imports including spDep, which should in turn have > installed th

Re: [R] Help needed with successfully downloading and opening Agricolae package

2016-05-06 Thread Jeff Newmiller
I am puzzled why the original install.packages call did not also download the sp package, since the default argument dependencies = NA should have triggered installation of imports including spDep, which should in turn have installed the dependencies including the sp package. Anyone have a theor

Re: [R] Help needed with successfully downloading and opening Agricolae package

2016-05-06 Thread Sarah Goslee
This is a plain-text email list, so your red doesn't show up, but since the error message said that the installer couldn't find the sp package, I'd start by installing that. Sarah On Fri, May 6, 2016 at 12:35 PM, Phillips,Douglas A wrote: > Hi, I just downloaded the Agricolae package and tried t

Re: [R] with vs. attach

2016-05-06 Thread David Winsemius
> On May 6, 2016, at 5:47 AM, Spencer Graves > wrote: > > > > On 5/6/2016 6:46 AM, peter dalgaard wrote: >> On 06 May 2016, at 02:43 , David Winsemius wrote: >> On May 5, 2016, at 5:12 PM, Spencer Graves wrote: I want a function to evaluate one argument in the en

[R] Help needed with successfully downloading and opening Agricolae package

2016-05-06 Thread Phillips,Douglas A
Hi, I just downloaded the Agricolae package and tried to access it using the commands listed below (and received the error messages in red). Any suggestions on resolving these errors? Thanks for your assistance. Doug > install.packages("agricolae") % Total% Received % Xferd Average S

Re: [R] Freq table

2016-05-06 Thread Bert Gunter
This is not a code writing service. Posters are expected to first make an honest effort and show us their code as part of their post. Please read the posting guide to learn what is expected. However, a hint to get you started: see ?cut If you have not already gone through an R tutorial or two, pl

[R] Freq table

2016-05-06 Thread Partha Sinha
M1 M2 M4 60 86 48 72 90 86 66 86 62 69 60 48 66 86 58 I want to frequency table by binning the data in 0-60, 61-80,80-100 and want output as M1 M2 M3 0-60 61-80 80-100 How to do [[alternative HTML version deleted]] __ R-help

[R] RandomForest-question about split point and GetTree function

2016-05-06 Thread Adam Sanders
I am looking at results of a random forest. In the documentation, it says the following for categorical variables: "For categorical predictors, the splitting point is represented by an integer, whose binary expansion gives the identities of the categories that goes to left or right. For example, i

[R] openssl package install error

2016-05-06 Thread Charles Determan
I am trying to install 'openssl' on ubuntu 14.04. I already of libssl-dev and libcurl4-openssl-dev installed. But when I try to install I get a bunch of errors complaining about 'unknown type 'u_char''. Thoughts? Excerpt of output: Found pkg-config cflags and libs! Using PKG_CFLAGS= Using PKG_

[R] bootstrapping code with ordered categorical data(five categories)

2016-05-06 Thread thanoon younis
Hi I need a bootstrapping code with ordered categorical data(five categories) to re-samplling a real data with 16 variables and 200 sample size. Any help please -- Thanoon Y. Thanoon PhD Department of Mathematical Sciences Faculty of Science University Technology Malaysia, UTM E.Mail: thano

Re: [R] with vs. attach

2016-05-06 Thread Spencer Graves
On 5/6/2016 6:46 AM, peter dalgaard wrote: On 06 May 2016, at 02:43 , David Winsemius wrote: On May 5, 2016, at 5:12 PM, Spencer Graves wrote: I want a function to evaluate one argument in the environment of a data.frame supplied as another argument. "attach" works for this, but "with" d

Re: [R] svyciprop object

2016-05-06 Thread Leonardo Ferreira Fontenelle
Em Sex 6 mai. 2016, às 06:20, kende jan via R-help escreveu: > Hi, I'd like to access to the different elements in a svyciprop object > (to the confidence intervals in particular...). But none of the functions > I know works.Thank you for your help ! I don't know what data set you are using, so fo

Re: [R] svyciprop object

2016-05-06 Thread Jeff Newmiller
Your post in HTML format came through garbled. Please post plain text email on this list. Your question is unclear as well. Perhaps you are not familiar with using the str() function preview what is in an object? -- Sent from my phone. Please excuse my brevity. On May 6, 2016 2:20:00 AM PD

Re: [R] with vs. attach

2016-05-06 Thread peter dalgaard
On 06 May 2016, at 02:43 , David Winsemius wrote: > >> On May 5, 2016, at 5:12 PM, Spencer Graves >> wrote: >> >> I want a function to evaluate one argument >> in the environment of a data.frame supplied >> as another argument. "attach" works for >> this, but "with" does not. Is there a wa

[R] Truncreg package help

2016-05-06 Thread Philipp Schaper
Dear R userers, I am running truncated regressions with the 'truncreg' package. My sample is large (6,000 observations), the data is left-truncated at 1 and the left tail of the data is heavily centered at 1. When I am running the regression I receive the following error message: Error in o

[R] svyciprop object

2016-05-06 Thread kende jan via R-help
Hi, I'd like to access to the different elements in a svyciprop object (to the confidence intervals in particular...). But none of the functions I know works.Thank you for your help ! > grr <- svyciprop(~temp==bzz, dclus1)> grr                               2.5%   > 97.5%temp == bzz 0.040719697

Re: [R] with vs. attach

2016-05-06 Thread Spencer Graves
On 5/5/2016 11:17 PM, Bert Gunter wrote: ... and it's exactly with.default's code ! Thanks for pointing that out. Unfortunately, it didn't work inside another function. However, if I had looked at it, I might have been able to thought to try it. Spencer Cheers, Bert Bert Gunter "Th