Questions tagged [nchar]

17 questions
1
vote
1 answer

Getting r to output how many 1, 2, 3 etc letter words per array

I need to create an array with counts of how many times a word with one, two, three, ... etc., letters appears in each sentences. That is, the array with 4 columns (one column per sentence) and 9 rows (1 letter, 2 letters, etc.) This is what I have…
user19485723
1
vote
1 answer

Number of characters in an object of class Date in R

I am trying to figure out the rationale for the number of characters in an R object of class Date, which seems to be different than I would expect based on manually counting the length of a date string. For example: str1 <- "2020-12-11" dat1 <-…
cgjeff
  • 41
  • 1
  • 5
1
vote
1 answer

Error in nchar(Tony.raw$neighborhood_overview) : 'nchar()' requires a character vector

I encounter the following error message: Error in nchar(Tony.raw$neighborhood_overview) : 'nchar()' requires a character vector I don't know why nchar can't read into neighborhood_overview column. I have an assignment with provided CSV file to…
pysolver33
  • 307
  • 1
  • 5
  • 13
1
vote
1 answer

NCHAR with UTF8 doesn´t set up correct czech words using file

I would like to ask you help regarding one thing or just your point of view. We have script in PL/SQL that worked correctly. But now when I want to run it, it doesn´t set up correctly czech words like (ěščěščěřěščřěš). I read here in stackoverflow…
Domorodec
  • 91
  • 12
1
vote
0 answers

Difference between nchar and object.size in R

What is the difference between nchar and object.size? Sample below: nchar("TestData", type="bytes") 8 format(object.size("TestData"), units = "b") "104 bytes"
eclairs
  • 1,515
  • 6
  • 21
  • 26
1
vote
2 answers

counting the characters of each cell in data.table

So I have this riddle for all R aficionados out there: library(data.table) set.seed(666) res<-data.table(NULL) for(i in 1:10){ res<-rbind(res,data.table(a=i,b=paste0(letters[sample(1:i)],collapse = ""))) } res<-res[sample(10)] resulting…
amonk
  • 1,769
  • 2
  • 18
  • 27
0
votes
1 answer

Find row with longest string in R

I have this dataframe DF V1 1. 123 2. 12 3. 12345 when I use the code max(nchar(DF$V1)) I get [1] 5 But I would like to know which row has the longest string, something like [3] Any suggestion on how to do…
Nnnz
  • 55
  • 6
0
votes
1 answer

How to convert UTF-16 symbol code to nvarchar2 in Oracle?

I have a UTF-16 code, which is \D83D, and I want to get a symbol out of this code. I need some function like chr that returns nvarchar2 string. Like this: select convert_utf16_to_nchar('\D83D') from dual;
Roman
  • 473
  • 5
  • 22
0
votes
1 answer

R - dynamically create columns using existing column names in sequence

I have a dataframe, df, with several columns in it. I would like to create a function to create new columns dynamically using existing column names. Part of it is using the last four characters of an existing column name. For example, I would…
jvalenti
  • 604
  • 1
  • 9
  • 31
0
votes
0 answers

How can I configure Entity Framework Core to handle nchar(N) fields retrieved from Oracle?

We have done a migration from Microsoft SQL Server to Oracle. We use Entity Framework Core code-first. We have some columns in the databases of type nchar(n), and as you already know, if we insert 'ismail' into a NCHAR(10) column, it will be…
0
votes
0 answers

Debezium SQL Server Connector value of NCHAR

I am using debezium 1.5.0.Beta1 sqlserver connector with SQL Server 2019 and Kafka to capture CDC on my database. I have a problem with NCHAR and NVARCHAR values from database. In my table I have values: NCHAR -> N'あ' and NVARCHAR -> N'こんにちは', and…
0
votes
2 answers

Can I rename vector elements based on their nchar length and their current values using R?

I have 6 vector values vec<-c("Col1","Col2islonger","Col3isabitlonger","Col4isless","Col5willbelongest") I run nchar(vec) my results are 4,12,16,10,17 Based on those values I would like to run a conditional statement or for loop whichever is…
user35131
  • 1,105
  • 6
  • 18
0
votes
0 answers

How to add a character to a string, based on the number of characters in R?

In R, I'm looking for a way to add a specific character to all values in a column of a data frame based on the number of characters. Put it simply: if cell has 4 characters, do nothing. If a cell has 3 characters, add a 0 in front of every cell…
Silhouettes
  • 145
  • 1
  • 10
0
votes
2 answers

Create new values based on length of a string in R?

I have a problem where I need to, ideally, create new values and new rows based on the length of a string. This is my source…
Seth Brundle
  • 160
  • 7
0
votes
1 answer

Expanding/Breaking down a for loop in R

`y <- c() for( position in c("cannon","jackson","benford","paws","moxie") ) { n <- nchar(position) y[position] <- letters[n] } y n What I am essentially trying to do is write the code that is behind the scenes of this for loop but I am running…
1
2