शुभ सोमवार!
मैं कमांड लाइन से दिए गए एक csv फ़ाइल में पढ़ने के लिए मेरी स्क्रिप्ट प्राप्त करने के लिए कोशिश कर रहा हूँ, लेकिन मैं यह त्रुटि मिलती रहती:
Amys-MBP:Code amy$ Rscript get_TreeHeight.R trees.csv
Error in make.names(col.names, unique = TRUE) :
invalid multibyte string at '<cf><fa><ed><fe><07>'
Calls: read.csv -> read.table -> make.names
In addition: Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 1 appears to contain embedded nulls
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 2 appears to contain embedded nulls
3: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 3 appears to contain embedded nulls
4: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on '/usr/local/Cellar/r/3.6.1_1/lib/R/bin/exec/R'
Execution halted
यह मेरा कोड है:
args = commandArgs(trailingOnly=FALSE)
MyTrees <- read.csv(args[1], header=TRUE)
TreeDistance <- MyTrees[[2]]
TreeDegrees <- MyTrees[[3]]
TreeHeight <- function(degrees, distance){
radians <- degrees * pi / 180
height <- distance * tan(radians)
print(paste(height))
}
Tree.Height <- TreeHeight(TreeDegrees, TreeDistance)
MyTrees$Tree.Height.m <- Tree.Height
filename <- tools::file_path_sans_ext(args[1])
write.table(paste0(MyTrees, file = ../Results/,filename,_treeheights.csv, row.names=FALSE, col.names=TRUE))
यह दूरी और डिग्री डेटा में पढ़ने के लिए, पेड़ों की ऊंचाई से काम करते हैं एक नई फ़ाइल में dataframe और उत्पादन के लिए ऊंचाई को जोड़ने के लिए चाहिए था। किसी भी मदद की बहुत सराहना की जाएगी, धन्यवाद! : डी