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 8368929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:30:45+00:00 2026-06-09T13:30:45+00:00

please how to insert a carriage return in strip text ( ggplot 2.0.9) I

  • 0

please how to insert a carriage return in strip text (ggplot 2.0.9)

I tried :

mf_labeller <- function(var, value){
  value <- as.character(value)
    if (var=="Nerves") { 
    value[value=="xv1"] <- c("xv","/r", "1")
    value[value=="xv2"]   <- c("xv","/r", "2")

  }
  return(value)
} 

facet_grid(..., labeller=mf_labeller)

It returns

Warning in value[value == "xv1"] <- c("xv","/r", "1") : number of items to replace is not a multiple of replacement length
Warning in value[value == "xv2"] <- c("xv","/r", "2") : number of items to replace is not a multiple of replacement length

and only “xv” “xv” on the figure

Thanks for your help

  • 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-09T13:30:47+00:00Added an answer on June 9, 2026 at 1:30 pm

    The labeller is telling you that it expecting a string of length 1, and only returning the first element.

    Note that I have replaced /r with the new line \n

    mf_labeller <- function(var, value){
      value <- as.character(value)
        if (var=="Nerves") { 
        value[value=="xv1"] <-  paste("xv","\n", "1")
        value[value=="xv2"]   <- paste("xv","\n", "2")
    
      }
      return(value)
    } 
    

    I think should be possible to do this with a regex / string split approach. This works (but I’m sure there is better)

    mf_labeller <- function(var, value){
      value <- as.character(value)
      if (var=="Nerves") { 
        unscramble <- unlist(strsplit(split = '',value))
        value <- paste(paste0(unscramble[1:2],collapse=''), '\n', unscramble[3])
    
      }
      return(value)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used Jquery to insert a variable to div. Please check my code. var
please help me to insert a date from a text box in dd-mm-yyyy format
UPDATE: Please see https://softwarerecs.stackexchange.com/questions/71464/java-library-to-insert-invisible-text-into-a-pdf instead. I want to insert invisible text into an existing
how can insert data array <input name='hello[]'> with function serialize in database? please give
i'm writing a function to send $.post show please how to correctly insert variables
FindFirstFile function is causing There is no disc in the drive. Please insert a
I have a jquery validation rule $.validator.addMethod(hexcolor, function (value, element) { return this.optional(element) ||
Please I need your help with my script. I'm trying to insert values into
I am new to web services. Please give suggestions how to insert and retrieve
Please don't mind that there is no insert fnc and that data are hardcoded.

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.