similar to: create dummy variables by for loop

Displaying 20 results from an estimated 1200 matches similar to: "create dummy variables by for loop"

2010 Feb 14
2
paperclip is making me crazy
seems pretty simple, my model... has_attached_file :pic_1, :styles => { :thumb => "120x90" }, :url => "/:attachment/:id_:style.:extension", :path => ":rails_root/public/system/:attachment/:id_:style.:extension" my view... <% form_tag(:action => ''create'', :html => { :multipart => true }) do -%> <label
2018 Jan 08
4
Replace NAs in split lists
Hi all-- I stumbled on this problem online. I did not like the solution given there which was a long UDF. I thought why cannot split and l/s apply work here. My aim is to split the data frame, use l/sapply, make changes on the split lists and combine the split lists to new data frame with the desired changes/output. The data frame shown below has a column named ID which has 2 variables a and b;
2018 Jan 08
2
Replace NAs in split lists
Thank you Jeff. Your code works, as usual , perfectly. I am just wondering why if i put the whole code in one line, i get an error message. sdf2 <- lapply( sdf, function(z){z$Value <-ifelse(is.na(z$Value),z$Value[!is.na(z$Value)][1],z$Value)z}) error. unexpected symbol in sdf2 Thanks again EK On Mon, Jan 8, 2018 at 3:12 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: >
2018 Jan 08
0
Replace NAs in split lists
Upon closer examination I see that you are not using the split version of df1 as I usually would, so here is a reproducible example: #---- df1 <- read.table( text= "ID ID_2 Firist Value 1 a aa TRUE 2 2 a ab FALSE NA 3 a ac FALSE NA 4 b aa TRUE 5 5 b ab FALSE NA ", header=TRUE, as.is=TRUE ) sdf <- split( df1, df1$ID ) # note the extra [ 1 ]
2018 Jan 08
3
Replace NAs in split lists
Why do you want to modify df1? Why not just reassemble the parts as a new data frame and use that going forward in your calculations? That is generally the preferred approach in R so you can re-do your calculations easily if you find a mistake later. -- Sent from my phone. Please excuse my brevity. On January 7, 2018 7:35:59 PM PST, Ek Esawi <esawiek at gmail.com> wrote: >I just came
2018 Jan 08
0
Replace NAs in split lists
I don't know. You seem to be posting in HTML so your code is mangled. Can you post plain text and use the reprex package to make sure it produces the errorin a clean R session? -- Sent from my phone. Please excuse my brevity. On January 8, 2018 8:03:45 AM PST, Ek Esawi <esawiek at gmail.com> wrote: >Thank you Jeff. Your code works, as usual , perfectly. I am just >wondering why
2018 Jan 08
0
Replace NAs in split lists
I just came up with a solution right after i posted the question, but i figured there must be a better and shorter one.than my solution sdf1[[1]][1,4]<-lapplyresults[[1]] sdf1[[2]][1,4]<-lapplyresults[[2]] EK On Sun, Jan 7, 2018 at 10:13 PM, Ek Esawi <esawiek at gmail.com> wrote: > Hi all-- > > I stumbled on this problem online. I did not like the solution given > there
2018 Jan 08
1
Replace NAs in split lists
OPS! Sorry i did indeed posted the code in HTML; should have known better. ifelse(is.na(z$Value),z$Value[!is.na(z$Value)][1],z$Value)z}) error. unexpected symbol in sdf2 On Mon, Jan 8, 2018 at 11:44 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: > I don't know. You seem to be posting in HTML so your code is mangled. Can you post plain text and use the reprex package to
2018 Jan 08
2
Replace NAs in split lists
Hi With the example, na.locf seems to be the easiest way. > library(zoo) > na.locf(df1) ID ID_2 Firist Value 1 a aa TRUE 2 2 a ab FALSE 2 3 a ac FALSE 2 4 b aa TRUE 5 5 b ab FALSE 5 Cheers Petr > -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Jeff > Newmiller > Sent: Monday, January
2007 Dec 10
0
password authentication stops but can be restarted
I have several Sun Solaris systems that share directories via SAMBA. After some period (I think 30 days, which the password expiration period) the authentication stops with the following messages (all names changed to protect the guilty): li_rpc_pipe_open_schannel: failed to get schannel session key from server W3K_SERVER for domain DOMAINX. connect_to_domain_password_server: unable to open the
2018 Jan 08
0
Replace NAs in split lists
Yes, you are right if the IDs are always sequentially-adjacent and the first non-NA value appears in the first record for each ID. -- Sent from my phone. Please excuse my brevity. On January 8, 2018 2:29:40 AM PST, PIKAL Petr <petr.pikal at precheza.cz> wrote: >Hi > >With the example, na.locf seems to be the easiest way. >> library(zoo) > >> na.locf(df1) > ID
2006 Jan 13
2
LoginGraceTime
Hello, We've found some undesirable behavior with respect to LoginGraceTime. A minor code change in session.c seems to clear it up, but now I'm asking for help in better understanding the problem and determining if there any unexpected side effects of the change. First, the code change: $ diff orig_session.c session.c 216c216,218 < alarm(0); --- >
2018 Jan 08
2
Replace NAs in split lists
You can enforce these assumptions by sorting on multiple columns, which leads to na.locf(df1[ order(df1$ID,df1$Value), ]) On Mon, Jan 8, 2018 at 4:19 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: > Yes, you are right if the IDs are always sequentially-adjacent and the > first non-NA value appears in the first record for each ID. > -- > Sent from my phone. Please
2012 Jun 06
2
ggplot2: legend for geom_rug() ..?
Hi, I was trying to make another legend for the rug plot. Sample code: library(ggplo2) ids <- paste('id_',1:3,sep='') before <- sample(9) after <- sample(1:10,9) dat <- as.matrix(cbind(before,after)) rownames(dat) <- rep(ids,3) position <- c(rep(10,3),rep(13,3),rep(19,3)) mdat <- cbind(melt(dat),position) ggplot(mdat, aes(position, value)) +
2018 Jan 08
0
Replace NAs in split lists
"Enforce" is overstating it... results will differ if there are no non-NA values for a given ID, and there is a potential further discrepancy if there are multiple non-NA values. But these issues were not identified by the OP, so may not be relevant in their case. -- Sent from my phone. Please excuse my brevity. On January 8, 2018 6:41:33 AM PST, Eric Berger <ericjberger at
2002 Sep 09
1
Plots by subject
Hello! I need some help with creating plots for each study subject. I have tried the 'for' command as described in 'An Introduction to R', but I wasn't successful. Here's what I want to do: -Create and save the following overlayed scatterplots for each subject (1 to n). -The data frame is in the form of one line per visit per subject (so more than one line per
2006 Mar 28
0
Moving all items from one Scriptaculous box to another
I posted the following on news://comp.lang.javascript, and someone kindly replied suggesting I should try on this mailing list. (Please excuse very long lines - I carefully format line endings; but Microsoft Outlook, which I have to use at my client site, then takes it upon itself to rearrange and remove most of my linefeeds! :-< ) I am using Thomas Fuchs''s amazing drag-and-drop
2009 Mar 09
3
Creating an Excel file with multiple spreadsheets
DeaR all, I'd like to know how to create an Excel file with multiple spreadsheets from R. I searched the help files and found [1] but it is not what I want to do. Let's say I have a data frame called DF as in the following code # Some data set.seed(123) ID<-sample(5,100,replace=TRUE) X<-rnorm(100) Y<-rpois(100,10) Z<-X*Y DF<-data.frame(ID,X,Y,Z) str(DF) I'd like to
2005 Aug 18
1
ssh pre-shared key
I might be going crazy... perhaps my notes and memory has failed me but it ain't working... on host machine... ssh-keygen -t rsa ssh-keygen -t dsa scp *pub root at remote:/root on remote machine... cat /root/id_{r,d}sa.pub >> /root/.ssh/authorizedkeys_2 but it still asks for password when I try to connect as root from remote host logsAug 18 15:51:13 srv1 sshd[1630]: Accepted
2002 Jan 15
3
ssh-agent too easy to hack
1/ Most correctly configured unix servers are fairly secure. Workstations on the other hand are extremely easy to compromise. Even if the eeprom (on a sparc) is password protected the fact that a hacker can get physical access to the machine means that it's very likely to be compromised, but thats just life. (I'm sure at least some readers on this list will at some time in there life have