[R] inconsistency in display of character vector....

Ben Tupper btupper @end|ng |rom b|ge|ow@org
Sun Jul 8 15:48:48 CEST 2018


Hi,

You will be hard pressed to get helpful answers as you have not provided any way for list readers to replicate your data and code.  Check out this https://rseek.org/?q=reproducible+example

On the other hand, ...

(1)  I have a hunch that one place you are getting tripped up by your effort to treat IDT as a regular data.frame.  In fact, read_excel(), I'm guessing from the readxl package, returns a tibble.  When you subset a tibble like you have with...

leq <- IDT[,1]

... you get a 1-column tibble...

> leq
# A tibble: 208 x 1
   SymbolSeries
   <chr>       
 1 ACCEQ       
 2 ADANIENTEQ  
 3 ADANIPORTSEQ
 4 ADANIPOWEREQ
 5 AJANTPHARMEQ
 6 ALBKEQ      
 7 AMARAJABATEQ
 8 AMBUJACEMEQ 
 9 ANDHRABANKEQ
10 APOLLOHOSPEQ
# ... with 198 more rows

So, that may be part of the issue (but I'm not really sure if it causes the problem you identify).

(2) Also another possible tripping point, when you prepend 'NSE/' to whatever lneq is supposed to be, you are using paste() without specifying the sep argument which defaults to a single space " ".  If you want it to be something else then you have to explicitly set the value of sep.

(3) Finally, you will have much better luck getting help if you configure your email client to send plain text to this list.  Fancily formatted text is made un-fancy by the list-server software - which will mess up your posted code.  That's why you keep getting ...

[[alternative HTML version deleted]]

... at the tail end of your emails.


Good luck!
Ben

> On Jul 8, 2018, at 8:37 AM, akshay kulkarni <akshay_e4 using hotmail.com> wrote:
> 
> dear members,
>                             The mail is not showing the spaces between [192] "NSE/YESBANK" and  [193] "NSE/ZEEL" ...Actually there is a lot of empty spaces between the two.....!!!!!!
> 
> ________________________________________
> From: R-help <r-help-bounces using r-project.org> on behalf of akshay kulkarni <akshay_e4 using hotmail.com>
> Sent: Sunday, July 8, 2018 5:58 PM
> To: R help Mailing  list
> Subject: [R] inconsistency in display of character vector....
> 
> dear members,
>                            I have the following code to update the list of stocks:
> 
> function (snlcqn)
> {
>                  lneq <- c()
>                  URL <- "https://canmoney.in/Intraday%20scrip.xls"
>                  file.string <- tempfile()
> 
>                  download.file(URL,file.string)
> 
>                  IDT <- read_excel(file.string)
> 
>                  leq <- IDT[,1]
> 
>                  for(i in 1:length(leq)){
>                  lneq[i] <- substr(leq[i],1,(nchar(leq[i])-2))}
> 
>                  for(j in 1:length(lneq)){
>                  snlcqna[j] <- paste("NSE/",lneq[j])}
> 
>                  if(identical(snlcqn,snlcqna) == "FALSE"){
>                  return(snlcqna)                         }
> 
>                  else                                    {
>                  return(snlcqn)                          }
> 
> }
> snlcqn is the list of present stocks and snlcqna is the list of updated stocks.
> The problem is the return object, instead of getting displayed in contiguous list, is getting displayed with lots of spaces...( I am using R on a LINUX RHEL AWS instance):
> 
> [192] "NSE/YESBANK"
> [193] "NSE/ZEEL"
> 
> Why is this happening? How can I get the return object as a contiguous list?
> Very many thanks for your time and effort...
> yours sincerely,
> AKSHAY M KULKARNI
> 
>        [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
> 

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/






	[[alternative HTML version deleted]]




More information about the R-help mailing list