how can i run unix command inside a makefile? [closed] - unix

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
First I have no idea what I am doing so sorry if the question is absurd.
I have a makefile I run at work. The command line for it is:
make -f libclmcomm.so.mak
At the start of this file I want to issue a unix command. Let's just start with echo hi.
So I edited my file and typed:
echo hi
at the type but when I run my make command I get the following error:
missing seperator

StackOverflow is for specific questions, not tutorials. I recommend you read the GNU make manual to understand what make is and how it works: http://www.gnu.org/software/make/manual/html_node/index.html
Your question really doesn't make sense as related to make. Make runs commands that build targets. Every command it runs must be associated with a target to be built. That's why adding a command at the beginning doesn't work: a makefile is not a shell script (if you just want to run a bunch of commands in order the same way every time, then make is not the tool for you: just write a script).

You need to add the command in the right place. It is probably good enough to search through the file for the first line that is indented (with a tab) and place 'echo hi' (also indented with a tab) before that line. Very likely, this will appear after an unindented line that includes the text all:.

Related

Why won't source function work in R Markdown? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed last year.
This post was edited and submitted for review last year and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
More of a conceptual question than a strictly coding one. I have an .R script dedicated to importing and generally cleaning my data. I have several different .Rmd scripts that use the data from the general cleaning .R script to run their specific analyses. I would like to be able to source("DataCleaning.R") at the beginning of each of the .Rmd scripts, that way I could reduce redundancy, but I'm getting this error:
'Pulling' is not recognized as an internal or external command,
operable program or batch file.
I could fix this problem by exporting and importing a .csv, but I'm kind of confused why source() won't work. I've tried it on a few computers now. Works fine in .R but not .Rmd. Would have sworn I've used it in .Rmd in the past. I reread the documentation on it. I couldn't find anyone else reporting this exact error message, but I'm trying to find the file containing the code to take a closer look at 'Pulling'.
QUESTION:
Does source not work in .Rmd, or is this a unique case?
UPDATE:
I managed to get the problem to go away by uninstalling both R and R Studio and reinstalling them. Updating them did not work. The code for source looked fine to me. Still scratching my head a little at this one, because it worked in a regular R script but not R markdown, and was giving me an issue across two different machines, both of which were resolved when I did the full reinstall. I suppose it's fixed for now, but not sure what it could have been.
This question was closed for nonspecificity and not providing reproducible code, but, again, those standards can't really apply in this case because it was a machine-specific problem. I just needed to know whether I was misunderstanding the role of the function. Hopefully the update addresses the critiques, but obviously feel free to close it again if not.
Yes source does work in .Rmd. Here's a reproducible example to prove it:
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
fname = tempfile()
writeLines('print("hello")', fname)
```
```{r}
source(fname)
```
The error you are getting must be caused by the content of your external file.

Renamed an R Source file from my R project. Now the other files can't find it [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I was working on R studio, I had a project with 2 .R files.
One is app.R, the other one used to be called test.R, and app.R was able to invoke it's functions without adding anything else, however, I renamed test.R to calculations.R
Now app.R cannot find any of its functions. I already checked the working directory and they're both in the same locations
What can I do to make app.R detect calculations.R?
That sounds to me like you defined your functions in test.R, also ran it there and than started your app. Once you define a function and ran it, no matter what script they are in, this function is within your global environment. That means that you can start your app, without sourcing your test.R script. However, you should follow the advice of #duckmayr, because in programming you rather want to make everything explicit.
In order to only have functions which are defined within your app environment, consider using the following command in the beginning of your script:
rm(list = ls())
This command will clear your enviroment, so that no unneeded functions, packages, objects and the like are within it.

How to get the basic example Shiny app working? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I can't make the first example of the first Shiny Tutorial to work.... on windows 10, R 3.6.1
I followed : https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/
I get some part of the app : title / input field... no CSS, not working... only the title as shown below : :-(
The issue was coming from one special caracter in my username !
My usernmae "stéphane" was transformed by R into "stiphane"... was led to a wrong path name for the shiny files...
Creating another Windows user without any accentuated caracter wolved the problem...

calling a function from another script [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I want to use a function from one script in another script but i either get an erorr or nothing is happend, depend on my code syntax. When i use the source("file_name) i get an erorr, and when i add the if(exists("function_name", mode = "function")) i get nothing..
hope you can help
have a good day
Or
In a different way you can choose your code script file using file.choose (avoiding problems related to the working directory) like this:
source(file.choose())
Terru_theTerror is absolutely right: it looks like there is something wrong with your source folder.
You may check the current name of your working directory with getwd() and check what contains this directory by dir(). If there your source file is placed elsewhere, your should change your current directory or to include the path to your source file by using source():
source_dir_name <- "D:/Work/Sources"
source_file_name <- "file_Name.R"
source_with_path <- paste(source_dir_name,"/", source_file_name, sep = "")
#
setwd(source_dir_name)
source(source_file_name)
# or
source(source_with_path)

User defined function to R library function like avg() [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I created a user defined function in R for checking whether a given number is prime or not. How can I make that user defined function as library function like avg or sd?
library(numbers)
isPrime(561)
# [1] FALSE
You will have to change the startup script. Use this site for more information. Customizing R:startup.
There is an Rprofile file that then refers to a .First() function. That user added functions to the .First function. I looked for it on my system and found an Rprofile file in the R folder, but did not find the latter.
I started going through the system files to do it myself. But not knowing exactly what I'm doing can cause more damage in the long run. Screwing something there may require reinstallation of the program.
Perhaps someone knows an easier way. Try it and report back, but I wouldn't recommend messing with system files unless you are very careful and the functions are absolutely necessary to your working environment startup. gl
Update
I found the Rprofile.site file in the R/etc directory. I added a .First() function. On opening RStudio in the next session, the packages I added loaded, but the function I put in it did not.
Update 2
I got it to work. I added this .First function to the Rprofile.site file in the etc folder.
.First <- function(){
library(dplyr)
library(stringr)
source('path/myfinctions.R')
}
And it loaded the packages and the functions that I have in the 'myfunctions.R' file. Thanks for asking this question as I have a place to save the functions that I want to define and load into R automatically. : )

Resources