Home > Mobile >  Files in R and how can i make good use of their data
Files in R and how can i make good use of their data

Time:06-23

I am having this .txt file with some variables and i want for example to convert square feet ("SQFT") to square meters in R with a new variable. How can i do that? ( I have already read the file in R with the command "read.delim" ) enter image description here

CodePudding user response:

I guess it's work for you

# importing .txt file
# file should be your .txt file name. For example "a.txt"
data1 <- read.csv2(file ,header = T ,sep = ";", dec = ".")
    
# 1ft²= 0.09290304m²
SQMT <- data1$SQFT * 0.09290304
    
# Add new column to data1 for SQMT
data1 <- cbind(data1, SQMT)

# To see what's going on
data1
  • Related