Re: [R] system() command in R
Thank you all for the suggestions. I've been trying different things to make this work. Mike I did try what you suggested . It would work normally But i guess here the problem is my local server itself. It by default takes time to start and nothing I do is helping . So I came up with the idea to communicate with the server through R-java connection. I am halfway through that , I hope it works:) Thank you all for the response. On Tue, Apr 5, 2011 at 4:36 PM, Jeff Newmiller wrote: > The ampersand is a good idea, but nohup is best avoided in scripts. Rather > the server itself should handle the transition to daemon status to avoid > ending up with many duplicate server processes running. > --- > Jeff Newmiller The . . Go Live... > DCN: Basics: ##.#. ##.#. Live Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/Batteries O.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > > Sent from my phone. Please excuse my brevity. > > Mike Marchywka wrote: >> >> -- >> > Date: Tue, 5 Apr 2011 13:37:12 +0530 >> > From: nandan.a...@gmail.com >> > To: rasanpreet.k...@gmail.com >> > CC: r-help@r-project.org >> > Subject: Re: [R] system() command in R >> > >> > On 4 April 2011 16:54, rasanpreet kaur suri wrote: >> > >> > > Hi all, >> > > I have a local server insalled on my system and have to start that from >> > > within my R function. >> > > >> > > here is how I start it: >> > > >> > > cmd<-"sh start-server.sh" >> > > >> > > system(cmd, wait=FALSE) >> > > >> > > My function has to start the server and proceed with further steps. The >> > > server starts but the further steps of the program are not executed.The >> > > cursor keeps waiting after the server is started. >> > > >> > > How r u executing further steps after starting server, meant for server >> > from R ?? >> > >> > >> > i tried removing the wait=FALSE, but it still keeps waiting. >> > > >> > > I also tried putting the start-server in a separate function and my >> > > further >> > > script in a separate function and then run them together, but it still >> > > waits. The transition from the start of server to next step is not >> > > happening. >> > > >> > > Please help. I have been stuck on this for quite some time now. >> > > >> > > -- >> >> I hadn't done this in R but expect to do so soon. >> I just got done with some java code to do something similar and you can >> expect in any implementation these things will be system dependent. It >> often helps to have simple test cases to isolate the problem. Here I made a >> tst script called "foo" >> that takes a minute or so to exevute and generates some output. >> >> If I type >> system("./foo",wait=F) >> the prompt comes back right away but stdout seems to still go to my console >> and maybe stdin is not redicrected either and it could eat your input ( no >> idea, but this is probably not what you want). >> >> I did try this that could fix your problem, on debian anyway it seems to >> work, >> >> system("nohup ./foo &") >> you can "man nohup" for details. >> >> > > Rasanpreet Kaur >> > > >> > > [[alternative HTML version deleted]] >> > > >> > > >> -- >> > > R-help@r-project.org mailing list >> > > https://stat.ethz.ch/mailman/listinfo/r-help >> > > PLEASE do read the posting guide >> > > http://www.R-project.org/posting-guide.html >> > > and provide commented, minimal, self-contained, reproducible code. >> > > >> > >> > >> > >> > -- >> > Amar Kumar Nandan >> > Karnataka, India, 560100 >> > http://aknandan.co.nr >> > >> > [[alternative HTML version deleted]] >> > >> > >> -- >> > R-help@r-project.org mailing list >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> > http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> -- >> R-help@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> -- Rasanpreet Kaur [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] system() command in R
Hi, The further steps do not get executed because the server keeps waiting. and they are in the same function as the start server. if server started manually then they run normally from the R environment. Is that what you wanted to know? I hope I answered it . On Tue, Apr 5, 2011 at 10:07 AM, nandan amar wrote: > > > On 4 April 2011 16:54, rasanpreet kaur suri wrote: > >> Hi all, >> I have a local server insalled on my system and have to start that from >> within my R function. >> >> here is how I start it: >> >> cmd<-"sh start-server.sh" >> >> system(cmd, wait=FALSE) >> >> My function has to start the server and proceed with further steps. The >> server starts but the further steps of the program are not executed.The >> cursor keeps waiting after the server is started. >> >> How r u executing further steps after starting server, meant for server > from R ?? > > > i tried removing the wait=FALSE, but it still keeps waiting. >> >> I also tried putting the start-server in a separate function and my >> further >> script in a separate function and then run them together, but it still >> waits. The transition from the start of server to next step is not >> happening. >> >> Please help. I have been stuck on this for quite some time now. >> >> -- >> Rasanpreet Kaur >> >>[[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > > > -- > Amar Kumar Nandan > Karnataka, India, 560100 > http://aknandan.co.nr > -- Rasanpreet Kaur [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] system() command in R
Hi all, I have a local server insalled on my system and have to start that from within my R function. here is how I start it: cmd<-"sh start-server.sh" system(cmd, wait=FALSE) My function has to start the server and proceed with further steps. The server starts but the further steps of the program are not executed.The cursor keeps waiting after the server is started. i tried removing the wait=FALSE, but it still keeps waiting. I also tried putting the start-server in a separate function and my further script in a separate function and then run them together, but it still waits. The transition from the start of server to next step is not happening. Please help. I have been stuck on this for quite some time now. -- Rasanpreet Kaur [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] merging multiple data frames
hi guys..thx for help i have to perform a calculation P-B/T-B where P is the values in pdf and B is the values in bdf and T in tdf On Thu, Sep 23, 2010 at 7:49 PM, Mike Rennie wrote: > First, you might want to start by generating a new column to identify your > 'pdf" and "bdf" or whatever once it's merged. > > For the merging, see > > ?merge > > But as someone's already pointed out, it's not clear what you are trying to > merge by. > > Also, as your example calculations show, you don't need to merge it to to > the calcuations you want to do... > > On Thu, Sep 23, 2010 at 8:53 AM, Steve Lianoglou < > mailinglist.honey...@gmail.com> wrote: > >> Hi, >> >> On Thu, Sep 23, 2010 at 9:04 AM, rasanpreet >> wrote: >> > >> > hi guys >> > i have multiple data frames which i want to merge. >> > there are four of them..eg >> >> Can you provide a (correct) example of what you want your merged >> data.frame to look like? >> What column do you want to use in your data.frame to merge against? >> I'm guessing SampleID(?), but then again, these aren't unique in your >> `pdf` data.frame. For instance, what would the row for "SDM001" look >> like in your merged data.frame? >> >> -steve >> >> > pdf >> > >> > SampleID UVDose_J RepairHours Day_0 Day_45 Day_90 >> > 1SDM001 1.0 3 485.612 465.142 490.873 >> > 2SDM001 1.0 3 503.658 457.863 487.783 >> > 3SDM001 1.0 2 533.193 451.044 456.973 >> > 4SDM001 1.0 2 538.334 452.887 474.915 >> > 5SDM001 1.0 1 526.034 481.123 477.801 >> > 6SDM001 1.0 1 546.543 472.322 481.546 >> > 7SDM001 1.0 0 NA NA NA >> > 8SDM001 1.0 0 NA NA NA >> > 9SDM001 0.5 3 432.134 457.245 497.975 >> > 10 SDM001 0.5 3 432.605 450.184 489.468 >> > 11 SDM001 0.5 2 450.335 496.520 488.784 >> > 12 SDM001 0.5 2 439.590 474.371 470.182 >> > 13 SDM001 0.5 1 510.480 489.561 525.029 >> > 14 SDM001 0.5 1 487.934 467.258 488.784 >> > 15 SDM001 0.5 0 NA NA NA >> > 16 SDM001 0.5 0 NA NA NA >> > 20 SDM002 1.0 3 465.549 528.715 501.374 >> > 21 SDM002 1.0 3 458.168 505.480 489.244 >> > 22 SDM002 1.0 2 447.317 464.009 478.058 >> > 23 SDM002 1.0 2 452.020 438.446 470.996 >> > 24 SDM002 1.0 1 441.718 458.760 499.221 >> > 25 SDM002 1.0 1 447.017 402.616 548.797 >> > 26 SDM002 1.0 0 NA NA NA >> > 27 SDM002 1.0 0 NA NA NA >> > 28 SDM002 0.5 3 421.409 448.870 476.392 >> > 29 SDM002 0.5 3 404.089 446.413 477.080 >> > 30 SDM002 0.5 2 399.775 432.678 465.015 >> > 31 SDM002 0.5 2 427.157 443.418 477.048 >> > 32 SDM002 0.5 1 389.674 449.353 482.264 >> > 33 SDM002 0.5 1 418.147 455.983 495.486 >> > 34 SDM002 0.5 0 NA NA NA >> > 35 SDM002 0.5 0 NA NA NA >> > 39 SDM005 1.0 3 579.836 441.040 476.382 >> > 40 SDM005 1.0 3 578.525 443.875 472.867 >> > 41 SDM005 1.0 2 564.266 432.116 469.416 >> > 42 SDM005 1.0 2 571.045 447.658 458.233 >> > 43 SDM005 1.0 1 564.664 427.673 524.122 >> > 44 SDM005 1.0 1 568.182 458.039 477.237 >> > 45 SDM005 1.0 0 NA NA NA >> > 46 SDM005 1.0 0 NA NA NA >> > 47 SDM005 0.5 3 556.534 424.786 501.658 >> > 48 SDM005 0.5 3 474.027 441.418 507.635 >> > 49 SDM005 0.5 2 481.355 430.346 468.021 >> > 50 SDM005 0.5 2 478.922 466.933 471.025 >> > 51 SDM005 0.5 1 505.539 937.759 460.985 >> > 52 SDM005 0.5 1 497.913 457.932 493.152 >> > 53 SDM005 0.5 0 NA NA NA >> > 54 SDM005 0.5 0 NA NA NA >> > 58 SDM006 1.0 3 589
[R] merging multiple data frames
hi guys i have multiple data frames which i want to merge. there are four of them..eg pdf SampleID UVDose_J RepairHours Day_0 Day_45 Day_90 1SDM001 1.0 3 485.612 465.142 490.873 2SDM001 1.0 3 503.658 457.863 487.783 3SDM001 1.0 2 533.193 451.044 456.973 4SDM001 1.0 2 538.334 452.887 474.915 5SDM001 1.0 1 526.034 481.123 477.801 6SDM001 1.0 1 546.543 472.322 481.546 7SDM001 1.0 0 NA NA NA 8SDM001 1.0 0 NA NA NA 9SDM001 0.5 3 432.134 457.245 497.975 10 SDM001 0.5 3 432.605 450.184 489.468 11 SDM001 0.5 2 450.335 496.520 488.784 12 SDM001 0.5 2 439.590 474.371 470.182 13 SDM001 0.5 1 510.480 489.561 525.029 14 SDM001 0.5 1 487.934 467.258 488.784 15 SDM001 0.5 0 NA NA NA 16 SDM001 0.5 0 NA NA NA 20 SDM002 1.0 3 465.549 528.715 501.374 21 SDM002 1.0 3 458.168 505.480 489.244 22 SDM002 1.0 2 447.317 464.009 478.058 23 SDM002 1.0 2 452.020 438.446 470.996 24 SDM002 1.0 1 441.718 458.760 499.221 25 SDM002 1.0 1 447.017 402.616 548.797 26 SDM002 1.0 0 NA NA NA 27 SDM002 1.0 0 NA NA NA 28 SDM002 0.5 3 421.409 448.870 476.392 29 SDM002 0.5 3 404.089 446.413 477.080 30 SDM002 0.5 2 399.775 432.678 465.015 31 SDM002 0.5 2 427.157 443.418 477.048 32 SDM002 0.5 1 389.674 449.353 482.264 33 SDM002 0.5 1 418.147 455.983 495.486 34 SDM002 0.5 0 NA NA NA 35 SDM002 0.5 0 NA NA NA 39 SDM005 1.0 3 579.836 441.040 476.382 40 SDM005 1.0 3 578.525 443.875 472.867 41 SDM005 1.0 2 564.266 432.116 469.416 42 SDM005 1.0 2 571.045 447.658 458.233 43 SDM005 1.0 1 564.664 427.673 524.122 44 SDM005 1.0 1 568.182 458.039 477.237 45 SDM005 1.0 0 NA NA NA 46 SDM005 1.0 0 NA NA NA 47 SDM005 0.5 3 556.534 424.786 501.658 48 SDM005 0.5 3 474.027 441.418 507.635 49 SDM005 0.5 2 481.355 430.346 468.021 50 SDM005 0.5 2 478.922 466.933 471.025 51 SDM005 0.5 1 505.539 937.759 460.985 52 SDM005 0.5 1 497.913 457.932 493.152 53 SDM005 0.5 0 NA NA NA 54 SDM005 0.5 0 NA NA NA 58 SDM006 1.0 3 589.164 459.578 509.565 59 SDM006 1.0 3 608.477 480.233 519.785 60 SDM006 1.0 2 598.354 449.266 487.058 61 SDM006 1.0 2 617.823 456.908 507.467 62 SDM006 1.0 1 566.477 500.189 526.744 63 SDM006 1.0 1 622.170 462.463 550.675 64 SDM006 1.0 0 NA NA NA 65 SDM006 1.0 0 NA NA NA 66 SDM006 0.5 3 546.472 457.880 468.129 67 SDM006 0.5 3 525.069 444.575 505.154 68 SDM006 0.5 2 569.068 446.196 473.739 69 SDM006 0.5 2 534.205 470.366 476.570 bdf SampleID UVDose_J RepairHoursDay_0 Day_45 Day_90 17SDM001 0.5 B 88.6145 388.3575 198.467 36SDM002 0.5 B 100.0760 384.9505 234.740 55SDM005 0.5 B 121.9595 300.3650 241.832 74SDM006 0.5 B 174.7005 378.3435 291.272 93SDM007 0.5 B 319.7750 335.4390 110.306 112 SDM008 0.5 B 292.8400 323.0370 172.615 131 SDM010 0.5 B 112.0225 281.0390 562.459 150 SDM011 0.5 B 125.0440 331.4650 230.026 169 SDM012 0.5 B 229.1310 264.5580 234.231 188 SDM013 0.5 B 212.9690 524.0240 420.211 207 SDM014 0.5 B 366.3350 225.0610 203.588 226 SDM016 0.5 B 305.6080 381.5770 155.052 245 SDM017 0.5 B 223.6260 281.7830 182.374 264 SDM018 0.5 B 200.7720 401.6350 193.573 283 SDM019 0.5 B 164.2360 156.9960 175.896 302 SDM023 0.5 B 198.8900 210.0600 215.629 321 SDM024 0.5 B 351.8460 100.0980 185.388 340 SDM026 0.5 B 190.4560 132.8970 160.213 359 SDM028 0.5 B 252.9760 158.2910 120.425 378 SDM029 0.5 B 411.0690 134.1060 138.528 tdf SampleID UVDose_J RepairHours Day_0 Day_45 Day_90 19SDM001 0.5 T 642.3255 579.6635 537.581 38SDM002 0.5 T 531.2000 581.
Re: [R] how to compute when row length is different
thank you so much Dennis...i got it[?] On Tue, Sep 14, 2010 at 7:01 AM, Dennis Murphy [via R] < ml-node+2539020-1932381782-160...@n4.nabble.com > wrote: > Hi: > > Just to be different, here's a data.table solution: > > library(data.table) > > # It's always a good idea to have your merge key variables match in each > data frame/table > names(DF1)[1] <- 'SampleId' > dt1 <- data.table(DF1, key = 'SampleId, RepairHours') > dt2 <- data.table(DF2, key = 'SampleId, RepairHours') > dt3 <- merge(dt1, dt2) > > dim(dt3) > [1] 30 12 # check > # Do the subtraction > dt3$diff <- with(dt3, Day_0_Read1 - ZeroMean) > > If you want to perform operations between two data frames/tables, you need > to merge the data first before you can perform the calculation(s). Dr. > Kaza's solution works if you change the ID variable name first in DF1 the > way I did and substitute SampleId for Sample_id in his code, or if you > change the ID variable in DF2 to Sample_id and use his code as is. > > HTH, > Dennis > > On Tue, Sep 14, 2010 at 5:38 AM, rasanpreet <[hidden > email]<http://user/SendEmail.jtp?type=node&node=2539020&i=0>>wrote: > > > > > > hi guys..please help me with this > > i am working on two data frames > > one goes like this: > > DF1 > > Sample_id RepairHours Denatured Dose ZeroMean FourtyFiveMean NinetyMean > > 1 SDM071 0 1B 60.5 19.0 > 45.0 > > 2 SDM071 1 1B 46.0 23.0 > 42.5 > > 3 SDM071 2 1B 52.5 24.0 > 40.0 > > 4 SDM071 3 1B 42.0 21.5 > 45.0 > > 5 SDM053 0 1B 66.5 28.5 > 56.5 > > 6 SDM053 1 1B 47.0 29.0 > 47.5 > > 7 SDM053 2 1B 52.0 31.0 > 44.0 > > 8 SDM053 3 1B 36.0 34.0 > 41.5 > > 9 SDM059 0 1B 47.5 41.5 > 29.0 > > 10SDM059 1 1B 47.0 36.0 > 35.0 > > 11SDM059 2 1B 41.5 42.0 > 32.5 > > 12SDM059 3 1B 46.5 41.5 > 32.0 > > > > > > and the other one: > > DF2 > > SampleId RepairHours Denatured Dose_uM Day_0_Read1 Day_0_Read2 > Day_45_Read1 > > 8SDM071 0 1 C 124 120 > > 108 > > 9SDM071 0 1 25 123 128 > > 77 > > 10 SDM071 0 1 50 132 138 > > 79 > > 11 SDM071 0 1 100 118 116 > > 68 > > 12 SDM071 0 1 200 125 146 > > 73 > > 20 SDM071 1 1 C 113 117 > > 113 > > 21 SDM071 1 1 25 108 115 > > 132 > > 22 SDM071 1 1 50 105 96 > > 94 > > 23 SDM071 1 1 100 101 101 > > 88 > > 24 SDM071 1 1 200 114 106 > > 89 > > 32 SDM071 2 1 C 143 136 > > 109 > > 33 SDM071 2 1 25 126 147 > > 110 > > 34 SDM071 2 1 50 109 122 > > 107 > > 35 SDM071 2 1 100 114 118 > > 89 > > 36 SDM071 2 1 200 118 128 > > 88 > > 44 SDM071 3 1 C 103 111 > > 116 > > 45 SDM071 3 1 25 108 105 > > 115 > > 46 SDM071 3 1 50 118 99 > > 88 > > 47 SDM071 3 1 100 98 103 > > 105 > > 48 SDM071 3 1 200 112 105 > > 96 > > 56 SDM053 0 1 C 214 208 > > 158 > > 57 SDM053 0 1 25 159 214 > > 178 > > 58 SDM053 0 1 50 170 169 > > 112 > > 59 SDM053 0 1 100 149 158 > > 124 > > 60 SDM053 0 1 200 201 171 > > 115 > > 68 SDM053 1 1 C 149
[R] how to compute when row length is different
hi guys..please help me with this i am working on two data frames one goes like this: DF1 Sample_id RepairHours Denatured Dose ZeroMean FourtyFiveMean NinetyMean 1 SDM071 0 1B 60.5 19.0 45.0 2 SDM071 1 1B 46.0 23.0 42.5 3 SDM071 2 1B 52.5 24.0 40.0 4 SDM071 3 1B 42.0 21.5 45.0 5 SDM053 0 1B 66.5 28.5 56.5 6 SDM053 1 1B 47.0 29.0 47.5 7 SDM053 2 1B 52.0 31.0 44.0 8 SDM053 3 1B 36.0 34.0 41.5 9 SDM059 0 1B 47.5 41.5 29.0 10SDM059 1 1B 47.0 36.0 35.0 11SDM059 2 1B 41.5 42.0 32.5 12SDM059 3 1B 46.5 41.5 32.0 and the other one: DF2 SampleId RepairHours Denatured Dose_uM Day_0_Read1 Day_0_Read2 Day_45_Read1 8SDM071 0 1 C 124 120 108 9SDM071 0 1 25 123 128 77 10 SDM071 0 1 50 132 138 79 11 SDM071 0 1 100 118 116 68 12 SDM071 0 1 200 125 146 73 20 SDM071 1 1 C 113 117 113 21 SDM071 1 1 25 108 115 132 22 SDM071 1 1 50 105 96 94 23 SDM071 1 1 100 101 101 88 24 SDM071 1 1 200 114 106 89 32 SDM071 2 1 C 143 136 109 33 SDM071 2 1 25 126 147 110 34 SDM071 2 1 50 109 122 107 35 SDM071 2 1 100 114 118 89 36 SDM071 2 1 200 118 128 88 44 SDM071 3 1 C 103 111 116 45 SDM071 3 1 25 108 105 115 46 SDM071 3 1 50 118 99 88 47 SDM071 3 1 100 98 103 105 48 SDM071 3 1 200 112 105 96 56 SDM053 0 1 C 214 208 158 57 SDM053 0 1 25 159 214 178 58 SDM053 0 1 50 170 169 112 59 SDM053 0 1 100 149 158 124 60 SDM053 0 1 200 201 171 115 68 SDM053 1 1 C 149 166 120 69 SDM053 1 1 25 145 134 118 70 SDM053 1 1 50 159 169 130 71 SDM053 1 1 100 113 126 110 72 SDM053 1 1 200 118 112 120 these are just part of the frames.. i have to subtract the first five values of dataframe2 from one value from dataframe1 eg: subtract<-DF2$Day_0_Read1-DF1$ ZeroMean if u notice the repair hours in both have to match...along with their id's. i have tried this zeroday_subtract1=DF1$Day_0_Read1 - DF2[DF1$RepairHours,]$ZeroMean but it dosent work please help me with this...i know its basic but i needhelp thx in advance -- View this message in context: http://r.789695.n4.nabble.com/how-to-compute-when-row-length-is-different-tp2538930p2538930.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.