hi, I want to know just enter a string value entering a numeric value is make with the function scan () or scan (nmax ..) but it does not work for string my goal is to enter three string: name and surname and date of birth I try with this code but it shows me errors print ("enter the name") name <- scan (nmax = 1) print ("enter the first name") firstName <- scan (nmax = 1) print ("enter the date of birth") BirthDate <- scan (nmax = 1) best regards alen -- View this message in context: http://r.789695.n4.nabble.com/how-to-enter-a-string-value-tp4649313.html Sent from the R help mailing list archive at Nabble.com.
Alen, look at ?scan and there particularly at the argument 'what'. Hth -- Gerrit On Mon, 12 Nov 2012, alen wrote:> hi, > > > I want to know just enter a string value > > entering a numeric value is make with the function scan () or scan (nmax > ..) > > but it does not work for string > > my goal is to enter three string: name and surname and date of birth > > I try with this code but it shows me errors > > > print ("enter the name") > name <- scan (nmax = 1) > print ("enter the first name") > firstName <- scan (nmax = 1) > print ("enter the date of birth") > BirthDate <- scan (nmax = 1) > > > > > best regards > > alen > > > > -- > View this message in context: http://r.789695.n4.nabble.com/how-to-enter-a-string-value-tp4649313.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.
> scan(what="", nmax=1,sep="\n")1: A four word string. Read 1 item [1] "A four word string."> > readline(prompt="Please type a line> ")Please type a line> A line of text [1] "A line of text"> > readLines(n=1)A line of text. [1] "A line of text." Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf > Of alen > Sent: Monday, November 12, 2012 7:55 AM > To: r-help at r-project.org > Subject: [R] how to enter a string value > > hi, > > > I want to know just enter a string value > > entering a numeric value is make with the function scan () or scan (nmax > ..) > > but it does not work for string > > my goal is to enter three string: name and surname and date of birth > > I try with this code but it shows me errors > > > print ("enter the name") > name <- scan (nmax = 1) > print ("enter the first name") > firstName <- scan (nmax = 1) > print ("enter the date of birth") > BirthDate <- scan (nmax = 1) > > > > > best regards > > alen > > > > -- > View this message in context: http://r.789695.n4.nabble.com/how-to-enter-a-string- > value-tp4649313.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.