关于R软件else后面显示多条语句问题

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/hello_dzm/article/details/81056264

新手,刚开始学遇到else后面输出多条语句特别是变量时遇到的问题,特意记录下来:

else后面,如果输出变量x,则一定将其要放在最下面


但如果下面有两个变量只能显示最后一个,我也不知道是什么情况,希望有缘人看到话能告诉我!!!!!!


展开阅读全文

求解关于if else问题

10-29

求解!!!!!!rn原来的表里字段都是可空的,而且原先并没有主键,但是执行后出现以下错误:rnrn消息 8111,级别 16,状态 1,第 24 行rn无法在表 'PMX' 中可为空的列上定义 PRIMARY KEY 约束。rn消息 1750,级别 16,状态 0,第 24 行rn无法创建约束。请参阅前面的错误消息。rnrn不应该啊,else后面的语句不是不应该执行么?为什么还会报错rn[code=sql]rnif exists (select 1 from sysobjectsrn where id = object_id('PMX')rn and type = 'U')rnbegin rn if not exists (select * from sys.indexes where object_id = object_id(N'[dbo].PMX') and name = N'PMX_K')rn beginrn alter table PMX alter column ZQ varchar(8);rn alter table PMX alter column DB varchar(20);rn endrn elsern beginrn ALTER TABLE PMX DROP CONSTRAINT PMX_K;rn alter table PMX alter column CY varchar(6) not null;rn alter table PMX alter column DB varchar(20) not null;rn alter table PMX alter column SC char not null;rn alter table PMX alter column BZ char not null;rn alter table PMX alter column YW bigint not null;rn alter table PMX alter column HT varchar(10) not null;rn alter table PMX alter column YW varchar(6) not null;rn alter table PMX alter column ZQ varchar(8) not null;rn alter table PMX alter column GH int not null;rn alter table PMX alter column SN bigint not null;rnrn ALTER TABLE PMX ADD CONSTRAINT PMX_K PRIMARY KEY CLUSTERED rn (rn CY ASC,rn DBH ASC,rn SC ASC,rn BZ ASC,rn YW ASC,rn HT ASC,rn YW ASC,rn ZQ ASC,rn GH ASC,rn SN ASCrn ); rn endrnend rngo rn[/code] 论坛

关于Delphi if else问题

12-29

selectString1 := contentSelect1;rn selectString2 := contentSelect2;rn if(selectString1='')and(selectString2='') thenrn beginrn with application dorn MessageBox('请选择查询条件','提示信息',MB_OK);rn end;rn endrn else if(selectString1='')and(selectString2<>'') then begin /////出错rn if(selectString2='Y') then beginrn With ADOQuery1 dorn beginrn Close;rn SQL.Clear;rn SQL.Add('Select * From jshk');rn SQL.Add(' where 打印状态=''Y'' and 监管项目<>''0037''');rn Open;rn end;rn end else beginrn With ADOQuery1 dorn beginrn Close;rn SQL.Clear;rn SQL.Add('Select * From jshk');rn SQL.Add(' where 打印状态<>''Y'' and 监管项目<>''0037''');rn Open;rn end;rn end;rn endrn else if(selectString1<>'')and(selectString2='') then beginrn With ADOQuery1 dorn beginrn Close;rn SQL.Clear;rn SQL.Add('Select * From jshk');rn SQL.Add('where 管辖单位=:ss and 监管项目<>''0037''');rn Parameters.ParamByName('ss').Value:=selectString1;rn Open;rn end;rn endrn else if(selectString1<>'')and(selectString2='Y') then beginrn With ADOQuery1 dorn beginrn Close;rn SQL.Clear;rn SQL.Add('Select * From jshk');rn SQL.Add(' where 管辖单位=:ss and 打印状态=''Y'' and 监管项目<>''0037''');rn Parameters.ParamByName('ss').Value:=selectString1;rn Open;rn end;rn endrn else beginrn With ADOQuery1 dorn beginrn Close;rn SQL.Clear;rn SQL.Add('Select * From jshk');rn SQL.Add(' where 管辖单位=:ss and 打印状态<>''Y'' and 监管项目<>''0037''');rn Parameters.ParamByName('ss').Value:=selectString1;rn Open;rn end;rn end;rn请大侠们帮忙看下哪里有问题,始终在第一个else if处报错,说是 ;expected but else foundrnrn 论坛

关于if else 问题

09-06

源代码:rn PHONEBOOK new_ptr;rn PHONEBOOK prev_ptr;rn PHONEBOOK tmp_ptr;rnrn int control1=1;rn char control2;rnrn new_ptr=(PHONEBOOK)malloc(sizeof(struct phone_book));rnrn while(control1)rn rn printf("================ Add Friends Function =====================\n");rn printf("=====What is your friend's first name?\n");rn scanf("%s", new_ptr->fname);rn printf("=====What is your friend's last name?\n");rn scanf("%s", new_ptr->lname);rn printf("=====What is your friend's phone number?\n");rn scanf("%s", new_ptr->phone_number); rn rn printf("This is information:\n"); rn printf("%s %s\'s phone number is %s. \n", new_ptr->lname, new_ptr->fname, new_ptr->phone_number);rn rn label1:rn printf("Confirm the action? (y\\Y or n\\N)\n");rn scanf("%c", &control2);rn rn if(control2=='y'||control2=='Y')rn rn control1=0;rn rn else if(control2=='n'||control2=='N')rn rn control1=1;rn rn elsern rn printf("Invalid input.\n");rn goto label1;rn rn rnrnrn这是我代码的一段,意思就是想做个对前面操作的确认。 但测试的时候,有个问题,rn================ Add Friends Function =====================rn=====What is your friend's first name?rnhellorn=====What is your friend's last name?rnhellorn=====What is your friend's phone number?rn2892890rnThis is information:rnhello hello's phone number is 2892890. rnConfirm the action? (y\Y or n\N) rnInvalid input. <<<<<--------------问题在这里,为什么总是先进入这个语句,在重新读取用户操作。rnConfirm the action? (y\Y or n\N)rnyrnrn谢谢。rn 论坛

一个同时then和else后面语句的程序

03-03

程序中000000的位置条件成立只执行THEN以后的语句,不成立时既执行THEN后面的语句(应该不执行)也执行ELSE以后的语句,这是什么问题?rnrnrnrn rn rn <% rn rn if session("UsrName")="" thenrn response.redirect "../"rn elsern if request("radiobutton")="" then rn response.Write " " rn elsern rn Set rsUser = Server.CreateObject("ADODB.RecordSet") rn sqltext="SELECT count(*) FROM JY_Sj_Bl_Infor WHERE Sj_tel_no='"&Request("textfield11")&"' and sj_end_period>='"&Request("sj_jx_period3")&"'"rn rsUser.open sqltext,cn,1,1 rn 000000: if rsUser(0)>=1 then rn response.Write " " rn else rn set cmd=server.CreateObject("adodb.command")rn cmd.ActiveConnection=cnrn cmd.CommandType=4rn cmd.commandText="Jy_sj_imei_dj"rn cmd.parameters.refreshrn cmd("@t_imei")=request("radiobutton")rn cmd("@t_tel_no")=request("textfield11") rn if request("textfield12")=0 or request("textfield12")="0" thenrn cmd("@t_y_cash")=0 rn cmd("@t_total_cash")=0 rn cmd("@t_cash_s_period")="" rn cmd("@t_cash_e_period")="" rn elsern cmd("@t_y_cash")=request("textfield13") rn cmd("@t_total_cash")=request("textfield12") rn cmd("@t_cash_s_period")=request("sj_jx_period1") rn cmd("@t_cash_e_period")=request("sj_jx_period2") rn end ifrn cmd("@t_yw_tel_no")=request("textfield15") rn cmd("@t_sj_price")= request("textfield2") rn cmd("@t_xfxe")=request("textfield3") rn cmd("@t_xfxe_s_period")= request("sj_jx_period3") rn cmd("@t_xfxe_e_period")= request("sj_jx_period4") rn cmd("@t_jb_usrnameinfor")=request("sj_jx0") rn cmd("@t_sc_usrnameinfor")=request("sj_jx111") rn cmd("@t_remark")= request("textfield14") rn cmd.execute rn Set cmd.ActiveConnection = nothingrn Set cmd = nothingrn response.Write " " rn end ifrn Set rsUser = nothingrn end ifrn end ifrn %>rn 论坛

关于VB goto 和if else问题

03-04

If Not mode Then rn COM1.InputLen = 14rn COM1.InBufferCount = 0rn COM1.Output = outDatarn tl = timeGetTimern ...........rn ElserntoNext:rn COM1.InputLen = 1rn Do Until COM1.InBufferCount > 13rn DoEventsrn Sleep 2rn Looprn…………rn End Ifrnrnrn Else 后面没有什么东西了,直接跟着toNext: ,难道else 之后执行的就是toNext: 里面的程序吗? 不是只有goto才能进入到toNext:里吗?rnrn看清我的提问:我是问,为什么 Else 后面没有东西了而是跟着toNext: 然后才是end if 难道else之后直接执行toNext:里的内容?rnrnrn下面还有一段程序,同样是困惑:如果说chkagain:只有goto指过去才能执行,那么可以看到下面的程序,goto 在chkagain:之下,也就是说,进去了才有可能执行到:If SetWenda Then GoTo chkagain 然后返回来chkagain:,所以我要问的是,是不是程序执行到chkagain:处,会当做一般的程序,继续执行chkagain:以下的内容,然后如果有goto 指向过来,也可以直接跳过来?rnrn If COM1.PortOpen = True Then COM1.PortOpen = Falsern rn comSetting = Combo1.Text & ",n,8,1 "rn COM1.Settings = comSettingrn COM1.CommPort = Val(Combo1)rn COM1.InputLen = 14rn COM1.PortOpen = Truern rn[color=#FF0000]chkagain:[/color] COM1.InBufferCount = 0rnrn Sleep 150 '延时150msrn If COM1.InBufferCount > 10 Then '>10说明开始有数据返回rn [color=#FF0000]If SetWenda Then GoTo chkagain[/color] rn If False Thenrn Label1 = "BROADCAST "rnrn ExBtn3.Enabled = Falsern bOnline = Truern mode = Truern ' ExBtn5.Enabled = Falsern ExBtn6.Enabled = Falsern ExBtn7.Enabled = Falsern ExBtn9.Enabled = Falsern ' ExBtn12.Enabled = Falsern ' ExBtn13.Enabled = Falsern ' ExBtn14.Enabled = Falsern MMButton_MACE1.Enabled = Truern MMButton_MACE2.Enabled = Truern End Ifrn Elsernrn 论坛

没有更多推荐了,返回首页