Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:35:18+00:00 2026-06-05T06:35:18+00:00

I made a function that removes en and em dashes. Great! But when I

  • 0

I made a function that removes en and em dashes. Great! But when I try to upload it to github and then re-install as a package something happens to the function. It replaces the dashes with some gobly gook characters. That usually means unicode stuff. I want to be able to export the function.

I tried replacing \\– with \u2013 and 0x2013. Also played with fixed and perl arguments. No luck.

Here’s:

  1. the function that works
  2. a test case
  3. how it looks after I import it back in

Code:

#What I exported
incomp <- function (text.var){
    x <- gsub("\\–", "|", x)
    x <- gsub("\\—", "|", x)
    return(x)
}

#here it is in action working well
x <- c("I like...", "well?.", "–", "—")
incomp(x)

#[1] "I like..." "well?."    "|"  "|"   #what I look like (ain't I pretty?)

#what the exported function looks like when the package compiles
incomp <- function (text.var){   
    x <- gsub("[–]", "|", x)
    x <- gsub("[—]", "|", x)
    return(x)
}

#I don't work anymore
x <- c("I like...", "well?.", "(–", "—")   #I'm broken
incomp(x)

A search for r and unicode brings up lots of information but I can’t seem to apply it to my situation correctly.

The unicodes are:

  • u2013 for the en dash
  • u2014 for the em dash

This post is cross posted at talkstats.com. I generally do not cross post but am under the gun to get this out. I will link the two threads. LINK TO THE TALKSTATS THREAD

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:35:21+00:00Added an answer on June 5, 2026 at 6:35 am

    The default when exporting locale of R are set to “C” I guess. Your locale maybe different.
    Perhaps you can use Sys.setlocale in your package?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ive made a function that should remove a p-element if it doesnt have any
I made a function that would ask a player to enter a letter until
I have made a function that gives users instructions. When I call it I
I've made some function that generates an email template. Code it generates is pure
i've made some kind of encode function that uses an array with 62 characters
I'm trying to use Seq.cache with a function that I made that returns a
Hi have made this function which is made to replicate an error that I
I have made a function to cound the weeks in a year, and that
I made this simple function to filter the data. I add the symbols that
I made a website that contains products with the url: http://somesite.com/controller/function/brand_id/product_id . I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.