Create a new variable based on the first 7 characters of existing variable

后端 未结 2 967
暖寄归人
暖寄归人 2020-12-06 15:08

I\'ve been struggling to create a new variable which contains only the first seven characters of an existing variable. Sorry if this if obvious but I\'ve struggled to find a

2条回答
  •  借酒劲吻你
    2020-12-06 15:22

    You need to store the output of substr(variable2, 1, 7) into variable2. Currently you're printing only

    variable2<-mydata$variable
    variable2<-substr(variable2, 1, 7)
    

提交回复
热议问题